How to increase /tmp partition size on a non-control panel server

Stop Apache and MySQL services.

# /etc/init.d/httpd stop; /etc/init.d/mysql stop

Take a backup of /tmp

# cp -rp /tmp /tmp.bak

Create a partition of 2GB using the below command

# dd if=/dev/zero of=/usr/temp-disk bs=2M count=1024

Create the file system on it using the mke2fs command

# mke2fs -j /usr/temp-disk

Unmount the current /tmp partition

# umount /tmp

Mount the new /tmp filesystem using the below command

# mount -t ext3 -o rw,noexec,nosuid,loop /usr/temp-disk /tmp

Set the correct permission for /tmp

# chmod 1777 /tmp

To verify the partition, execute:

# mount

Restore the content of old /tmp.bkp directory

# cp -rp /tmp.bak/* /tmp

Start Apache and MySQL services.

# /etc/init.d/httpd start; /etc/init.d/mysql start

To make sure this partition is mounted automatically after every reboot, edit the /etc/fstab and replace /tmp entry line with the following one.

/usr/temp-disk /tmp ext3 rw,noexec,nosuid,loop 0 0

Increase /tmp partition size in cPanel and secure it

1. Stop cpanel, apache (or whatever webserver you are using), mysql services:

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

2. Umount /tmp and /var/tmp:

umount -l /tmp
umount -l /var/tmp

3. Move /usr/tmpDSK file to another location (just in case you’ll need to mount it somewhere else to preserve data):

mv /usr/tmpDSK /usr/tmpDSK_back

4. Modify /scripts/securetmp to set tmpdsksize to desired size:

vi /scripts/securetmp

$tmpdsksize = 2048000

5. Run:

/scripts/securetmp

6. Start cpanel, apache (webserver), mysql services:

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