Re: df -h shows ~10 times bigger size when umounting pendrive

David Newall
2009-03-22T14:52:39Z

Arkadiusz Miskiewicz wrote:
> /etc/mtab contains:
>
> /dev/sdb1 /media/floppy vfat rw 0 0
>
> statfs() returns:
>
> statfs("/media/floppy", {f_type=0x58465342, f_bsize=4096, f_blocks=2497555,
> f_bfree=1410716, f_bavail=1410716, f_files=10000448, f_ffree=9842679,
> f_fsid={2051, 0}, f_namelen=255, f_frsize=4096}) = 0
>

The statfs(), above, is not a stat for the file system at /media/floppy,
it's a stat for the file system which *contains* /media/floppy. If
/dev/sdb1 has been unmounted (which was in fact in occurring at the
time) the stat refers to (in your case) the root filesystem. And look
at the returned information: 2497555 4K blocks, 1410716 of them
available; that's 9.6GB file system with 5.5GB available, same as /dev/sda3.

Truly, this is what I said it was; and it's normal, and it's reasonable.

> /dev/sdb1 9,6G 4,2G 5,4G 44% /media/floppy
>
> So why statfs() lies on a being unmounted filesystem?

There is a lie, which is that /media/floppy is on /dev/sdb1. That
ceases to be true as soon as the umount starts. The reason df lies is
because it trusts the mtab, which has not yet had the entry for
/dev/sdb1 removed.