SimplerCloud Pte Ltd

×
×

Configuring cPanel to make use of the data-disk to store data

Back

Note: You can purchase our System Admin - WHM/cPanel Initial Configuration and Optimisation ($30 one-time) if you would like to engage our service to do this, by logging in to our portal and then go to Order > Additional Services > System Admin - WHM/cPanel Initial Configuration and Optimisation.

This service also covers installing the latest patches for CentOS as well as upgrading cPanel to the latest stable release version, in addition to the initial configuration and optimisation of WHM/cPanel.

====

cPanel uses /home folder to store most of your data, and this /home folder resides on the root-disk by default.  (For more about the difference between your server's root-disk and data-disk, please read this)

As a rule, we recommend customers take the extra step to configure cPAnel to make use of the data-disk to store data by mounting the data-disk partition as /home.  This is a recommended one-time task before you create new cPanel accounts for your customers or start migrating your customers over. If you are already running some live sites on the servelet, please schedule a time during off-peak hour to do this due to the downtime involved. When you have already sites and data running, the process will take longer.

Please see this article on why we recommend you do this.

To free up disk-space on the root-disk, you can also consider moving /usr/local/cpanel folder to the data-disk. However,  you would need to use bind mount instead of symbolic link for this. Based on our experience, the use of symbolic links might affect cPanel operations. For example, the cPanel update script can cause the symbolic link to break and affect cPanel operations. A cPanel engineer has also confirmed that the usage of symbolic links is not supported by cPanel.

You might also need to re-run /usr/local/cpanel/cpkeyclt if you see license file expired error message after the move.

You are also advised to install all CentOS patches and upgrade your cPanel to the latest release build before you create your first cPanel account or migrate your customers over.

Below are the complete steps on how to mount the data-disk as /home, and to move /usr/local/cpanel folder to the data-disk (optional), presuming that the data-disk is mounted as /data. Check first on which folder your data-disk is mounted, it might be mounted on a different directory, e.g. /home or /data1. Of course, if your data-disk is already mounted as /home, there's no need to move the contents of the /home folder anymore.

1. Firstly, ensure that you have your data-disk mounted as /data, which is the default settings. If the data-disk is not mounted yet, please mount it as /data. If the data-disk is mounted as different folder name, then adjust below commands accordingly. Use df to verify:

Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_sccentos6464b14-lv_root
                      7.5G  3.3G  3.9G  47% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/vda1             485M  135M  325M  30% /boot
/dev/vdb1              89G  185M   84G   1% /data

The data-disk device is (normally) /dev/vdb1 and based on df result above, you can see that it's mounted as /data, which is the default.

2. Stop cPanel service and all related services:

On CentOS 7:

systemctl stop tailwatchd
systemctl stop cpanel
systemctl stop httpd
systemctl stop exim
systemctl stop dovecot
systemctl stop mysql

On older CentOS 6:

service tailwatchd stop
service cpanel stop
service httpd stop
service exim stop
service dovecot stop
service mysql stop

3. Move the contents of the /home folder to the data-disk (on this example, presuming that the data-disk is mounted as /data)

cd /home (go to /home folder)
mv * /data (move all files under /home to /data folder, this will take some time especially if you already have sites running)
mv .cp* /data (move all the hidden files which starts with .cp under /home to /data folder)
cd / (go to root folder)
umount /data (un-mount the /data folder)

At this stage, the data-disk is not mounted. You can then use your favourite text editor (e.g. nano or vi) to edit the /etc/fstab file to change the mount point for the data-disk from /data to /home:

nano /etc/fstab

or

vi /etc/fstab

On the last line of /etc/fstab, you will see something like this:

UUID=b17605c2-5939-4590-9261-4db4e23e30b8 /data ext4 defaults 1 2

Change "data" to "home" so it will become like this:

UUID=b17605c2-5939-4590-9261-4db4e23e30b8 /home ext4 defaults 1 2

Save the file, and then mount back the data-disk by keying in this command (which will mount all un-mounted partition based on /etc/fstab):

mount -a

Use df to verify that the data-disk is now mounted as /home.

Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_sccentos6464b14-lv_root
                      7.5G  3.3G  3.9G  47% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/vda1             485M  135M  325M  30% /boot
/dev/vdb1              89G  185M   84G   1% /home

Go to your /home folder and verify that you can see all the files and folders you moved earlier (including the hidden .cp* files).

4. Move /usr/local/cpanel folder to /home/local/cpanel (optional, if you need more free space on the root-disk). This is presuming that the data-disk has been mounted as /home as a result of step (3) above:

mkdir /home/local (create /home/local folder)
cd /usr/local (go to /usr/local folder)
mv cpanel /home/local (move the cpanel folder under /usr/local to /home/local)

If you get some error messages stating that some of the logs file cannot be moved, like below:

===
mv: cannot remove ‘cpanel/logs/error_log’: Operation not permitted
mv: cannot remove ‘cpanel/logs/spamd_error_log’: Operation not permitted
mv: cannot remove ‘cpanel/logs/dnsadmin_log’: Operation not permitted
mv: cannot remove ‘cpanel/logs/tailwatchd_log’: Operation not permitted
mv: cannot remove ‘cpanel/logs/queueprocd.log’: Operation not permitted
mv: cannot remove ‘cpanel/logs/stats_log’: Operation not permitted
mv: cannot remove ‘cpanel/logs/cpdavd_error_log’: Operation not permitted
===

Just move the old cpanel folder to cpanel.bak:

mv cpanel cpanel.bak

5. Create a new /usr/local/cpanel folder and bind mount it to /home/local/cpanel folder:

mkdir cpanel (create an empty cpanel folder)
mount --bind /home/local/cpanel cpanel (create bind mount for /usr/local/cpanel --> /home/local/cpanel)

6. Lastly, add a line on /etc/fstab to add the bind mount entry, so it will be mounted when the servelet is restarted

vi /etc/fstab

Add this line at the end of the file:

===
/home/local/cpanel /usr/local/cpanel none rw,bind 0 0
===

7. Start cPanel service and all its related services:

On CentOS 7:

systemctl start tailwatchd
systemctl start cpanel
systemctl start httpd
systemctl start exim
systemctl start dovecot
systemctl start mysql

On older CentOS 6:

service tailwatchd start
service cpanel start
service httpd start
service exim start
service dovecot start
service mysql start

That's it! :)

Was this article helpful?
Dislike0 Like0
Views: 7592