The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'General Discussion' started by bhanuprasad1981, Feb 9, 2011.

  1. bhanuprasad1981

    bhanuprasad1981 Well-Known Member

    Joined:
    Aug 5, 2008
    Messages:
    222
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    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 ?
     
  2. Cindu

    Cindu Well-Known Member

    Joined:
    Feb 7, 2011
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    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.
     
  3. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    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.
     
    Arash Mehmandoost likes this.
  4. bhanuprasad1981

    bhanuprasad1981 Well-Known Member

    Joined:
    Aug 5, 2008
    Messages:
    222
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    hello /tmp is already 2gb in size, i don't use eaccelerator, i barely run easyapache, how to install / use the script tempwatch ?
     
  5. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    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.
     
  6. bhanuprasad1981

    bhanuprasad1981 Well-Known Member

    Joined:
    Aug 5, 2008
    Messages:
    222
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    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 ?
     
  7. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    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.
     
  8. Hedloff

    Hedloff Well-Known Member

    Joined:
    Jun 7, 2004
    Messages:
    98
    Likes Received:
    2
    Trophy Points:
    8
    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?
     
  9. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    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.
     
  10. Hedloff

    Hedloff Well-Known Member

    Joined:
    Jun 7, 2004
    Messages:
    98
    Likes Received:
    2
    Trophy Points:
    8
    Thanks for the fast reply ;-)

    Ok, will try to either increase this on the old servers or change MySQL to another location.
     
  11. DomineauX

    DomineauX Well-Known Member
    PartnerNOC

    Joined:
    Apr 12, 2003
    Messages:
    414
    Likes Received:
    4
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Sure would love to have the /scripts/securetmp default to a more reasonable size than 500mb or have an option under Tweak Settings to set a specific size like 2 or 4gb.
     
  12. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    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!
     
  13. DomineauX

    DomineauX Well-Known Member
    PartnerNOC

    Joined:
    Apr 12, 2003
    Messages:
    414
    Likes Received:
    4
    Trophy Points:
    18
    Location:
    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.
     
  14. ikillbill

    ikillbill Well-Known Member

    Joined:
    Feb 18, 2008
    Messages:
    119
    Likes Received:
    0
    Trophy Points:
    16
    Hi

    could we move this to /home too?


     
  15. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    650
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  16. ikillbill

    ikillbill Well-Known Member

    Joined:
    Feb 18, 2008
    Messages:
    119
    Likes Received:
    0
    Trophy Points:
    16
    How to check whether tmpwatch is installed or not?

    we use CentOS 5.7 + cpanel 11.30.5
     
  17. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    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.
     
  18. ikillbill

    ikillbill Well-Known Member

    Joined:
    Feb 18, 2008
    Messages:
    119
    Likes Received:
    0
    Trophy Points:
    16
    does tmpwatch clean all "folders" under /tmp too? or only files
     
  19. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    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.
     
  20. ronald.prism

    ronald.prism Member

    Joined:
    Dec 26, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    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
     
Loading...

Share This Page