View Full Version : How to free up disk space?

17th October 2007, 12:22 AM
Okay, somehow my hard disk is at 100 percent full, causing mayhem: lock files aren't getting removed, certain apps don't run...gack. I'd like to delete any caches or temp files that are large enough to give me a wee bit of room...what can safely be deleted? Is there a way to list the top 50 largest files on my system so I can look for a nice 10GB fattie that can be dropped first? I am thinking var or tmp might be a good place to start?

17th October 2007, 01:10 AM
It depends on your filesystem layout. If you have different partitions you can limit your search to that particular partition. If everything is under / then everything is fair game. To find the disk hogs, start with using the du command:

du -sk *

that will give you the disk usage for everything from the current directory on down. You can then start narrowing things down by directory. If you want to find the largest files on your system, use the find command with the -size option. See the manpage for details. A simple one-liner I always use is:

find . -type f -exec ls -l '{}' \; | awk '{print $5, $NF}' | sort -n | tail -10

this will find the 10 largest files from your current directory on down. You can always change the tail value. Beware though, large files are not always the problem. Sometimes its just a bunch of little files.


17th October 2007, 01:40 AM
I'm a big fan of baobab, I like the radial display of the filesystem sizes. It's installable via yum.

William Haller
17th October 2007, 04:37 PM
Take a quick look in /var/log. These files are log files that are created in real time with information about what is happening in the system. They are generally archived once per week creating backup files. These may or may not be compressed. In an emergency, move old ones (ending in a .1, .2 or .1.gz, .2.gz and so forth) to a CD if you need to keep them or remove them completely.

If running squid, shut it down and cd /var/spool/squid. as root - being sure you are really in /var/spool/squid, do a rm -rf *. Then restart squid. Again. Be really, really sure you are in /var/spool/squid before doing a recursive remove.

Do a yum clean all just in case you have it set to save downloaded packages.

Take a look in /var/spool/mail/archive, or similar, depending on your setup and see if you have a huge archive of root mail messages that could be gone through and removed.

If you ever write files to /dev/null, check in /dev for non-device files that you may have accidentally created.

Drop your system down to single user, non-graphical, and cd /tmp. Remove files in there that may have accumulated over time and then restart. Check /var/tmp as well.

Go into your browser and clean all browser caches.

That's a quick list of some basic housekeeping you could do.

20th October 2007, 12:12 PM
Some great info here! I had issues with the 10GB partition that Fedora 8 Test 3 is installed on being 90% used. I didn't like that so I started investigating. I searched the forum and found this post. As a result my disk usage is at 48% now.. That's great! Thanks, everyone, for this valuable info!