How to increase /tmp & /usr/tmpDSK size in Linux

Before you read it!
it’s maybe a good solution to use tmpwatch to auto clean /tmp directory, check this article
auto clean /tmp folder using tmpwatch

if the previous article didn’t help you, and you need to increase tmp folder size then follow these steps.

1- Connect to your server using SSH or WHM Terminal

2- Stop MySql service and kill the tailwatchd process.
run this command

/etc/init.d/mysqld stop

to kill all processes run this command to check out what is running behind the scenes!

pstree -p | grep tailwatchd

after knowing the running processes kill them using this command but don’t forget to change process ID

kill -9 2522

3- Take a backup of /tmp as /tmp.bak
to do that, run this command line

cp -prf /tmp /tmp.bak

4- Create a 6 GB file in the available free space

dd if=/dev/zero of=/usr/tmpDSK bs=1024k count=6048
du -sch /usr/tmpDSK

5- Assign ext3 filesystem to the file

mkfs -t ext3 /usr/tmpDSK

if this message appears to you, type y and click Enter on your keyboard
Proceed anyway? (y,n) y

6- Check the file system type

file /usr/tmpDSK

You may also use the following comands for making ext3 file system on a file.

mkfs.ext3 /usr/tmpDSK
mke2fs /usr/tmpDSK

7- Unmount /tmp partition

umount /tmp

8- Mount the new /tmp filesystem with noexec

mount -o loop,noexec,nosuid,rw /usr/tmpDSK /tmp

9- Set the correct permission for /tmp

install -d –mode=1777 /tmp
ls -ld /tmp

or use this simple command as root

chmod 1777 /tmp

10- Check if the /tmp size is updated!

df -h

this command should return something like this:
Filesystem Size Used Avail Use% Mounted on
/usr/tmpDSK 6.0G 68M 5.9G 4% /tmp

if you see the new size appear like the above example, then it’d DONE!

11- *optional* Restore the content of old /tmp.bkp directory

cp -rpf /tmp.bak/* /tmp

12- Restart MySQL and tailwathchd services

/etc/init.d/mysql start

/scripts/restartsrv_tailwatchd

13- Mount all filesystems

mount -a

after that check the filesystems again using df -h command.

Hope it’s working well with you!
if you have any questions post a comment.

Thanks

Share this article:

Leave a Reply

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