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/zbLxFquF’ (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 usage and does not have enough space to more temp files, or, even if your /tmp partition is almost empty, the file trying to being 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 afterwards, 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, where as an 80GB server might get 4096MB of /tmp.
First, view the current parition 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
0
2
.9G
0
% /dev
tmpfs
3
.0G
0
3
.0G
0
% /dev/shm
tmpfs
3
.0G 49M
2
.9G
2
% /run
tmpfs
3
.0G
0
3
.0G
0
% /sys/fs/cgroup
/dev/loop0 516M 45M 445M
10
% /tmp
tmpfs 597M
0
597M
0
% /run/user/
0
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
cp -rfp /tmp /tmp_backup
umount /tmp
rm -rf /usr/tmpDSK
vi /scripts/securetmp
my $tmpdsksize =
512000
; # Must be larger than
250000
/scripts/securetmp
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
0
2
.9G
0
% /dev
tmpfs
3
.0G
0
3
.0G
0
% /dev/shm
tmpfs
3
.0G 49M
2
.9G
2
% /run
tmpfs
3
.0G
0
3
.0G
0
% /sys/fs/cgroup
/dev/loop0 516M 45M 445M
10
% /var/tmp
tmpfs 597M
0
597M
0
% /run/user/
0
/dev/loop1
1
.9G
3
.3M
1
.8G
1
% /tmp
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
rm -rf /tmp_backup/