1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Mount a Volume on a Cloud VPS
This guide explains how to format and then mount the Volume dedicated to storing your data on your VPS Cloud.
Indeed, by default, these unmanaged Cloud Servers are offered with two Volumes:
- 1 Volume for the operating system of your choice (/dev/vda)
- 1 Volume for storing your data (/dev/vdb)
The volume for data storage (/dev/vdb) must be formatted and then mounted by the client.
1. SSH commands to format storage volume
If you choose XFS for example, it is necessary to install the appropriate tools (if they are not already present):
sudo apt install xfsprogs
Then format the volume with the following SSH commands:
sudo mkfs.xfs -f /dev/vdb
And if you choose EXT4 :
sudo mkfs.ext4 /dev/vdb
If necessary, it is possible to format the volume with another file system supported by your distribution.
2. Mount the storage volumeWarning: if you mount your data volume in /home, you will no longer be able to connect to your server via your private key on the next restart (because SSH will look for the keys in the ".ssh" folder in the home (home folder) of the user and if the data volume is mounted on this folder, the keys are lost). Therefore, it is necessary to first copy the data to be kept. For example, as root:
mount /dev/vdb /mnt/home
rsync -rlptgoDHAX /home/ /mnt/home/
mount /dev/vdb /home
What it does in order:
- create a temporary folder
- mount the volume on the temporary folder
- we copy the contents of the original "/home" folder to the root of the volume while retaining the rights, owner, group, etc. ( be careful, you may need to install the "rsync" package depending on the Linux distribution chosen )
- unmount the volume from the temporary folder
- mount the volume on the "/home" folder
- delete the temporary folder
This way you should be able to mount the volume to "/home" while keeping the initial configuration that will be installed. However, we recommend setting a password for "root" so as not to lose control in the event of an error. The password can be removed afterwards.
Alternative solution: do not mount in "/home"...
This is a standard location to mount the data volume because it is generally in "/home" that users will work and especially store their data. A user without special rights will normally be limited to his "/home/user" directory. It is possible to indicate another default directory for a user (but the configuration will no longer be "standard").
Another alternative solution : Automatic mounting of the volume at startup
A mount does not effectively resist a restart. If you want to make the modification persistent, you can add your volume to the "/etc/fstab" file. Debian documentation on this: https://wiki.debian.org/en/fstab
3. SSH commands to mount the storage volume
sudo mount /dev/vdb mount_point
SSH login help
For example, to mount the data volume in the /home directory of your Cloud Server, the command to execute is as follows:
sudo mount /dev/vdb /home
A guide covering these steps and explaining in detail how to deploy a managed server with Laravel Forge is available by clicking here .