Sunday, August 26, 2012

cPanel/WHM Server. /var is 100% full

I know with a couple of my older installs and some datacenter custom installs. /var is put onto its own partition. Often this partition is not big enough and you sometimes find your logs fulling up the partition to 100% disk space. In /var are the logs, mysql databases and queued email.

What I found out that filled my /var partition so much where the mysql databases. Get enough clients on a cPanel/WHM server and that partition is quickly filled up.

The quickest and easiest way to do this is to move those mysql databases to a partition with lots of spare disk space  This is normally found in /home. To do this you can type out the following commands

1) First we stop mysql:

# /etc/init.d/mysql stop

2) Now we create the directory we are going to be moving the databases to:
# mkdir /home/var_mysql

3) Now its time to move the databases to the directory you just created:
# mv /var/lib/mysql /home/var_mysql

4) After the databases have finished copying, we need to make sure mysql has permission to access the files we just moved:
# chown -R mysql:mysql /home/var_mysql/mysql

5) Once the permissions are correct we need to make a symbolic link that links everything to the new file location:
# ln -s /home/var_mysql/mysql /var/lib/mysql

6) Thats about it. The only thing left to do now is startup mysql
# /etc/init.d/mysql start

Everything should be working now and you should have a lot of spare space on your /var partition.


  1. Recommend you adjust your article to include the critical step of turning off service monitoring for MySQL or it gets restarted in the midst of the database move which in turn corrupts everything.

    If that's too late then this can help in shell:
    mysqlcheck --repair --all-databases

    Lesson learned but passing it on for anyone else who doesn't realise this article is not a good reference!

    1. Bro, Have any change to recover this error? bcz, i did by above method, now I got error in establishing..

  2. After doing with these step we got error of Error establishing a database connection

  3. F***king page.! Don't follow this fellow pages... If you did you will face loss everything...