Skip to content
Commit 38280190 authored by Mike Fleetwood's avatar Mike Fleetwood Committed by Curtis Gedak
Browse files

Read file system size for mounted ext2/3/4 from superblock (#683255)

A user had a 190 MiB partition containing an old ext2 file system.  When
unmounted it was reported as filling the partition, but when mounted it
was reported as having 6% unallocated space.  The file system's inode
tables were approximately twice the size of those created by default
with the current mkfs.ext2 defaults.

To create an equivalent file system in a 190 MiB partition:
    mkfs.ext2 -N 97344 /dev/sda15

It turns out that for ext2, ext3 and ext4 file systems what was
described as intrinsic unallocated space during the development of
Bug #499202 is actually file system overhead.  When mounted the ext2/3/4
kernel code reports the size of the file system after subtracting the
overhead.  Overhead is made up of superblock backups, group descriptors,
allocation bitmaps and largest of all inode tables.  E2fsprogs tools
don't subtract this overhead when reporting the file system size.

References:

 *  The Second Extended File System, Internal Layout, by Dave Poirier
    http://www.nongnu.org/ext2-doc/ext2.html

 *  Linux ext2_statfs() function
    http://lxr.linux.no/#linux+v3.5.3/fs/ext2/super.c#L1311

Call the file system specific method for reading the usage of ext2, ext3
and ext4 file systems while mounted.  Make it read the file system size
from the on disk superblock to avoid subtraction of overhead and use the
statvfs() system call to return an up to date free space figure.

Bug #683255 - ext2: statvfs differs from dumpe2fs (x MB unallocated
              space within the partition)
parent 01150758
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment