Attach a volume to a compute instance
5 min read
Overview
Volumes provide independent, resizable block storage that you can attach to any Compute Instance in the same region. This guide walks through attaching an existing volume to a running instance and mounting it so your application can use it.
Before you begin
- A running Compute Instance with SSH access configured.
- A Volume created in the same region as the instance.
Open Compute Instances
Click Compute Instances in the sidebar.
Select the instance
Check the row for the instance you want to attach a volume to.
Attach the volume
Click Attach Volume in the selection bar.
Choose the volume
- Web
- CLI
Pick the volume to attach from the dropdown, then click Confirm.
addVolume— The existing volume you want to attach — pick it from the dropdown;<your-volume-name>here is a placeholder, not a real volume to look for.
sonic instances update web-01 \
--addVolume <your-volume-name>
Mount the filesystem
SSH into the instance, format the device if it's new, then mount it:
sudo mkfs.ext4 /dev/sdb
sudo mkdir -p /mnt/data
sudo mount /dev/sdb /mnt/data
tip
Add an entry to /etc/fstab so the volume remounts automatically after a reboot.
Confirm it's mounted and writable:
df -h /mnt/data
Filesystem Size Used Avail Use% Mounted on
/dev/sdb 98G 61M 93G 1% /mnt/data