Operating systems

Grappling with disk space

September 24, 2008, 02:30 PM — 

When you find yourself suddenly faced with a disk or file system that is 100% full or close to it, the first thing you generally want to do is alleviate the "out of space" condition. However, finding the source of the disk space crunch may take some time. Let's look at some handy commands for figuring out what you can do quickly to keep the system operational.

Strategies that might provde useful for finding the files that are causing the disk space crunch involve:

  • finding recently added and recently grown files
  • finding especially big files and directories
  • looking for large log files, especially older logs that may have been rolled over (e.g., messages.3) and can be easily deleted
  • compressing large files that are not currently in use (tar files, etc)

Both newly added files and those recently modified will have a recent mtime (modification time) stamp. If you track down this type of file, you might be able to figure out why disk space has been used up recently.

# cd /filesystem
# find . -mtime -1 -ls

This command will tell you what files have been added or changed in the previous 24 hours. With the -ls option instead of the more common -print, it gives you a long listing so that you can see the file size and owner. This command might point you at some newly created directories that look benign enough, but a quick
"du -sk" of their contents might show that they are a significant contributor to your disk space woes.

20416175  1 drwxr-xr-x   7 jdoe   users    512 Sep 24 09:36 planning/PSQL_Data
22710997  1 drwxr-xr-x   4 jdoe   users    512 Sep 24 09:36 planning/PSQL_Data/fy2009

If you check for new files periodically, you might like the -newer argument which you can use to find all files that are newer than a reference file. For example, the command below will find all files that have been created or modified since the timestamp file was last changed.

# find . -newer /opt/appl/timestamp

You can also look for especially large files by providing a file size as an argument.

# find . -size +1000000 -ls
76435     0 --rw-r--r--   1 datahog  users 19493236306 Sep 24 13:42 biglog

Prints files with more than 1,000,000 blocks. The same command with +1000c would look for files with 1,000,000 or more characters (i.e., much smaller).

You can look for directories and get a rough idea of how many files they contain by using the -type d argument. Directories that contain relatively few files will have only used one 512 byte block to store their contents, like these:

Sign up for ITworld's Daily newsletter
Follow ITworld on Twitter @IT_world

I like it!
Comments

I was pretty upset today to

I was pretty upset today to get an email from IT World, "Unix in the Enterprise" with the subject line "Sun Solaris on Its Deathbed?" Knowing that you are first and foremost a Solaris administrator, I knew immediately that this wasn't one of your columns. And since your column is the only reason I subscribe to an IT world newsletter, I really don't appreciate it when they send me junk like this.

| reply
peer-to-peer

Esther Schindler
If the comments are ugly, the code is ugly

claird
SVG a graphics format for 21st century

pasmith
Take Chrome OS for a test spin

Sandra Henry-Stocker
Solaris Tip: Have Your Files Changed Since Installation?

sjvn
64-bits of protection?

jfruh
Android fragments vs. the iPhone monolith

mikelgan
What Gizmodo missed about the Pro WX Wireless USB disk drive

 

Where Google Chrome security fails: the password
I heard mention that the Chrome OS will have some sort of encryption available a la bitlocker. If it's possible to encrypt personal data using another password or key, then it may have potential for very secure data.... And Ubuntu has an 'encrypt home directory' option, perhaps google should follow suit.
- Dann

Join the conversation here

The Daily Tip

The Daily TipQuick, practical advice for IT pros. Made fresh daily.

Hot tips:

Want to cash in on your IT savvy? Send your tip to tips@itworld.com. If we post it, we'll send you a $25 Amazon e-gift card.

Newsletters

Subscribe to ITWORLD TODAY and receive the latest IT news and analysis.

I would like to receive offers via email from ITworld partners.
By clicking submit you agree to the terms and conditions outlined in ITworld's privacy policy.
Featured Sponsor

AISO founders envisioned a Web hosting company that was environmentally friendly. While the company employed energy-efficient innovations like solar panels, its infrastructure produced unacceptable power and cooling requirements. Find out how AISO leveraged AMD technology to overcome their challenge in this case study white paper.

In this whitepaper, Scalar explores the opportunity to change the landscape with respect to mission critical databases built around Oracle. Leveraging technologies such as Linux, high-end commodity processing power and Oracle RAC technology to architect, design, build and maintain database infrastructure that delivers maximum availability, reliability and performance at a fraction of traditional cost.

On a typical day, weather.com, the Web site for The Weather Channel in Atlanta, serves up between 15 million and 20 million page views. But in September 2004, when back-to-back hurricanes ransacked Florida, the peak traffic on one day more than tripled: over 70 million page views by more than 7 million unique visitors. Read the full success story now.

Marketplace