As your server grows or you have some rather large tasks, you might find the default size of your /tmp partition to be too small, which can result in various errors from your services, the most common 4 being cPanel, Apache, LiteSpeed, and MySQL.

For example:
[ERROR] mysqld: Can’t create/write to file ‘/tmp/ohUjKwaL’ (Errcode: 28 “No space left on device”)

This could be the result of 1 of 2 issues, your /tmp partition is filling up from lots of usages and does not have enough space to more temp files, or, even if your /tmp partition is almost empty, the file trying to be written could be larger than the current maximum size of your /tmp partition.

Another thing to keep in mind, the initial size of your /tmp partition depends on how much total disk space was available during your cPanel/WHM installation. If you add more disk space afterward, your /tmp partition does not automatically adjust and may need to be manually increased to scale up with the server. Eg a 20GB disk server might get 512MB of /tmp, whereas an 80GB server might get 4096MB of /tmp.

First, view the current partition sizes using the df command as seen below.

df -h

Filesystem Size Used Avail Use% Mounted on
/dev/vda1 30G 21G 10G 67% /
devtmpfs 2.9G 02.9G 0% /dev
tmpfs 3.0G 03.0G 0% /dev/shm
tmpfs 3.0G 49M 2.9G 2% /run
tmpfs 3.0G 03.0G 0% /sys/fsgroup
/dev/loop0 516M 45M 445M 10% /tmp
tmpfs 597M 0597M 0% /run/user/0

As we can see the “/tmp” partition is on a “/dev/loop0” device. This is a virtual device, which is a binary file stored at “/usr/tmpDSK”, which in this case is 512MB. This file is generated by the cPanel itself.

Before we continue, we need to stop the core services from writing to it. If our servers are running CentOS 5 or CentOS 6, we will need to use the “service” command. If you are running CentOS 7, so we will use the “systemctl” command.

CentOS 5 / CentOS 6
service httpd stop
service lsws stop
service mysql stop
service cpanel stop

CentOS 7
systemctl stop httpd
systemctl stop lsws
systemctl stop mysql
systemctl stop cpanel

Next, lets make a quick backup of the current /tmp partition, if you experience any unexpected issues, it’s always best practice to have a usable backup to restore from.

cp -rfp /tmp /tmp_backup

Now we will unmount the /tmp partition.
umount /tmp

Delete the binary file holing the virtual partition.
rm -rf /usr/tmpDSK

Edit the “/scripts/securetmp” file.
vi /scripts/securetmp

Look for the following line, and change it to the desired size. This example is 512MB, and we will be changing it to 2048MB.
my $tmpdsksize = 512000; # Must be larger than 250000

Now we must run the script to re-create the tmp partition with the new size we entered.

You may also get some “y/n” prompts along the way such as the 2 below, which you will want to select “yes” for.
Would you like to secure /tmp & /var/tmp at boot time? (y/n) y
Would you like to secure /tmp & /var/tmp now? (y/n) y

Next, let’s verify the /tmp partition is mounted and has the new expected size.
df -h

Filesystem Size Used Avail Use% Mounted on
/dev/vda1 30G 20G 11G 66% /
devtmpfs 2.9G 02.9G 0% /dev
tmpfs 3.0G 03.0G 0% /dev/shm
tmpfs 3.0G 49M 2.9G 2% /run
tmpfs 3.0G 03.0G 0% /sys/fs/cgroup
/dev/loop0 516M 45M 445M 10% /var/tmp
tmpfs 597M 0597M 0% /run/user/0
/dev/loop1 1.9G 3.3M 1.8G 1% /tmp

Turn on the core services again:

CentOS 5/CentOS 6
service httpd start
service lsws start
service mysql start
service cpanel start

CentOS 7
systemctl start httpd
systemctl start lsws
systemctl start mysql
systemctl start cpanel

If everything started up correctly and is working, delete the backup we made of the partition.
rm -rf /tmp_backup/