Skip to navigation

Attach volumes

A volume is an extra disk from Block Storage that you plug into a VM. Inside the VM it appears next to the root disk (/dev/vda) as another device, such as /dev/vdc. Unlike the root disk, a volume isn’t tied to the VM: you can detach it and attach it to another VM, and it’s kept when the VM is deleted.

When to use a volume

You want to…Use
Keep data (databases, uploads, logs) safe when you delete or replace the VMA volume (this page)
Add disk space without moving to a bigger planA volume
Move data from one VM to anotherA volume: detach it, then attach it to the other VM
More vCPUs or memory as well as diskResize the VM
Store files that apps fetch over HTTPObject Storage

The root disk that comes with the plan (50 GB to 400 GB) is fine for the operating system and apps. It’s deleted with the VM.

How it works

  1. You create a volume in the same location as the VM.
  2. You attach it from the Block Storage page. The VM sees a new, empty disk.
  3. The first time, you format it (create a filesystem) and mount it (give it a folder, such as /mnt/data).
  4. You add it to /etc/fstab so it’s mounted again after every reboot.

Before you begin

  • A Running Cloud VM or GPU VM.
  • A Ready volume in the same location. See Create a volume.
  • SSH access to the VM (or Remote Desktop for Windows).
  • A volume is billed from creation until you delete it, whether it’s attached or not. See Block Storage.

Attach and mount a volume (Linux)

1

Attach it in the portal

Open Block Storage, click the volume, then Attach to Server. Pick the VM under Select Server and click Attach to Server. When it’s done, the volume shows In Use and the device path, for example Device: /dev/vdc. There’s no volume section on the VM’s own page; attaching always starts from Block Storage.

2

Find the new disk

Sign in to the VM and list its disks:

lsblk

The new disk has no partitions and no mount point, for example vdc 10G disk. Use the device shown in the portal.

3

Format it (first time only)

sudo mkfs.ext4 /dev/vdc

Formatting erases the disk. Only do it on a new, empty volume. Never format a volume that came from a restore or from another VM: it already holds data.

4

Mount it

sudo mkdir -p /mnt/data
sudo mount /dev/vdc /mnt/data
df -h /mnt/data
5

Mount it again after every reboot

Add the volume to /etc/fstab by its UUID, which doesn’t change when device names do. nofail lets the VM boot even if the volume is detached:

echo "UUID=$(sudo blkid -s UUID -o value /dev/vdc) /mnt/data ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab
sudo mount -a

mount -a prints nothing when the line is correct.

The volume’s Mount Instructions tab in Block Storage shows the same commands with your device filled in.

Attach and mount a volume (Windows)

  1. Attach the volume in Block Storage as above.
  2. In the VM, open Disk Management.
  3. Right-click the new disk, choose Online, then Initialize Disk (choose GPT for disks over 2 TB).
  4. Right-click the unallocated space, choose New Simple Volume, and follow the wizard to assign a drive letter and format it as NTFS.

Verify

df -h /mnt/data
echo ok | sudo tee /mnt/data/test.txt
sudo reboot

After the VM is Running again, cat /mnt/data/test.txt prints ok, which shows the volume is mounted automatically.

Detach a volume

  1. Stop anything writing to the volume, then unmount it inside the VM: sudo umount /mnt/data.
  2. Remove its line from /etc/fstab (or keep nofail on it).
  3. On the volume’s page in Block Storage, click Detach.

The volume keeps its data and can be attached to any VM in the same location. Detaching without unmounting first can corrupt its filesystem.

Deleting a VM detaches its volumes automatically and keeps them.

Volumes in snapshots and backups

  • Snapshots let you choose: Root volume only, All attached volumes, or Selective volumes. See Create a snapshot.
  • Backups always include every volume attached when the backup runs. See Backups.

Restored volumes are attached to the target VM but not mounted. Use the Mount Instructions in the recovery point’s Details, and don’t format them.

Limits

Value
LocationThe volume and the VM must be in the same location
VMs per volume (portal)1 at a time
Kept when the VM is deletedYes, detached automatically
Root diskNot a volume; 50 GB to 400 GB set by the plan, deleted with the VM

Troubleshooting

You seeWhat it meansWhat to do
The VM isn’t in the Select Server listIt’s in another location, or it isn’t runningCreate the volume in the VM’s location, or start the VM.
lsblk doesn’t show the new diskThe attach hasn’t finishedWait until the volume shows In Use, then run lsblk again. If it’s still missing, reboot the VM.
mount: wrong fs type, bad option, bad superblockThe volume has no filesystem yetOn a new, empty volume only: run sudo mkfs.ext4 /dev/vdc.
The VM won’t come back after a rebootAn /etc/fstab line points at a missing volume without nofailRestore from a snapshot, or contact support. Always add nofail.
The root disk is still full after attachingFiles still go to the root diskMove data to /mnt/data, or point your app’s data folder there.
A restored volume looks emptyIt isn’t mounted yetRun the Mount Instructions from the recovery point’s Details. Don’t format it.