Drive Critical: /dev/loop0 (/var/tmp) is 97% full

bhanuprasad1981

Well-Known Member
Aug 5, 2008
222
0
66
India
i get 2-3 mails from server evry day , i cant be online whole day , when ever i check temp after watching this mail its back to normal 3-4% of 2gb allotted , i am really confused what may be eating so much temp and just disappear ?
 

Cindu

Well-Known Member
Feb 7, 2011
46
0
56
Hello,

As the tmp is clearing automatically you need to check whether there is any cron set to clear the /tmp partition of the server.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
Hello,

What size is your /tmp partition? You can resize it if it isn't large enough. Many servers have only 500MB for /tmp which isn't large enough and should be around 2GB instead. You could edit /scripts/securetmp for this line:

Code:
my $tmpdsksize     = 512000;    # Must be larger than 250000
Change to this line for 2GB:

Code:
my $tmpdsksize     = 2097152;    # Must be larger than 250000
Save the file :)wq), then run these commands to resize /tmp partition:

Code:
umount -l /tmp
umount -l /var/tmp
rm -fv /usr/tmpDSK
/scripts/securetmp
Unfortunately, if you aren't able to catch it when it has the high usage, it's difficult for us to state why it's alerting. It could be high session activity (those sessions do clear on their own) for some site during the times it hits the high disk space level. It could be MySQL having the temporary MyISAM tables filling it up. It could be EAccelerator writing files to it (if you use that, it writes some temporary files there). There are many reasons it could be happening. If you aren't certain, you can simply resize it to be larger. Otherwise, you'll have to watch it closely until you do catch it and then provide the details on what you are seeing.

There are also some scripts that will periodically clear tmp such as tmpwatch, but you need to be careful not to cron clear /tmp as EasyApache writes to /tmp during build, so you cannot simply clear files every 15 minutes or something, since you'll then break EasyApache from recompiling properly.

Thanks.
 
  • Like
Reactions: Arash Mehmandoost

bhanuprasad1981

Well-Known Member
Aug 5, 2008
222
0
66
India
hello /tmp is already 2gb in size, i don't use eaccelerator, i barely run easyapache, how to install / use the script tempwatch ?
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
You can do:

Code:
yum install tmpwatch
This will install that command, then put into crontab -e (or editing /var/spool/cron/root) the following type of entry:

Code:
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.

Can you do me a favor and check your /var/lib/mysql/hostname.err log to see if you find any errors like this in it (where hostname is the hostname of the server)?

Code:
Incorrect key file for table '/tmp/#sql_4108_0.MYI'; try to repair it
The sql_4108_0.MYI part might vary, so the main thing I'm looking for is the "Incorrect key file" entry. You could grep for it even:

Code:
grep "Incorrect key" /var/lib/mysql/hostname.err
If you do find that in your error log for MySQL, then it is MySQL causing this and you'll want to move the tmp directory for MySQL, which I could explain how to do once I know if that's the case.
 

bhanuprasad1981

Well-Known Member
Aug 5, 2008
222
0
66
India
hello error had gone for quite sometime, but back again and yes it was mysql causing this , how can i move mysql tmp directory ?
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
You can use the following steps to move the MySQL /tmp directory location:

1. Edit /etc/my.cnf file to set new tmpdir for MySQL

Code:
vi /etc/my.cnf
Place the following line into the file under the [mysqld] section:

Code:
tmpdir=/mysqltmp
Save the file with :wq

2. Create the /mysqltmp directory

Code:
mkdir /mysqltmp
chmod 1777 /mysqltmp
3. Restart MySQL and check that the tmpdir is now /mysqltmp

Code:
/etc/init.d/mysql restart
mysqladmin var | grep tmpdir
You should see the following return:

Code:
# mysqladmin var | grep tmpdir
| slave_load_tmpdir                       | /mysqltmp
| tmpdir                                  | /mysqltmp
This presumes / partition itself has sufficient space. I would like to hope / partition would have more space than /tmp was provided on most systems.
 

Hedloff

