file size and actually blocks do not match

Bryan Kadzban bryan at
Fri Jul 2 23:08:09 UTC 2004

Paul Raines wrote:
> I have a disk where serveral files have a file size that is much bigger
> then the space they actually use.  THe file size is bogus. In the example
> below, the size is reported as 4.2MB but the file is really supposed to be
> on 116K which is true accoring to du and the block list from debugfs.

Sparse file?

$ dd if=/dev/zero of=testfile seek=1M count=1 bs=1024
1+0 records in
1+0 records out
$ ls -l testfile
-rw-r--r--    1 <me>    <me>    1073742848 Jul  2 19:04 testfile
$ du -h testfile
12K testfile
$ wc testfile
       0       0 1073742848 testfile

This file contains 1 gig of empty space, then 1K of zeros.  The gig of
empty space reads as zeros to most programs (including wc), but the
zeros aren't actually stored on disk, because they've never been written
to.  That's why it's sparse.

More information about the Ext3-users mailing list