LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 09-30-2009, 11:37 AM   #1
Daravon
Member
 
Registered: Mar 2006
Posts: 170

Rep: Reputation: 15
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:

Code:
bob@0-13-72-d0-a-5:~$ df -lh
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5              18G   17G   99M 100% /
varrun                501M  164K  501M   1% /var/run
varlock               501M     0  501M   0% /var/lock
udev                  501M   52K  501M   1% /dev
devshm                501M     0  501M   0% /dev/shm
lrm                   501M   38M  464M   8% /lib/modules/2.6.24-17-generic/volatile
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:

Code:
bob@0-13-72-d0-a-5:/$ ls -l
total 84
drwxr-xr-x   2 root root  4096 2008-08-04 10:31 bin
drwxr-xr-x   3 root root  4096 2008-06-19 09:31 boot
lrwxrwxrwx   1 root root    11 2008-05-15 11:19 cdrom -> media/cdrom
drwxr-xr-x  14 root root 14100 2009-09-30 10:13 dev
drwxr-xr-x 143 root root 12288 2009-09-30 10:13 etc
drwxr-xr-x   3 root root  4096 2008-05-15 13:46 home
drwxr-xr-x   2 root root  4096 2008-05-15 11:20 initrd
lrwxrwxrwx   1 root root    33 2008-05-27 10:42 initrd.img -> boot/initrd.img-2.6.24-17-generic
lrwxrwxrwx   1 root root    33 2008-05-15 11:21 initrd.img.old -> boot/initrd.img-2.6.24-16-generic
drwxr-xr-x  17 root root  4096 2008-08-04 10:31 lib
drwx------   2 root root 16384 2008-05-15 11:19 lost+found
drwxr-xr-x   3 root root  4096 2009-09-30 10:13 media
drwxr-xr-x   2 root root  4096 2008-12-11 11:52 mnt
drwxr-xr-x   2 root root  4096 2008-05-15 11:20 opt
dr-xr-xr-x 137 root root     0 2009-09-22 07:42 proc
drwxr-xr-x  17 root root  4096 2009-09-30 10:28 root
drwxr-xr-x   2 root root  4096 2009-04-01 10:06 sbin
drwxr-xr-x   2 root root  4096 2008-05-15 11:20 srv
drwxr-xr-x  12 root root     0 2009-09-22 07:42 sys
drwxrwxrwt  22 root root  4096 2009-09-30 10:28 tmp
drwxr-xr-x  15 root root  4096 2009-04-01 10:04 usr
drwxr-xr-x  15 root root  4096 2008-05-15 11:36 var
lrwxrwxrwx   1 root root    30 2008-05-27 10:42 vmlinuz -> boot/vmlinuz-2.6.24-17-generic
lrwxrwxrwx   1 root root    30 2008-05-15 11:21 vmlinuz.old -> boot
I'm not sure what those numbers are....I thought they were sizes, but surely they aren't all exactly 4096 bytes.

How can I figure out what is using many gigabytes of space on my system? I don't even see where it's coming from right now, so that I can delete it.
 
Old 09-30-2009, 12:02 PM   #2
brilyant
LQ Newbie
 
Registered: Mar 2006
Posts: 5

Rep: Reputation: 0
My first guess is that you have an auto backup running. They are very good at filling up the nooks and crannies.

To find out what files are using the space use du

My favourite way ahead is:

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

OR

du | sort -rn | less which allows you to scroll through the result immediately.

Why sort -rn ?

n makes the sort numerical, not alpha-numerical, so that 4 is treated as a smaller number than 10.

r reverses the sort order, putting the biggest first. So you will be able to track the really greedy files.

Hope that helps. And DON'T FORGET TO EXIT FROM THE root LOGIN
 
Old 09-30-2009, 12:15 PM   #3
IW2B
Member
 
Registered: Aug 2008
Location: Denmark
Distribution: Fedora, Ubuntu, Solaris
Posts: 35

Rep: Reputation: 19
Hi,

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.

Regards
Ian
 
Old 09-30-2009, 12:20 PM   #4
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 100Reputation: 100
Your hard disk may be full up by log files. Have you checked it?

A beautiful command to sort space usage in decrease order:
su -
cd /
du -s * | sort -rn | cut -f2 | xargs -d '\n' du -sh


You can install a monitoring tool to monitor your hard disk and determine when the disk is full up.
 
Old 09-30-2009, 12:29 PM   #5
Lordandmaker
Member
 
Registered: Sep 2005
Location: London, UK
Distribution: Debian
Posts: 258

Rep: Reputation: 38
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 .
 
Old 09-30-2009, 12:34 PM   #6
Lordandmaker
Member
 
Registered: Sep 2005
Location: London, UK
Distribution: Debian
Posts: 258

Rep: Reputation: 38
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 View Post
A beautiful command to sort space usage in decrease order:
 
Old 09-30-2009, 03:04 PM   #7
hellomynameisphil
LQ Newbie
 
Registered: Aug 2005
Distribution: CRUX and Arch
Posts: 11

Rep: Reputation: 0
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.
 
Old 09-30-2009, 03:17 PM   #8
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 115Reputation: 115
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.
 
Old 09-30-2009, 09:49 PM   #9
SharpyWarpy
Member
 
Registered: Feb 2003
Location: Florida
Distribution: Fedora 18
Posts: 862

Rep: Reputation: 90
I'd go with jiml8's answer if I were you. Sounds pretty good.
 
Old 09-30-2009, 10:50 PM   #10
scottro11
Member
 
Registered: Jun 2009
Location: NYC
Posts: 260

Rep: Reputation: 58
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.
 
Old 10-01-2009, 11:14 AM   #11
Daravon
Member
 
Registered: Mar 2006
Posts: 170

Original Poster
Rep: Reputation: 15
Quote:
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!
 
Old 10-01-2009, 02:47 PM   #12
btncix
Member
 
Registered: Aug 2009
Location: USA
Posts: 141

Rep: Reputation: 26
I love it when a plan comes together!
-Hannibal


Appreciate the info.
 
Old 10-01-2009, 02:51 PM   #13
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,527

Rep: Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898
Quote:
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.
 
Old 10-01-2009, 05:26 PM   #14
Daravon
Member
 
Registered: Mar 2006
Posts: 170

Original Poster
Rep: Reputation: 15
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.
 
Old 12-04-2011, 01:51 AM   #15
debian2004
LQ Newbie
 
Registered: Dec 2011
Posts: 1

Rep: Reputation: Disabled
.xsession-errors

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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ClamAV files filling up disk space noir911 Linux - Server 5 10-10-2008 06:04 AM
ksymoops log filling disk to 100% lobo78 Linux - General 0 06-26-2004 01:04 PM
Something's Wrong! kaz4u2dig Linux - Newbie 2 01-27-2004 08:28 AM
Something's wrong, i know it soulsniper Linux From Scratch 2 10-18-2003 04:08 PM
Something's gone horribly wrong zikhermm Linux - General 4 08-13-2001 09:13 PM


All times are GMT -5. The time now is 01:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration