In this tutorial, we will go over how to increase the /tmp directory for cPanel/WHM based servers.

First and foremost, you will need root SSH access to your server. Once connected to your server via SSH, check how /tmp is configured and it’s size by running the “df -h” command:

root@ip:/home# df -h
Filesystem Size Used Avail Use% Mounted on…
/dev/loop5 991M 1.4M 939M 1% /tmp

In this example, /tmp is approximately 1GB in size.

Step 1:

The most critical services which use /tmp for storing temporary files are Webserver, MySQL and cPanel service. Files can be removed under this except the MySQL socket file.

So, we need disable monitoring these services using the commands mentioned below:

To disable monitoring the service. This is essential as if we stop the service only, the monitoring service will start it automatically if it detects that the service got stopped.

whmapi1 configureservice service=cpsrvd enabled=1 monitored=0
whmapi1 configureservice service=mysql enabled=1 monitored=0
whmapi1 configureservice service=httpd enabled=1 monitored=0

Step 2:

We are increasing the size of /tmp from 1GB to 10GB. To increase the size of /tmp, edit the file /scripts/securetmp by running the below command:

nano /scripts/securetmp

a. Change value to “10485760” in

my $tmpdsksize = 10485760

b. Comment these lines in the file /scripts/securetmp

my $five_percent_of_available = ( $available * 0.05 );
if ( $five_percent_of_available > $tmpdsksize ) {
$tmpdsksize = $five_percent_of_available;
}
my $FOUR_GIG_k = ( 1024 * 1024 * 4 );
if ( $tmpdsksize > $FOUR_GIG_k ) {
$tmpdsksize = $FOUR_GIG_k;
}

Step 3:

Stop the critical services such Webserver, MySQL and cPanel service.

/scripts/restartsrv_cpsrvd –stop
/scripts/restartsrv_mysql –stop
/scripts/restartsrv_httpd –stop

Step 4:

Unmount /tmp and /usr/tmp

root@ip:~# umount -l /tmp
root@ip:~# umount -l /var/tmp

Now, you need to mount it elsewhere to preserve the data.

root@ip:~# mv /usr/tmpDSK /usr/tmpDSK_bak

Step 5:

Now run the command below so that /tmp becomes 10GB.

root@ip:~# /scripts/securetmp
root@ip:~# df -h
Filesystem Size Used Avail Use% Mounted on
…..
/dev/loop6 9.8G 23M 9.3G 1% /tmp

Now you can see that the /tmp space has increased to 10GB.

Server Hosting Solutions by RackNerd:

Shared Hosting
cPanel Web Hosting in US, Europe, and Asia datacenters
Logo
Reseller Hosting
Create your new income stream today with a reseller account
Logo
VPS (Virtual Private Server)
Fast and Affordable VPS services - Instantly Deployed
Logo
Dedicated Servers
Bare-metal servers, ideal for the performance-demanding use case.
Logo

Leave a comment

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