Extending cPanel Home Directory across different partitions
SCENARIO 1:
Mounting the new SAN as an additional partition to house the cPanel Accounts YET to be created in the server
The best practice is to keep the disk usage of the primary partition “/” below 85%. This would ensure smooth functioning of the services hosted in the server along with optimum resource usage.
By default the primary cPanel partition created in the server will be called as /home. So let's say we are going to call our new SAN as /home1 [/dev/vdc device] and it will be used to house new cPanel accounts. The steps included in achieving this are as follows:
I. RUN lsblk and blkid
Sample Output
[email protected] [/]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 30G 0 disk
vdc 252:32 0 50G 0 disk >> this is the SAN we have to mount
[email protected] [/]# blkid
/dev/vda1: UUID="1fcf2679-aa67-4ced-bb9d-f55d7cbbaa93" TYPE="xfs"
/dev/vdc: UUID="1fcf564-jh97-3cea-aa9d-f34d8cbbab21"
II. now run mkfs.ext4 /dev/vdc
Create a file system for the new device
III. e2label /dev/vdc home1
So “e2label” labels the drive with an easy to use name
IV. mkdir /home1
Create a physical directory called /home1 to store the accounts
V. mount /dev/vdc /home1
Mount the device to the directory we just created
VI. Lastly we add it into /etc/fstab so the new SAN is persistent across reboots
UUID=1fcf564-jh97-3cea-aa9d-f34d8cbbab21 /dev/vdc ext4 defaults,noatime,nodiratime,errors=remount-ro 0 1
LABEL=home1 /home1 ext4 defaults 0 0
VII. Once this is done please run the below command to check whether the entry in /etc/fstab is correct by mounting the device:
mount -a
Now the SAN is mounted and this can be verified by running the df -h command.
VIII. The last step is to tell cPanel that henceforth /home1 is the partition to be used for cPanel accounts to be created . This can be done from WHM » Home » Server Configuration » Basic WebHost Manager Setup.
Using this method cPanel accounts will reside both in /home and /home1 partitions.
SCENARIO 2:
Mounting the new SAN to house all the cPanel Accounts together.
So we are going to call our new SAN as /home [/dev/vdc device] and it will be used to house all the cPanel accounts together. The steps included in achieving this are as follows:
I. RUN lsblk and blkid
Sample Output
[email protected] [/]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 30G 0 disk
vdc 252:32 0 50G 0 disk >> this is the SAN we have to mount
[email protected] [/]# blkid
/dev/vda1: UUID="1fcf2679-aa67-4ced-bb9d-f55d7cbbaa93" TYPE="xfs"
/dev/vdc: UUID="1fcf564-jh97-3cea-aa9d-f34d8cbbab21"
II. now run mkfs.ext4 /dev/vdc
Create a file system for the new device
III. mv /home /home_temp/
Rename the existing home directory to home_temp
IV. e2label /dev/vdc home
So “e2label” labels the drive with an easy to use name
V. mkdir /home
Create a physical directory called /home1 to store the accounts
VI. mount /dev/vdc /home
Mount the device to the directory we just created
VII. Lastly we add it into /etc/fstab so the new SAN is persistent across reboots
UUID=1fcf564-jh97-3cea-aa9d-f34d8cbbab21 /dev/vdc ext4 defaults,noatime,nodiratime,errors=remount-ro 0 1
LABEL=home /home ext4 defaults 0 0
VIII. Once this is done please run the below command to check whether the entry in /etc/fstab is correct by mounting the device:
mount -a
Now the SAN is mounted and this can be verified by running the df -h command.
IX. Now, we need to copy the contents from home_temp to home
cd /home_temp
cp -a * /home
Once this is done, reboot the server and remove the home_temp directory.