Something's filling up my disk, but I don't know what it is.
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Something's filling up my disk, but I don't know what it is.
My work computer has been running for nearly 2 years now. It's running Ubuntu 8.04 right now. For me it's a good lesson in what happens to installs over the long term.
I just started getting "disk full" errors, and I don't know what could be causing it. First I run df:
It looks like I have 18GB of space and using most of it. I have no idea what it could be, since I have no videos or pictures on this system. I ran apt-get clean, apt-get autoclean as well. So I try ls, thinking I could see what directory is the huge one:
Better to use the command du to show disk usage. Examples:
Code:
du -sh /*
du -ah /
The first will give a directory summery, the second command will output sizes off all files, - hence a lot of output. You can redirect the output to a file (space permitting), then sort/examine it.
Code:
du -sh /* > sizes-summery
du -ah / > sizes-full
The 4096 shown with ls is the size necessary to store the meta-data about files, including the file names contained within the directory.
Since everything is mounted on /dev/sda5 it could be system files or user files under /home that are consuming the space.
In general, I find my Ubuntu systems fill up with trash more than anything else. But this might just be me never quite adjusting to the fact that deleting something doesn't delete it... Look for a hidden directory .Trash1000 in the root of any volumes.
After that, my first ports of call would be /var/log and /home .
OT, but as per your signature, the following would be better phrased "to sort space usage in descending order", but more ideally would be "to sort files in descending order of disk space used" or "to sort files according to disk space used, in descending order".
Quote:
Originally Posted by quanta
A beautiful command to sort space usage in decrease order:
There is also a graphical program that can perform similar functions. If you're using GNOME, I think it's called Disk Usage Analyzer or something similar.
Linux treats everything - including directories - as files. The 4096 you are seeing is the default directory size on disk. If the table of contents for the directory contents fits into the 4096 bytes (most do), then 4096 is what you will see. As the directory grows with more and more files, more and more space will be allocated for the TOC, and the size you see for the directory will grow.
From the command line, execute this command:
sudo find / -type d -size +100000c
This will search your hard drive for any directories whose file descriptor is over 100000 bytes (this would be a BIG directory with lots of files. Typically, /usr, /bin, and /lib will be that big. Also possibly /usr/lib or /usr/local/lib.
You may find something in /var/cache that is that big; if so take a look at it; nothing there should have that many files in it and if it does, you have found your problem.
Basically, look at any directory that is that big. Someplace, you just might find a directory that has a million files in it because a misconfiguration in, for instance, your mail daemon has caused an email to be generated every 60 seconds for the last two years but - because that email couldn't be sent due to a misconfig - those emails have accumulated for that entire time. This, BTW, is the exact situation I have encountered in the past...with over a million files in the directory.
Then, run this command:
sudo find / -type f -size +5000000c
This will identify all files on your drive that are over 5 million bytes in size. You are looking for log files or error files, or core dump files, or pretty much anything else. Check out all candidates, and respond appropriately. Often - usually - deleting is the thing to do. Pay particular attention to .xsession-errors that will exist in home directories; if you remain logged in for long periods, that file can get HUGE if you have some program running that likes to write to the log.
Play with the numbers and the file sizes you use for your thresholds. You'll find the problem; it is there someplace.
Just yesterday, I did this on my system drive and freed 1.7 Gigs on my system partition when I discovered some log files that were growing forever that I had not known about.
Also check if du and df give very different results. If so, there may be some open files, (such as logging scripts) that don't properly end.
For example, I used to run a cronjob with the swatch command (a perl script that monitors log files.) However, the old jobs wouldn't properly close, so if I did pgrep swatch (to see how many instances were running) there would only be one, but if I did pgrep perl there would be 10 instances (in a ten day period.)
The command
Code:
lsof |(sed 1q; grep deleted)
will show files that might be held open by something or another, along with a PID number. Doing
ps -ef |grep <PID_number> will show what process is doing this.
It's a relatively uncommon situation, but a useful thing to check if du shows lots of space while df shows almost none.
1. su to become root. BE VERY CAREFUL FROM THIS POINT ON
2. cd / to go to the root of the file system
3. du | sort -rn > /tmp/greedy.txt to create a text file for browsing with less, or a text editor
I did this. The first entry in my text file was ~/.strigi. I deleted it and gained 7GB. I'm not even sure what it is but I think it's just a config file for a desktop search program. Thanks!
I did this. The first entry in my text file was ~/.strigi. I deleted it and gained 7GB. I'm not even sure what it is but I think it's just a config file for a desktop search program. Thanks!
You did removed or disabled the program to?
Otherwise the file will be recreated.
Ahh, but I really needed my computer so as soon as I could do work again I forgot about further de-cruftifying. I have at least two years before I have to worry about it. I'll probably upgrade before then.
I had the same problem that was driving me mad. every time i'd clear more space on my drive i would come back the next day to see it full again.
Turns out it was my
.xsession-errors
files that grew to 142G
much of it was firefox warnings...
now i need to go back and find out what is wrong with firefox but at least my disk is free.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.