Ubuntu disk space issues with virtual files

Posted by on November 29, 2011 in Operating Systems, Ubuntu | 0 comments

I recently had an issue over Thanksgiving with a server running out of disk space. I was fairly perplexed because it had 30 gigs free on the primary drive. All of the data was stored on a separate disk, so the only thing that should have been creating files was the operating system.

It turns out the issue was with a php script that wasn’t finishing. It was just sitting there looping. Now on paper, the machine should have run out memory and crashed the script, but the looping wasn’t incrementing any data. It was just waiting 30 seconds then checking a directory to see if any files were in it, then waiting again.

The issue is that while it’s doing this, the disk space continually decreases, until you kill the process. After you kill it, the normal disk space available is there. While the script is running however, I looked for things that were taking up space. The issue with the hunt is that the normal command I run to find files that are taking up the most space, see my article Directory Sorting and File Size’s in Ubuntu, doesn’t find the virtual files.

Now I have researched the issue and everyone says that virtual files do not take up any “real” space. My objection to this argument is that the data has to be stored somewhere right? So why wouldn’t the virtual file take up real space. Ubuntu clearly thought that the virtual file was taking up real harddrive space because it wouldn’t allow a new file to be created on the drive when it was “virtually” filled. So I’m calling shananagins on that argument. Just because the files delete themselves when the process is done, doesn’t mean they don’t take up space on your harddrive.

So to fix the issue for me, I could simply rewrite the code so that it would end the loop sooner. However if you’re facing a runaway script that you don’t know how to fix, or you don’t know that it’s a script that’s causing the issue, there are some common places you should look for large files.

  • Any hard files and will show up in a “du” command search for file sizes.   Directory Sorting and File Size’s in Ubuntu
  • /proc – should tell you if it’s a script that’s causing the disk issue.  /proc is supposed to be a copy of the system memory that when you access it it accesses the memory, not physical drives, so there shouldn’t really be an issue with this directory, but check it anyways.
  • /var/log
  • /var/lib
  • Any output file from crontab processes.  You set the output path, so check your crontab and see where the output files are writing to.
  • /tmp
  • /var/tmp
  • /var/cache
  • /home – any users that are allowed to upload files may take up more space than you realize.
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Comment

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

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