After you attach a volume to a Linux node, it appears as a block device. To use it, you format
it with a file system (if it is empty) and mount it at a directory. Once mounted, everything
you write to that directory is stored on the volume. The examples assume the volume shows up as
/dev/vdb and your node’s own root disk is /dev/vda1; your device names can differ, so check
them first.
Before you begin
Section titled “Before you begin”- A volume attached to the node. See Attach a volume.
- Access to the node over SSH.
Find the volume’s device name
Section titled “Find the volume’s device name”On the node, list the block devices:
lsblkThe attached volume is the unmounted device, for example /dev/vdb. Check its device name
before doing anything else.
Check whether the volume needs formatting
Section titled “Check whether the volume needs formatting”An empty volume has no file system and must be formatted; a volume created from a snapshot often already has one. Check which you have:
sudo file -s /dev/vdbIf it prints data, the volume has no file system. If it prints a type such as XFS or ext4,
it is already formatted, skip the formatting step and do not format it again, or you erase its
data.
Format the volume
Section titled “Format the volume”An empty volume needs a file system. This example uses XFS; ext4 also works if you prefer it.
sudo mkfs -t xfs /dev/vdbFormatting erases all data on the volume. Run it only on an empty volume, never on one created
from a snapshot or one that already holds data. If the command is not found, install the XFS
utilities: sudo yum install -y xfsprogs, or on Ubuntu sudo apt install -y xfsprogs.
Mount the volume
Section titled “Mount the volume”-
Create a directory to mount it at, for example
/data:sudo mkdir /data -
Mount the volume to that directory:
sudo mount /dev/vdb /data -
Confirm the mount:
df -h
You can read and write to /data now, and the volume stores it.
Keep the mount across a reboot
Section titled “Keep the mount across a reboot”To keep the mount across reboots, add it to /etc/fstab by the device’s UUID.
-
Find the UUID:
sudo blkid /dev/vdbThe output shows a line like
UUID="e7c5b2f2-..." TYPE="xfs". Copy the UUID value. -
Edit
/etc/fstab:sudo nano /etc/fstab -
Add a line at the end, using your own UUID and mount point:
UUID=e7c5b2f2-8b2a-4e13-b9a9-bb3f122a91f1 /data xfs defaults,nofail 0 2 -
Apply the configuration and check for errors:
sudo mount -a
If mount -a prints no errors, the setup is correct. Reboot the node and run df -h again to
confirm /data mounts automatically.
The volume is mounted and stays mounted across reboots. When you later detach it, unmount it and remove its /etc/fstab line first; see Detach a volume. If it will not mount, see Troubleshooting Volumes.