No space left on device

14 Sep, 2007  |  Posted by Danesh  |  in Linux

The DBA I work with was reporting this error on the server she was working on. Every time she tried to add a new cron job the error would come up.

[oracle@###### - /db/home/oracle]
$ crontab -e
crontab: installing new crontab
cron/tmp.5821: No space left on device
crontab: edits left in /tmp/crontab.5821

From the error it’s quite obvious that it’s a space related issue. It’s not fun when you get woken up at 3am but anyway this is how I fixed the problem.

First I had to see what the space situation was on the server. Running “df -h” showed sufficient free space available on the server so apparently storage space was not the issue.

Next I ran “df -i” and the result painted a different picture instead, the server had hit the maximum inodes allowed for the “/var” partition. What are inodes?

Ok, so now I know the issue was in “/var”. There’s most likely a directory within “/var” with a whole bunch of files in it causing the problem.

Running “find /var -size -8k” would return me all files within “/var” smaller then 8k. What I found was a long list of unsent mails in the “/var/spool/mquee” directory. 261517 files to be exact.

How I got “261517″ ?

find /var/spool/mquee -size -8k | wc -l

The next step was to remove all these files. The “rm” command would not work because the amount files I was trying to delete would exceed the maximum argument count allowed for “rm”.

A different approach had to be taken. The command would search for files within “/var/spool/mquee” that were smaller then 8k and removed them 1 by 1.

find /var/spool/mqueue -size -8k -exec rm -f {} \;

The command ran for 30 minutes and fixed the problem and now I have a happy DBA again.

Have you faced familiar situations before? I would love to hear about them and how you fixed them.

  • Digg
  • del.icio.us
  • BlinkList
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Furl
  • Google
  • Live
  • Facebook
  • Pownce
  • TwitThis
  • E-mail this story to a friend!
Tags: ,

7 Responses so far | Have Your Say!

  1. aizatto  |  September 14th, 2007 at 10:55 pm #

    Should have just ran:
    ls | xargs rm

    aizatto - Gravatar
  2. Wing Loon  |  September 15th, 2007 at 12:01 am #

    Bro, you may try to run the command below: -

    cd /var/spool/mqueue
    for f in *; do rm -f $f; done

    This will delete all the files in the /var/spool/mqueue

    Hope this help, :)

    Wing Loon - Gravatar
  3. Danny  |  September 15th, 2007 at 3:34 am #

    Thanks man. That will work.

    Danny - Gravatar
  4. Danny  |  September 15th, 2007 at 3:41 am #

    thanks aizatto, worked like a charm :)

    Danny - Gravatar
  5. Wing Loon  |  September 16th, 2007 at 11:07 pm #

    aizatto, cool…it works great, :)

    Wing Loon - Gravatar
  6. Maski  |  May 6th, 2008 at 11:58 pm #

    The exact same thing just happen to me, well i just rm -Rf /var/spool/mqueue and then mkdir the same dir with the owner nad group and samba finally started!!!

    thanks

    Maski - Gravatar
  7. dragoncity99  |  June 30th, 2008 at 10:24 pm #

    For long term resolution if it occurs again:
    1. Put in a cronjob the commands to make it go again.

    Another way might be creating a ruleset in /etc/logrotate.conf to make the files get archived and compressed if the logs are still needed for reference.

    dragoncity99 - Gravatar

Leave a Feedback

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>