How To Increase size of /var/tmp and /tmp in CentOS

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. You can download the file using WinSCP, edit it and then upload it to the server.

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

Depending on your server configuration, the commands may take some time to execute properly. When you are done, restart the server.

restart

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

df -h

tmp-partition

Hope this solves your problem.

Get Updates In Your Inbox

Get the WordPress Tips and latst Internet Marketing ideas delivered directly to your email inbox, plus access to our FREE Pro Blogging Model blogging guide.

You need to confirm your email once. Don't worry, we hate SPAMs as much as you do

Comments

  1. Phoenix says

    Did this. But this still created /tmp folder that is still 600MB. Any ideas why? How can I create a MUCH larger /tmp folder? 

  2. says

    Thanks for explaining how to increase the size of the tmp partition and pointing out the scheduled backup being the cause. I also get this error occasionally and didn’t really why it was happening or what to do about it exactly.

    -Jean

Speak Your Mind

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

You may use these HTML Tags and Attributes

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>