Increase the storage of a Cloudpanel server with Volumes Block Storage

How to increase the storage of a Cloudpanel server with Volumes Block Storage on DigitalOcean or similar. Sometimes you have a tremendous website or multiple websites that use more disk space or storage than is provided by the virtual server or plans available.

This guide can also be used for non-Cloudpanel servers, the only difference is the /home folder and permissions where the data is stored. You can change the location according to the storage location of your control panel or use case.

Volumes are network-based block devices that provide additional data storage for Droplets or instances. You can move them between Droplets, create disk images of them, and resize them at any time.

How to Create and Set Up Volumes for Use with Droplets on DigitalOcean

To create and use a new volume with a Droplet on DigitalOcean, you need to create the volume itself, and then format and mount it to prepare it for use. Formatting and mounting are automatic by default for Droplets with supported operating systems, and you can choose to format and mount manually.

See an article here about creating and adding Volumes on DidigalOcean:
How to Create and Set Up Volumes for Use with Droplets

How to mount the Volume to use with Cloudpanel

I created a new Droplet and added a Volume, which will automatically mount. However, to use it to increase storage to be used with Cloudpanel I need to re-mount it as the /home folder.

I assume you successfully deployed a Droplet with a Volume, now SSH into the server and configure the Volume on the Droplet.

Re-mount the volume

Make a copy of /home

# mkdir /tmp/home_backup

Copy the content of /home to /tmp/home_backup

# cp -a /home/. /tmp/home_backup/

Get the volume’s mount point 

# df -h

Unmount the volume with umount

# umount --verbose /mnt/volume_lon1_02

Find the mount unit information:

# cd /etc/systemd/system/

# ls
# nano /etc/systemd/system/mnt-volume_lon1_02.mount

Edit the file and change the mount point from /mnt/volume_lon1_02 to /home
Replace the highlighted disk ID with your disk ID.

[Unit]
Description=Mount DO Volume volume-lon1-02

[Mount]
What=/dev/disk/by-uuid/82a48a18-873f-11e6-96bf-000f53315a41
Where=/home
Options=defaults,nofail,discard,noatime
Type=ext4

[Install]
WantedBy = multi-user.target

Set up Persistent Mounting:

# nano /etc/fstab

Add the volume to /etc/fstab
You can find this information about the mount unit information also in the DigitalOcean config instructions. Replace the highlighted disk ID with your disk ID.

/dev/disk/by-uuid/82a48a18-873f-11e6-96bf-000f53315a41 /home ext4 defaults,nofail,discard,noatime 0 2

check that /etc/fstab is parsable and usable:

# findmnt --verify --verbose

Mount the Volume to /home

# mount -o defaults,nofail,discard,noatime /dev/disk/by-uuid/82a48a18-873f-11e6-96bf-000f53315a41 /home

Move the data from the temporary backup directory to the new disk:

# cp -a /tmp/home_backup/. /home/

Set ownership and permissions:

# chown -R clp:clp /home/clp/
# chown -R mysql:mysql /home/mysql/

Check if persistent mounting is working: 

# mount -a
# Reboot


Check if the volume is mounted after reboot:

# df -h

Conclusion

Setting up and configuring a Volume is easy if you have some guidance like this tutorial, it should work for most providers, and be sure to replace the volume IDs with yours as those are just an example.

After setting up a Volume it is also recommended to set up automated daily backups, because the server backup will not make a backup of the Volume.

You can make manual snapshots or make automated snapshots with Snapshooter. Alternatively, you can use the DigitalOcean API or DigitalOcean CLI(doctl CLI). Check this link for more information about Snapshooter: Snapshooter Marketplace Add-on

Here is an article on DigitalOcean on how to make snapshots of Volumes:
How to Create Snapshots of Volumes

Try DigitalOcean for free, and get a $200 credit to try

I am using different providers to host virtual servers and so far the General Purpose (Premium Intel) Droplets have the best performance.

Sign up and get $200 in credit for your first 60 days with DigitalOcean.

Leave a Comment