Fixing a cPanel Insufficient Disk Space Problem

So I logged into our company website's WHM portal the other day and noticed that the most recent cPanel update had failed due to insufficient disk space. Here was the message:

The last attempt to update cPanel & WHM was blocked.
 Please correct these issues and rerun updates.
 fatal: Cannot upgrade due to insufficient disk space. Detected 1.97GB. You will need at least 3GB to install/update to a new version of cPanel.

Sounds simple enough, right? However, a quick check of the server revealed that:

  • /usr had only been allocated 8GB
  • /usr was 76% full

A quick Google search turned up some tips for freeing up disk space in /usr (where cPanel lives). Searching for and deleting large log files only freed up about 500MB, still quite far from the 3GB we needed. Unable to move further, I contacted the technical support team of our hosting provider. They provided me with the syntax to find large files in Linux. Back to square one.

Luckily, Uplogix employs a team of highly talented developers who know Linux far better than I do. Since the server had so much space in /home (100GB free), they suggested simply moving /usr/local/cpanel to /home/cpanel.

What Didn’t Work

Our first attempt went like this:

  • shut down cpanel process
  • copy /usr/local/cpanel to /home/cpanel
  • mv /usr/local/cpanel to /usr/local/cpanel.bak
  • create a symlink from /usr/local/cpanel to /home/cpanel
  • start cpanel process

Unfortunately, we were greeted with 500 Internal Server errors when we tried to connect to cPanel and WHM. We guessed this was a permission problem.

What Did Work

It turned out that I was searching for the wrong terms, and after more Googling, found Moving cpanel location from /usr/local to home. User Eddie suggested we use a bind mount instead of a hard link.

mount --bind /home/cpanel/ /usr/local/cpanel/

Here were the steps:

  • shut down cpanel process
  • copy /usr/local/cpanel to /home/cpanel
  • move /usr/local/cpanel to /usr/local/cpanel.bak
  • make a new directory: /usr/local/cpanel
  • bind /usr/local/cpanel to /home/cpanel
  • start cpanel process

Even without deleting /usr/local/cpanel.bak, the cPanel update completed without issue.

PROBLEM: The mount command we ran won’t persist across a reboot.

SOLUTION: Add the mount command to /etc/fstab

root@upxwebserver [/usr/local]# cat /etc/fstab
# wasn't enough space in /usr/local for cpanel, so we had to move it to /home 
/home/cpanel /usr/local/cpanel none defaults,bind 0 0

We then rebooted the server and everything continued working fine.

Problem solved.

Thanks to Matt for steering me away from trying to resize the partitions on the server. Additional thanks to Jeremy for playing Clash of Clans on his phone when the going got tough.