Skip to main content

Attach and mount an Arianet cloud volume

A volume is block storage that is created separately from a server and attached to it. It suits data that should be independent of the server itself: uploads, databases, container data or backups. You can detach a volume from one server and attach it to another in the same data center, and grow it without losing data.

In this tutorial you create and attach a volume, format and mount it permanently, and grow the filesystem after a resize.

Prerequisites​

  • A cloud server with Ubuntu 24.04 (or 22.04) and a sudo user
  • For the CLI parts: the Arianet CLI with a token that has cloud:servers:write
note

A volume is 10 to 10240 GB and can only grow. It is billed hourly by size and stays, and keeps being billed, after the server is deleted until you delete it.

1. Create and attach the volume​

In the panel: on the server page, use the Volumes tab to create and attach a volume, or create one from the cloud menu under Storage → Volumes («ذخیره‌سازی ← دیسک‌ها») and attach it to the server.

With the CLI:

# create a 50 GB volume and attach it to server 12 (same datacenter)
arianet cloud volumes create --name data --size 50 --server 12 --wait

# or attach an existing volume
arianet cloud volumes attach <volume-id> --server 12 --wait

Volume details, including its device path in the server:

arianet cloud volumes get <volume-id>

The device field is the stable device path inside the server (for virtio volumes; it is empty on scsi), and device_id_prefix is the part of the volume's id that appears in its serial and its name under /dev/disk/by-id/.

2. Find the disk on the server​

lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS,SERIAL
ls -l /dev/disk/by-id/

The new disk shows up with the size you chose and no MOUNTPOINTS, usually /dev/vdb (virtio) or /dev/sdb (scsi). Below we assume /dev/vdb; replace it with what you see.

danger

Double-check the device name. mkfs on the wrong disk (for example the main disk /dev/vda) erases all its data.

3. Check it is empty, then format​

sudo blkid /dev/vdb || echo "no filesystem"
  • If the output is no filesystem, the disk is empty; format it.
  • If it prints TYPE="ext4" or TYPE="xfs", the disk already has a filesystem (for example it was used on another server, or you picked a filesystem at creation). Do not format it; go to step 4.

Format an empty disk with ext4, on the whole disk without a partition (this makes growing it later simpler):

sudo mkfs.ext4 -L data /dev/vdb

For XFS: sudo mkfs.xfs -L data /dev/vdb (package xfsprogs).

4. Mount it once​

sudo mkdir -p /mnt/data
sudo mount /dev/vdb /mnt/data
df -h /mnt/data

5. Mount it permanently with fstab​

Names like /dev/vdb can change when other disks are attached, so use the filesystem UUID in fstab:

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

The nofail option matters: if the volume is ever detached, the server boots without it instead of stopping in emergency mode. For XFS write xfs instead of ext4.

Test fstab without rebooting:

sudo umount /mnt/data
sudo systemctl daemon-reload
sudo mount -a
sudo findmnt --verify
findmnt /mnt/data

If mount -a shows no error and findmnt /mnt/data shows the disk, it will be mounted after a reboot too. Finally sudo reboot once and check df -h /mnt/data again.

Give your user access (optional):

sudo chown $USER:$USER /mnt/data

6. Grow the volume​

Grow the volume with the CLI (or with POST /volumes/{id}/actions/resize in the cloud API, or by raising size on the arianet_volume resource in Terraform):

arianet cloud volumes resize <volume-id> --size 100 --wait

Then on the server:

lsblk /dev/vdb          # should show the new size

If the new size does not show, rescan the device (replace vdb with your disk):

echo 1 | sudo tee /sys/class/block/vdb/device/rescan

Grow the filesystem without unmounting:

# ext4 on the whole disk
sudo resize2fs /dev/vdb

# xfs (takes the mount point)
sudo xfs_growfs /mnt/data

df -h /mnt/data

If you partitioned the disk (for example /dev/vdb1), grow the partition first: sudo growpart /dev/vdb 1 (package cloud-guest-utils), then sudo resize2fs /dev/vdb1.

7. Detach the volume​

  1. Stop the services that use the disk.
  2. sudo umount /mnt/data
  3. If the volume will not come back, remove its line from /etc/fstab.
  4. arianet cloud volumes detach <volume-id>, or use the panel.

Common errors​

ErrorFix
wrong fs type, bad option, bad superblockThe disk is not formatted, or the filesystem type in the command or fstab is wrong. Check sudo blkid /dev/vdb.
target is busy on umountA process uses the disk: sudo lsof +f -- /mnt/data. Also leave /mnt/data (cd ~).
The server does not boot after detachingThe fstab line has no nofail. Log in through the panel console (or rescue mode) and fix the line.
df shows the old size after a resizeThe filesystem was not grown; run resize2fs or xfs_growfs.
The volume will not attachThe volume and server must be in the same data center, and the volume must not be attached to another server (already_attached).

Backing up the volume​

A cloud server snapshot copies the server's main disk. Back up important data on separate volumes separately (snapshots, backups and restore).

Next steps​

Create your volume​

In Arianet Cloud, create volumes of up to 10 TB, grow them whenever you need, and pay only for the hours they exist. In the Arianet panel, go to Cloud server / Cloud Computing → Storage → Volumes.