Well-Known Member
Jun 7, 2004
189
13
168
Up north!
cPanel Access Level
DataCenter Provider
Why does this error appear:
100416 12:49:20 [ERROR] /usr/sbin/mysqld: Incorrect key file for table './username_nyjoomla/smf_log_activity.MYI'; try to repair it ?

Why don't cPanel automatically repair this database?
Is it smart to check the /var/lib/mysql/hostname.err for such errors weekly and manually repair the databases?
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
That error appears due to your /tmp partition being too small for MySQL to write the data for the temporary MyISAM tables, and cPanel cannot automatically repair that happening. You would be able to follow the steps I've noted in my last post to change the MySQL tmpdir to another location.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
Hello DomineauX,

We have a case opened internally (30506) to allow users to specify the size of /tmp rather than having to manually edit /scripts/securetmp or creating /usr/tmpDSK manually. If you wanted to create a feature request for this to be in Tweak Settings to have an option for the values, that would be akin to the existing case, but you are certainly welcome to open such a request to allow other customers to lend support for it. The feature request forum is at the following location:

Feature Requests for cPanel and WHM

Please post a link to the request here after creating it.

Thanks!
 

DomineauX

Well-Known Member
PartnerNOC
Apr 12, 2003
429
11
168
Houston, TX
cPanel Access Level
Root Administrator
Thanks Tristan. I'll be more than happy with the ability to specify how large to make /tmp during /scripts/upcp execution so won't worry about a new feature request to add it as a Tweak Settings option.
 

ikillbill

Well-Known Member
Feb 18, 2008
119
0
66
Hi

could we move this to /home too?


You can use the following steps to move the MySQL /tmp directory location:

1. Edit /etc/my.cnf file to set new tmpdir for MySQL

Code:
vi /etc/my.cnf
Place the following line into the file under the [mysqld] section:

Code:
tmpdir=/mysqltmp
Save the file with :wq

2. Create the /mysqltmp directory

Code:
mkdir /mysqltmp
chmod 1777 /mysqltmp
3. Restart MySQL and check that the tmpdir is now /mysqltmp

Code:
/etc/init.d/mysql restart
mysqladmin var | grep tmpdir
You should see the following return:

Code:
# mysqladmin var | grep tmpdir
| slave_load_tmpdir                       | /mysqltmp
| tmpdir                                  | /mysqltmp
This presumes / partition itself has sufficient space. I would like to hope / partition would have more space than /tmp was provided on most systems.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
Hello :)

Yes, you could create the new tmp directory underneath the /home directory.

EX:

Code:
tmpdir=/home/mysqltmp
Thank you.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
You would simply check where it is:

Code:
whereis tmpwatch
If you don't get a return showing a binary location such as /usr/sbin/tmpwatch, you'd install it using the previously noted command:

Code:
yum install tmpwatch
In fact, if you try to install it via yum and it is already installed, you'd get this return:

Code:
Package tmpwatch-* already installed and latest version
The * represents the version as the version that message would report would differ depending on the system.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
If you view the man page about tmpwatch at tmpwatch - Linux Command - Unix Command location, there are various flags for tmpwatch that you can use. Some include "--all" which would remove all file types, and some are "--nodirs" which doesn't remove directories unless they are empty.

I would highly suggest viewing the man page for any service installed and using the appropriate flags as needed.
 

ronald.prism

Member
Dec 26, 2011
5
0
51
cPanel Access Level
Website Owner
I tried the following commands after raising $tmpdsksize to 2G

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

and received this warning, even after doing a "modprobe loop"

*** Notice *** No loop module detected
If the loopback block device is built as a module, try running `modprobe loop` as root via ssh and running this script again.
If the loopback block device is built into the kernel itself, you can ignore this message.
*** Notice *** No working loopback device files found. Try running `modprobe loop` as root via ssh and running this script again.


Filesystem Size Used Avail Use% Mounted on
/dev/mapper/SysVolGroup-LogVolRoot
225G 76G 137G 36% /
/dev/sda1 244M 15M 216M 7% /boot
tmpfs 1.7G 0 1.7G 0% /dev/shm
/dev/sdb1 231G 87G 144G 38% /home4


shouldn't there be a mounted "/tmp" folder in there?



TIA