Informational Website publish

Blog

News about our company, tutorials about IT and much more you will find in this page.

How to Fix /dev/loop0 (/var/tmp) is Full

Janeiro 30th, 2018

In this short tutorial we will learn how to resize the /tmp partition to 2GB or 4GB and how to setup a cron to clean this partition regularly to avoid situations where this folder fills up and the partition has no more free inodes left, causing massive I/O utilization, lagging the whole server.

Increase /tmp Partition Size

Many servers have only 500MB for /tmp which isn’t large enough and should be around 2GB instead. For this you will edit /scripts/securetmp:

  • vi /scripts/securetmp
Now you will search for the following line:
my $tmpdsksize = 512000; # Must be larger than 250000

Now substitute that line for this if you want a 2GB /tmp partition:
my $tmpdsksize = 2097152; # Must be larger than 250000

or to this line for 4GB of space:
my $tmpdsksize = 4194304; # Must be larger than 250000

Save the changes made to the file and run the following commands:

  • umount -l /tmp
  • umount -l /var/tmp
  • rm -fv /usr/tmpDSK
  • /scripts/securetmp

If asked about mounting the partition at server start-up and mounting it now, answer yes to both questions.

Install / Use Script tempwatch

Now we will periodically clear /tmp with the help from a script called tmpwatch.

First we will install it via yum:

  • yum install tmpwatch

To setup the script run crontab -e (or edit /var/spool/cron/root) with the following type of entry:

  • crontab -e
0 * * * * /usr/sbin/tmpwatch --mtime --all 24 /tmp

This will then run tmpwatch at the beginning of each hour and clear any files that haven’t been accessed for 24 hours. If you want to drop the hours to less than 24, you can always change it to 1 hour. It will not let you change it lower than an hour.