[comp.unix.questions] du vs. df

pjh@mccc.uucp (Pete Holsberg) (11/18/90)

From TFM, it appears to me that "df <filesystem>" and "du -s
<filesystem>" should give complementary reports, the first giving the
number of 512 byte blocks remaining in <filesystem> and the latter, the
number used.  On a 3B2/400 running SVR3.1.2, they don't.  "du -s /usr2"
reports 1049 blocks used.  "df -t /usr2" reports 108424 free, 117404
total, or 8980 blocks used.  The only files that exist in /usr2 are
directory files.

Could someone please explain what's going on?  Oh, I seem to have lost
incoming news, so would you please email your reply?  If anyone else is
interested, I'll post a summary of the replies.

Thanks,
Pete
-- 
Prof. Peter J. Holsberg      Mercer County Community College
Voice: 609-586-4800          Engineering Technology, Computers and Math
UUCP:...!princeton!mccc!pjh  1200 Old Trenton Road, Trenton, NJ 08690
Internet: pjh@mccc.edu	     Trenton Computer Festival -- 4/20-21/91

shwake@raysnec.UUCP (Ray Shwake) (11/22/90)

pjh@mccc.uucp (Pete Holsberg) writes:

>From TFM, it appears to me that "df <filesystem>" and "du -s
><filesystem>" should give complementary reports, the first giving the
>number of 512 byte blocks remaining in <filesystem> and the latter, the
>number used.  On a 3B2/400 running SVR3.1.2, they don't.  "du -s /usr2"
>reports 1049 blocks used.  "df -t /usr2" reports 108424 free, 117404
>total, or 8980 blocks used.  The only files that exist in /usr2 are
>directory files.

	While complementary in some respects, du and df will not provide
	complementary results since they source their information in
	different fashion. (Note: what follows is based on the System III
	and System V boxes with which I'm familiar.)

	'df' pulls its information from the superblocks. "df -t" shows
	the total block size of the file system, *including* space allocated
	to the boot block, superblock, etc. which, by definition are not
	available (not free) for user use. 

	'du', on the other hand, looks at the space consumed by the files
	and directories themselves. Some implementations will double-count
	the space consumed by linked files, others will not.

ask@cbnews.att.com (Arthur S. Kamlet) (11/29/90)

In article <143@raysnec.UUCP>, shwake@raysnec.UUCP (Ray Shwake) writes:
 > pjh@mccc.uucp (Pete Holsberg) writes:
 > 
 > >From TFM, it appears to me that "df <filesystem>" and "du -s
 > ><filesystem>" should give complementary reports, the first giving the
 > >number of 512 byte blocks remaining in <filesystem> and the latter, the
 > >number used.  On a 3B2/400 running SVR3.1.2, they don't.  "du -s /usr2"
 > >reports 1049 blocks used.  "df -t /usr2" reports 108424 free, 117404
 > >total, or 8980 blocks used.  The only files that exist in /usr2 are
 > >directory files.
 > 
 > 	While complementary in some respects, du and df will not provide
 > 	complementary results since they source their information in
 > 	different fashion. (Note: what follows is based on the System III
 > 	and System V boxes with which I'm familiar.)
 > 
 > 	'df' pulls its information from the superblocks. "df -t" shows
 > 	the total block size of the file system, *including* space allocated
 > 	to the boot block, superblock, etc. which, by definition are not
 > 	available (not free) for user use. 
 > 
 > 	'du', on the other hand, looks at the space consumed by the files
 > 	and directories themselves. Some implementations will double-count
 > 	the space consumed by linked files, others will not.
 
 
Also, du silently fails to report about unreadable directories.
-- 
Art Kamlet  a_s_kamlet@att.com  AT&T Bell Laboratories, Columbus