How to Mount Block Storage on a Linux Server
When you want to attach additional storage and make it usable on your server. This article explains how to mount block storage on a Linux server.
Our provisioning system always attempts to attach and automatically mount a volume on your VPS server. However, due to the customizations you may have made on the server, the volume's mounting may fail.
In such cases, you can SSH to the VPS server and follow the steps below to mount the volume on your VPS.
Partitioning of the volume.
- Before you can store data on a raw volume, it needs to be partitioned with a filesystem. To format it with an EXT4 filesystem, run the following command.Subsequent volumes on the same VPS will appear as /dev/vdc, /dev/vdd, and so on.
sudo mkfs.ext4
- Creation of a directory or mount point.
Every device in a Linux system can be accessed through a mount point, for which you will need to create a directory. We recommend using the given naming convention for the directory name for easy identification.
sudo mkdir /mnt/vol-us-1
- Mounting the partition on the server
This step makes the volume accessible through a mount point.
sudo mount -t ext4 /dev/vdb /mnt/vol-us-1
Please use the appropriate device and mount point names from the earlier steps. - Updating /etc/fstab
To persistently mount the volume on the server, you must update the fstab file. If you skip this step, you will lose all the above settings upon restart.bin/bash -c "if [ $(cat /etc/fstab | grep -i /dev/vdb | awk '{print $1}')!="/dev/vdb" ]; then sudo bash -c 'echo \/dev/vdb /mnt/vol-us-1 ext4 defaults,nofail,discard,noatime 1 2\ >> /etc/fstab';fi"