/ full?

Hal Duston hald at sound.net
Mon Dec 2 20:50:35 CST 2002


On Wed, 17 Jan 2001, Steven Elling wrote:

> On Monday 02 December 2002 00:20, Jim Herrmann wrote:
> 
> > Man, I'm learning some great commands here, but I still don't see why DU
> > and DF don't match up.
> 
> I think the reason they don't match is because du asks the kernel for the 
> size of each file and df asks the kernel how many blocks are being used by 
> all the files on the file system.
> 
> By default when mke2fs is used to create a file system the block size is set 
> to 4096 typically.  So as far as the space being used on the file system is 
> concerned, a 1 byte file will use up 4096 bytes on the file system.  If you 
> have 1024 1-byte files, all the files will take up 4194304 bytes (4 Meg) on 
> the file system.  This would explain why df always shows more space being 
> used as compared to du.

No.  `du' reports blocks in use as well.

$ mkdir x
$ cd x
$ for i in a b c d e f g h i j k l m n o p q r s t u v w x y z
$ do echo > $i
$ done
$ du -k .
105     .
$ du -b .
107520  .
$ du -h .
105K    .

The most likely culprit is files that have been removed from the
filesystem, but are still held open by some process.  `du' reports blocks
used by each and every object that is reachable with a valid filename.  
`df' reports blocks in used by the filesystem.  That may include files
that are still in use, but have been removed from the filesystem.

My mechanisim to chase down file-system usage is "du -kx | sort -nr".  -k
for kilobytes, -x for one-file-system, -n for numeric sort, and -r for
reverse.

Hal




More information about the Kclug mailing list