Increase size of /tmp folder on CentOS under Cpanel

Any ded­i­cated server host­ing some web­sites that get mean­ing­ful traf­fic will quickly ­grow Cpanel’s default /tmp folder size of 512MB. It houses PHP ses­sion files, tem­po­rary file uploads, your data­base tem­po­rary files, your web server’s cache includ­ing the one from caches such as APC or eAc­cel­er­a­tor, and other such stuff.

With the tmp par­ti­tion full, the server will expe­ri­ence many ran­dom issues such as server crashes. Your sites will quickly go down and leave you head-scratching.

For­tu­nately, it’s quite easy to resize the /tmp par­ti­tion on cPanel servers — espe­cially if it is the default one cre­ated by cPanel installs. There’s a handy script at /scripts/securetmp.

Open this file:

pico /scripts/securetmp

And find this line:

my $tmpdsksize = 512000; # Must be larger than 250000 Change it to a larger num­ber than 512 MB.

Say you want it to be 2 GB:

my $tmpdsksize = 2097152; # 2GB for the /tmp folder

Now close and save the file.

We need to stop all ser­vices that may be using this folder.

Now we will sim­ply unmount the /tmp folder and recre­ate it. Here’s the sequence of com­mands to cre­ate it:

lsof /tmp
umount -l /tmp
umount -l /var/tmp
rm -fv /usr/tmpDSK


You can ver­ify the size of the /tmp folder among others:

df -h

This should show you some­thing like this:

/usr/tmpDSK ext3 2.0G 996M 1.1G 51% /tmp

NOTE: If you have any problems, for instance, the size of the recre­ated /tmp folder is not really 2GB despite that code in the /scripts/securetmp we changed, it may be because of some set­tings you have in the /etc/fstab file. Take a look at it and com­ment out any lines that inter­fere with the LABEL for /tmp mount.



Loading Likes...
Kazi S: XeonBD, Suite 2A, House 231, Road 06, Mohammadi Housing Limited, Mohammadpur, Dhaka 1207, Bangladesh Web: http://www.xeonbd.com | Blog: https://blog.xeonbd.com | Telephone: +88-02-8101735 | Fax: +88-02-8101736 Sales HotLine: +88 019 77XEONBD (936623)
Related Post
Leave a Comment

In order to give you the best experience, our website uses cookies.