How To Increase size of /var/tmp

I was frequently getting an error message that the /var/tmp directory in one of my cPanel CentOS 5.5 server is full and I need to delete some data. A cronjob is already there in crontab to cleanup the temporary data periodically, but I was still getting that error.

I looked at the error log and found that the tmp partition goes full when the scheduled backup runs. Therefore, I had nothing to do but increase the size of the tmp partition. After that, my server runs fine and no issues or error messages since then.

Here is How to increase the size of /var/tmp and /tmp partition

You need to have root access to your server. If not, you can’t increase the size of /tmp and /var/tmp partition directory, sorry.

Shutdown httpd and mysql using these commands

service httpd stop
service mysql stop

First, you need to edit the file securetmp in /usr/local/cpanel/scripts/ folder.

nano /usr/local/cpanel/scripts/securetmp

As default the size for tmp is 512 MB , just make it something that is convenient to you .

In /usr/local/cpanel/scripts/securetmp file, look for a line like this:

my $tmpdsksize = 512000; # Must be larger than 250000

and change it to

my $tmpdsksize = 2097152; # Must be larger than 250000

This will allow us to allot 2GB of space size for the tmp partition.
Now, you need to log in to SSH using root account to make the changes. Once you are in, run these commands one by one.

umount -l /tmp
umount -l /var/tmp
rm -fv /usr/tmpDSK
/usr/local/cpanel/scripts/securetmp

Then Restart the server :-

shutdown -r 0

Now when the server is fully restarted, you can check the partitions using the following command.

df -h

Leave a Reply

Your email address will not be published. Required fields are marked *