LinuxQuestions.org
Register a domain and help support LQ
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-03-2003, 05:45 PM   #1
mcd
Member
 
Registered: Aug 2003
Location: Boulder, CO
Distribution: Slackware, RHEL, CentOS
Posts: 825

Rep: Reputation: 33
df and du


i'm having the weirdest problem: i ran df and got this:

bash-2.05b# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hdb5 5.7G 5.1G 314M 95% /
/dev/hdb1 99M 6.9M 86M 8% /boot
/dev/hdb6 5.7G 2.3G 3.1G 42% /usr
/dev/hdb2 15G 4.2G 10G 29% /mnt/files
/dev/hda1 8.5G 3.6G 4.9G 42% /mnt/windows


so i figured i'd take a look at what was taking up all the room on my / partition with du

4.9M /bin
2.9M /boot
348k /dev
19M /etc
9.8M /fonts
11M /freetype-2.1.4
254M /home
20M /lib
16k /lost+found
7.7G /mnt
250M /opt
du: `/proc/2020/fd/4': No such file or directory
5.0k /proc
32M /root
5.7M /sbin
13M /tmp
2.3G /usr
313M /var


since /usr and /mnt are different partitions, they shouldn't be included in the total count right? unless my math is really off, all the rest adds up to less than 1 gigabyte! why does df say my 5.7 gb partition is almost full??

i'd really appreciate any help people can give on this, since having a full / partition is bound to be a problem. thanks,
 
Old 09-03-2003, 06:01 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Jessie, Linux Mint 17
Posts: 7,751

Rep: Reputation: 272Reputation: 272Reputation: 272
"so i figured i'd take a look at what was taking up all the room on my / partition with du"

du reports space usage for a file system, not a partition. If you simply enter du it reports everything, including any mounted partitions, including mounted CD, etc.

Break the problem into chunks like this:
du -s -h /usr
du -s -h /bin

and so forth.
 
Old 09-03-2003, 06:13 PM   #3
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 683

Rep: Reputation: 63
du -x skips directories on different filesystems
 
Old 09-03-2003, 08:05 PM   #4
mcd
Member
 
Registered: Aug 2003
Location: Boulder, CO
Distribution: Slackware, RHEL, CentOS
Posts: 825

Original Poster
Rep: Reputation: 33
those results i've already posted came from du -sh /* - which was exactly what you suggested. can you explain why those results don't match the total space used according to df?
 
Old 09-03-2003, 11:38 PM   #5
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Jessie, Linux Mint 17
Posts: 7,751

Rep: Reputation: 272Reputation: 272Reputation: 272
"those results i've already posted came from du -sh /* - which was exactly what you suggested. can you explain why those results don't match the total space used according to df?"

I did not suggest du -sh /*

df measures the space on a partition.
du measures the space on a file system.

When you issue du -sh /* you measure your entire file system which includes several partitions, including your windows partition, mounted CDs, etc.

When you issue df it measures only the / partition. It does not include the mounted partitions such as windows, mounted CDs, etc.

So du will show more space in your / file system than df shows in your / partition.
 
Old 09-04-2003, 12:11 AM   #6
mcd
Member
 
Registered: Aug 2003
Location: Boulder, CO
Distribution: Slackware, RHEL, CentOS
Posts: 825

Original Poster
Rep: Reputation: 33
i understand that, which is why i ignored the 7.7G and 2.3G associated with /mnt and /usr, respectively. I'm wondering why the rest of the values add up to less than 1G when df claims they add up to 5.1G. Since I would rather solve this problem than get into an argument, here are the results of what you suggest:

bash-2.05b# ls
bin dev fonts home lost+found opt root tmp var
boot etc freetype-2.1.4 lib mnt proc sbin usr

bash-2.05b# du -sh /bin
4.9M /bin
bash-2.05b# du -sh /boot
2.9M /boot
bash-2.05b# du -sh /dev
348k /dev
bash-2.05b# du -sh /etc
19M /etc
bash-2.05b# du -sh /fonts
9.8M /fonts
bash-2.05b# du -sh /freetype-2.1.4/
11M /freetype-2.1.4
bash-2.05b# du -sh home
257M home
bash-2.05b# du -sh /lib
20M /lib
bash-2.05b# du -sh /lost+found/
16k /lost+found
bash-2.05b# du -sh /opt
250M /opt
bash-2.05b# du -sh /proc
du: `/proc/2554/fd/4': No such file or directory
18k /proc
bash-2.05b# du -sh /root
32M /root
bash-2.05b# du -sh /sbin
5.7M /sbin
bash-2.05b# du -sh /tmp
13M /tmp
bash-2.05b# du -sh /var
313M /var
bash-2.05b#


these have the same numbers as those I posted above, and do not include /usr or /mnt because those are separate partitions which should not affect the free space on my / partition. As you can see, these add up to less than 1G. Any ideas?
 
Old 09-04-2003, 04:22 AM   #7
mcd
Member
 
Registered: Aug 2003
Location: Boulder, CO
Distribution: Slackware, RHEL, CentOS
Posts: 825

Original Poster
Rep: Reputation: 33
is it possible that df is not up-to-date or reporting innacurately? is there any way i could tell?
 
Old 09-04-2003, 04:41 AM   #8
footfrisbee
Member
 
Registered: Apr 2003
Distribution: Debian Sarge
Posts: 259

Rep: Reputation: 30
Maybe you should try dropping to single user mode, unmounting all the other partitions except / and run du again?
 
Old 10-06-2003, 09:12 AM   #9
jogar
LQ Newbie
 
Registered: Sep 2003
Location: Yorktown, VA
Distribution: Mandrake 10
Posts: 8

Rep: Reputation: 0
I am curious about this as well. I'm not sure what caused this to happen but df reports my / as being:
1028124 1009680 18444 99% /

But du -sx / reports:
78624

So I should be at 8%. I've booted off the CD, gone into rescue mode and did a fsck on /, but found no problems and the size (reported by df) did not change.

I've downloaded and compiled fileutils, but I haven't figured out where exactly in the df code the summation is coming from.
 
  


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




All times are GMT -5. The time now is 12:56 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