Block storage
Overview
Block storage is persistent storage attached to a VM like a disk. Data is preserved when the VM is deleted, and the volume can be reattached to a different VM.
Block storage attached to a VM is kept when the VM is deleted, and continues to be billed until you delete the volume yourself. Unneeded storage must be deleted manually. See Detaching and deleting a disk.
Performance specs
| Metric | Spec |
|---|---|
| Bandwidth | Under 170 GiB: up to 128 MiB/s · 170 GiB and above: up to 250 MiB/s |
| IOPS | 3 IOPS per 1 GiB of disk size · minimum 100, maximum 16,000 IOPS · 1 IOPS is up to 256 KiB |
| Burst | Up to 3,000 IOPS sustained for 1,800 seconds |
Creating block storage
-
From the left menu Block Storage > Block Storage, click Create Block Storage.
-
Configure the following:
Field Description Block storage name A recognizable name (1–256 characters) Storage size (GiB) Required capacity. Minimum 10 GiB, maximum 32,768 GiB (32 TiB). When creating from an image, must be at least the image's original size Zone Choose the same zone as the VM Disk type Empty disk(data only) /Image(bootable OS disk) /Snapshot(restore from an existing snapshot)Disaster recovery Automatically replicate to another zone (higher rate) -
Click Create.
If a VM was created with DR, the block storage you attach must also have DR enabled (otherwise you'll see machineDrMismatch). Likewise, you can only attach standard block storage to a standard VM.
Growing an existing disk (resize)
The volume can only be modified when the attached VM is in Ready (idle) or Stopped state.
- Stop the target VM.
- Pick the target volume in Block Storage.
- Click Edit.
- Increase the value for Storage size (GiB) (shrinking is not supported).
- Click Save and wait until the status becomes Ready.
- Start the VM again.
- After connecting, confirm the filesystem has been expanded.
df -h
# Check that /dev/vda1 has grown
The filesystem is expanded automatically after the restart.
Attaching an additional disk
You can attach data-only disks alongside the existing OS disk. A virtual machine holds up to 31 data disks.
You do not need to stop it first. Only the boot disk requires a stop before it can be detached.
Step 1: Create an empty block storage volume
Pick Empty disk as the disk type to create a data-only volume.
Step 2: Attach to the VM
- On the new volume's detail page, click Edit.
- Pick the target VM in the Attached machine ID field.
- Click Save.
Step 3: Mount the disk
On a running virtual machine the disk appears as soon as you save; if it was stopped, start it and connect over SSH. The attached disk has no filesystem yet and cannot be used as-is, so the five steps below make it usable.
It comes from an Ubuntu 24.04 virtual machine with a 10 GiB disk attached. Device names, UUIDs, capacity, block counts, and the mke2fs version vary by environment, so your values will not match exactly. What to check is noted under each output.
1. Identify the disk
Find out which device is the disk you just attached. This is where you get the device name used by every later command.
lsblk -o NAME,SERIAL,SIZE,FSTYPE,MOUNTPOINT
NAME SERIAL SIZE FSTYPE MOUNTPOINT
vda ECI-OS-DISK 20G
├─vda1 19G ext4 /
├─vda15 106M vfat /boot/efi
└─vda16 913M ext4 /boot
vdb ECI-CLOUDINIT-DISK 16M vfat
vdc ECI-DISK-9c9e89921b0 10G ← the disk you attached
Identify disks by the SERIAL column.
| SERIAL | Disk |
|---|---|
Starts with ECI-DISK- | A data disk you attached, followed by the first part of the block storage ID |
ECI-OS-DISK | The OS disk — ⚠️ do not format |
ECI-CLOUDINIT-DISK | Used for virtual machine initialization — ⚠️ do not format |
Blank FSTYPE and MOUNTPOINT columns are not enough to go on — the OS disk (vda) shows both blank as well. The commands take the device name from the NAME column, not the SERIAL, so this example calls for vdc in place of {new-disk-name}.
If the disk is still missing from lsblk after attaching, stop the virtual machine and start it again. One restart is enough; from then on it accepts disks while running. See The disk I attached is not visible inside the virtual machine.
2. Create a filesystem (format)
An attached volume is a raw block device with no filesystem, so it cannot store files as-is. This creates an ext4 filesystem to manage files, directories, and their metadata. Perform it only once per disk.
mkfs erases everything on the target diskDo not run the example as-is: replace {new-disk-name} with the device name you found in step 1. Run it only on a brand-new, empty disk.
If step 1 showed a value such as ext4 under FSTYPE, the disk is already formatted — you are reattaching a disk you used before. Skip this step and go straight to step 3 to mount it. Running mkfs here destroys everything on the disk.
sudo mkfs.ext4 /dev/{new-disk-name}
mke2fs 1.47.0 (5-Feb-2023)
Discarding device blocks: done
Creating filesystem with 2617344 4k blocks and 655360 inodes
Filesystem UUID: 87e1e238-6a9a-45fb-8ccf-d39a4342aaf2
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
The filesystem is created once the final line reads done. The Filesystem UUID is generated fresh on every format, so it differs every time.
3. Mount
This attaches the filesystem to /data so you can read and write files there. mount needs that directory to exist, so create it first.
sudo mkdir -p /data
sudo mount /dev/{new-disk-name} /data
df -h /data
Filesystem Size Used Avail Use% Mounted on
/dev/vdc 9.8G 24K 9.3G 1% /data
Seeing /data under Mounted on means it worked.
The top-level directory of a freshly formatted disk is owned by root. Creating a file as a regular user fails with Permission denied, so change the owner unless you want to prefix every write with sudo. The new owner is stored on the disk itself, so it survives reboots and remounts.
sudo chown $USER:$USER /data
4. Register for auto-mount on reboot
The mount from step 3 is lost on reboot. Registering it in /etc/fstab restores it on every boot. Device names can change between attachments, so register the UUID instead, and add nofail so the virtual machine still boots if the disk has been detached.
UUID=$(sudo blkid -s UUID -o value /dev/{new-disk-name})
echo "UUID=$UUID /data ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab
UUID=87e1e238-6a9a-45fb-8ccf-d39a4342aaf2 /data ext4 defaults,nofail 0 2
tee echoes back the line it just appended.
5. Verify the entry
A typo in /etc/fstab only surfaces at the next boot, when you may be locked out and recovery is awkward. Check that the entry is valid now.
sudo mount -a
No output means the entry is correct.
Once this is done, files written under /data land on the attached disk, and the mount is restored automatically on reboot.
Detaching and deleting a disk
Detaching only separates the disk from the virtual machine — billing continues. To stop billing you must also delete the volume.
Back up anything you need with a snapshot before deleting.
Step 1: Unmount inside the virtual machine
Always clean up inside the virtual machine before detaching. Detaching a mounted disk can lose in-flight writes. Remove the /etc/fstab entry as well. With nofail the machine still boots normally if you leave it, but the entry keeps pointing at the UUID of a disk that is no longer attached, and mounting a different disk at the same path later would duplicate the mount point.
# 1) Unmount
sudo umount /data
# 2) Remove the fstab entry so it no longer points at a disk that is gone.
sudo sed -i '\|/data|d' /etc/fstab
target is busyA process is still using the directory. The most common cause is your own shell sitting inside /data — run cd / and try again. If it persists, find the process with sudo lsof /data and stop it. Forcing the unmount can corrupt data.
Confirm the cleanup.
findmnt /data
cat /etc/fstab
LABEL=cloudimg-rootfs / ext4 discard,commit=30,errors=remount-ro 0 1
LABEL=BOOT /boot ext4 defaults 0 2
LABEL=UEFI /boot/efi vfat umask=0077 0 1
No output from findmnt and no /data line in /etc/fstab means you are done.
/data stays behind as an empty directory. Nothing was deleted — the disk is simply detached, and the files are still there when you mount it again or attach it to another virtual machine. Remove the directory with sudo rmdir /data if you no longer need it.
Step 2: Detach from the virtual machine
This separates the disk from the virtual machine. The volume and its data remain, and you can attach it to another virtual machine later.
- On the volume's detail page, click Edit.
- Clear the Attached machine ID field.
- Click Save.
Data disks detach while the virtual machine is running. The boot disk can only be detached after stopping the virtual machine.
Confirm that the disk has been detached from the virtual machine.
lsblk -o NAME,SERIAL,SIZE,FSTYPE,MOUNTPOINT
The detached disk's row — the one whose SERIAL starts with ECI-DISK- — is no longer listed once the detach has been applied. If it still appears, the console save has not taken effect yet; run the command again once it completes.
Step 3: Delete the block storage
This removes the volume and its data for good, which is what stops the billing. Skip this step if you want to keep the disk.
- Select the volume in the Block storage list.
- Click Delete and type the volume name to confirm.
Billing stops once the deletion completes.
In the delete dialog the confirm button becomes Detach and delete, which detaches and then deletes in order. Even then, unmount it first as in Step 1.
If the virtual machine is running, stop it before deleting. While it runs, detaching is processed asynchronously and can race with the delete. See the resource deletion FAQ.
Backing up with snapshots
You can save a point-in-time copy of a block storage volume.
- On the volume's detail page, click Create Snapshot.
- Restore the data into a new volume, or attach the new volume to a different VM, by creating a block storage volume from the snapshot.
See Snapshots for details.
Next steps
- Snapshots: point-in-time backup and restore
- Snapshot scheduler: automatic backups
- Choosing a storage type: block vs object vs PFS