Resize /tmp Partition

Many of you might have come across situations where your /tmp gets filled very often either due to eaccelerator cache or due to session files or such temporary files. Cpanel by default creates /tmp with 512M size. You can always resize tmp to your choice. Here is the step by step details on how it can be done.

1) Stop mysql, apache and cpanel to prevent writing temporary files to /tmp.

/etc/init.d/chkservd stop
/etc/rc.d/init.d/mysql stop
/etc/rc.d/init.d/httpd stop
/etc/rc.d/init.d/cpanel stop

2) Unmount tmp partition.

umount /var/tmp
umount /tmp

Sometimes you will receive errors stating that the device is busy or /tmp cannot be unmounted. Then find out all processes using /tmp and kill them.

lsof /tmp

The above command will list the process ids currently using /tmp. Kill the pids as follows.

kill -9 pid

eg: kill -9 3766

3) The cpanel /scripts/securetmp is the one which maintains the tmp size. You can edit the following line in it to change the size.

my $tmpdsksize = 512000;

Suppose you want to raise the partition size to 2G, you can also do it as follows.

sed -i -e ‘s/512000/2048000/g’ /scripts/securetmp

The above will replace 512000 with 2048000 in the file /scripts/securetmp

4) Remove the temp disk

rm /usr/tmpDSK

5) Now, run the following to recreate tmp

/scripts/securetmp –auto

6) Now go to /tmp and set the mysql socket file.

cd /tmp
ln -s /var/lib/mysql/mysql.sock

7) Restart all services

/etc/rc.d/init.d/mysql start
/etc/rc.d/init.d/httpd start
/etc/rc.d/init.d/cpanel start
/etc/init.d/chkservd start

8) Now check your tmp size using the command df -h

Done !

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: