How to Manually Move a cPanel Account to Another Partition

How to Manually Move a cPanel Account to Another Partition

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?

  1. The WHM rearrange fails due to insufficient space on the source partition.
  2. You need to move an account to a partition with more available space.
  3. You want to redistribute accounts across partitions to improve server performance.

Before you begin

  1. SSH access to the server with root privileges.
  2. Verify that the destination partition has enough space to host the entire account. You can check with df -h.
  3. 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:
  1. Website: Open the user's site in a browser and confirm it loads without errors.
  2. Email: Send and receive a test email from the user's account.
  3. FTP: Connect via FTP with the user's credentials and verify that the home directory points to the new partition.
  4. cPanel: Log in to cPanel with the user's account and check the File Manager to confirm files are visible.
  5. Home path: Verify that the path is pointing to the new partition:
grep USERNAME /etc/passwd
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:
  1. Delete the user directory on the source partition:
rm -rf /homeSource/USERNAME

  1. Create the symbolic link:
ln -s /homeDest/USERNAME /homeSource/USERNAME

  1. 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:
  1. USERNAME — cPanel account name.
  2. homeSource — Current partition name (example: home, home2).
  3. homeDest — Destination partition name (example: home3, home4).

Recommendations

  1. Perform this procedure during low-traffic hours to minimize impact on the user.
  2. Always use screen to prevent an SSH disconnection from interrupting the process midway.
  3. Do not delete the source data until you have fully verified that the website, email, and FTP are working correctly on the new partition.
  4. 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.
  5. After completing the process, verify the freed space on the source partition with df -h.

    • Related Articles

    • How to Install cPanel on Your Server or VPS: Updated Guide by Distribution

      cPanel & WHM is the most widely used control panel in the web hosting industry. If you have a dedicated server or VPS with Webzi (or any other provider), this guide shows you how to install cPanel from scratch on the currently supported operating ...
    • How to install and configure Nginx as a reverse proxy in cPanel/WHM 🚀

      What is Nginx and why use it with cPanel? Nginx is a high-performance web server that can function as a reverse proxy in front of Apache on cPanel servers. This configuration allows Nginx to handle static files (images, CSS, JavaScript) while Apache ...
    • Emails don't appear in webmail searches

      When you search for an email in Roundcube (cPanel) and it doesn't appear in the results even though it exists in your mailbox, the problem almost always stems from the server not having properly indexed the messages. For example, if you try to locate ...
    • Fix MySQL Stored Procedures Import Error in cPanel

      When working with MySQL databases that include stored procedures, it's common to encounter errors during import in shared hosting environments with cPanel. These errors are usually related to the DEFINER parameter, which specifies the owner of the ...
    • How to List All CronJobs for Every cPanel User

      Cron jobs are scheduled tasks that run automatically on the server at specific times. These tasks can include updates, backups, sending scheduled emails, among others. Knowing the active cron jobs for each user gives you a clear view of the automated ...