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.
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.
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: Start the VM and mount the disk
After the VM is running, connect over SSH and mount the disk.
# Check attached disks
lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINT
# Create a filesystem (first use only)
sudo mkfs.ext4 /dev/vdb
# Mount
sudo mkdir -p /data
sudo mount /dev/vdb /data
# Auto-mount on reboot
echo '/dev/vdb /data ext4 defaults 0 2' | sudo tee -a /etc/fstab
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