cPanel includes a native feature called rearrange that allows moving accounts between partitions from WHM. However, this process requires enough free space on the source partition to create a temporary copy, and when the partition is nearly full, the rearrange fails without completing.
In this article, you will learn how to manually move a cPanel account to another partition without relying on the native rearrange. This procedure uses rsync for file synchronization and sed to update paths in configuration files.
When is this procedure necessary?
- The WHM rearrange fails due to insufficient space on the source partition.
- You need to move an account to a partition with more available space.
- You want to redistribute accounts across partitions to improve server performance.
Before you begin
- SSH access to the server with root privileges.
- Verify that the destination partition has enough space to host the entire account. You can check with
df -h. - Identify and note the following values you will use throughout the process:
USERNAME — cPanel account name
homeSource — Current partition (example: home)
homeDest — Destination partition (example: home2)
Important: MySQL/MariaDB databases are not affected by this process as they reside in /var/lib/mysql, not in /home. There is no need to migrate them.
Phase 1: Preparation
Create a screen session so the process is not interrupted if you lose your SSH connection:
screen -S move_USERNAME
If your connection drops, you can reattach to the session with:
screen -r move_USERNAME
Phase 2: Initial synchronization
Run the first rsync to copy all account files to the destination partition. This synchronization can be performed while the account is still active, as it is not the final cutover:
rsync -avhzo /homeSource/USERNAME/ /homeDest/USERNAME
If the account is large and you want to receive an email notification when it finishes:
rsync -avhzo /homeSource/USERNAME/ /homeDest/USERNAME && echo "Initial sync completed" | mail -s "rsync USERNAME finished" your@email.com
Note: Pay attention to the trailing slash (/) after USERNAME/ on the source. This tells rsync to copy the contents of the directory, not the directory itself.
Phase 3: Final sync with consistency
Once the initial synchronization is complete, run a second rsync with the --delete option to ensure the destination copy is an exact replica. This will remove any files from the destination that were deleted from the source during the first sync:
rsync -avhzo --delete /homeSource/USERNAME/ /homeDest/USERNAME
This second rsync will be much faster as it will only transfer files that have changed since the first synchronization.
Phase 4: Update configuration
Update userdata and ProFTPD
Modify the partition paths in cPanel and ProFTPD configuration files:
sed -i 's/homeSource/homeDest/g' /var/cpanel/userdata/USERNAME/*
sed -i 's/homeSource/homeDest/g' /etc/proftpd/USERNAME
Update /etc/passwd
Modify the user's home directory path in the system password file:
nano /etc/passwd
Find the line containing your USERNAME and change /homeSource/USERNAME to /homeDest/USERNAME. Do not modify any other data on the line.
Update email passwords and restart services
Update the paths in email password files, rebuild the Apache configuration, restart affected services, and update CageFS (only if using CloudLinux):
sed -i 's/homeSource/homeDest/g' /homeDest/USERNAME/etc/*/passwd
/scripts/rebuildhttpdconf
service httpd restart
service pure-ftpd restart
/scripts/updateuserdatacache
cagefsctl -m USERNAME
Note: If your server does not use CloudLinux, skip the last command (cagefsctl).
Phase 5: Verification
Before deleting the source data, verify that everything works correctly:
- Website: Open the user's site in a browser and confirm it loads without errors.
- Email: Send and receive a test email from the user's account.
- FTP: Connect via FTP with the user's credentials and verify that the home directory points to the new partition.
- cPanel: Log in to cPanel with the user's account and check the File Manager to confirm files are visible.
- Home path: Verify that the path is pointing to the new partition:
grep USERNAME /etc/passwd
Phase 6: Cleanup and symlink
Once you have confirmed that everything works correctly, delete the old data from the source partition and create a symbolic link to maintain compatibility with any old references to the original path:
- Delete the user directory on the source partition:
rm -rf /homeSource/USERNAME
- Create the symbolic link:
ln -s /homeDest/USERNAME /homeSource/USERNAME
- Verify the symlink was created correctly:
ls -la /homeSource/ | grep USERNAME
You should see something similar to:
USERNAME -> /homeDest/USERNAME
Quick variable reference
Throughout the entire process, you only need to replace the following three variables. Do not modify any other data:
USERNAME — cPanel account name.homeSource — Current partition name (example: home, home2).homeDest — Destination partition name (example: home3, home4).
Recommendations
- Perform this procedure during low-traffic hours to minimize impact on the user.
- Always use
screen to prevent an SSH disconnection from interrupting the process midway. - Do not delete the source data until you have fully verified that the website, email, and FTP are working correctly on the new partition.
- If moving multiple accounts, repeat the process one at a time. Do not attempt to move several accounts simultaneously, as this could overload the server.
- After completing the process, verify the freed space on the source partition with
df -h.