linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to query ext2/3/4 total fs size while mounted?
@ 2012-09-07 20:12 Mike Fleetwood
  2012-09-08  0:39 ` Theodore Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Fleetwood @ 2012-09-07 20:12 UTC (permalink / raw)
  To: linux-ext4; +Cc: Mike Fleetwood

Hi,

Is there a way I can/should code GParted (GNOME Partition Editor) to
query a mounted ext2/3/4 file system to get the total file system size?

Unfortunately the f_blocks value from the statvfs() system call has
space occupied by inode tables, allocation bitmaps, etc. subtracted as
overhead and I need the total file system size.  This is so that GParted
can inform users when the file system doesn't fill the partition and
recommend resizing the FS to fix it.

I really want some way to get the the total file system size from
statvfs().  The mount option minixdf isn't really appropriate as GParted
shouldn't be remounting file systems adding mount options to query the
file system size.

Is it safe to read the super block off disk using ext2fs_open() or by
running dumpe2fs for a mounted file system?  What if the file system has
just been resized?  Are there any other methods for querying the total
file system size?

Thanks,
Mike


In this example I want to get the 194560 blocks figure while mounted,
not f_blocks=188403.

# sfdisk -s /dev/sda10
194560
# mkfs.ext4 /dev/sda10
mke2fs 1.41.12 (17-May-2010)
...
48768 inodes, 194560 blocks
...
# dumpe2fs -h /dev/sda10 | grep 'Block count:'
dumpe2fs 1.41.12 (17-May-2010)
Block count:              194560
# mount /dev/sda10 /mnt/0
# strace -e statfs64 stat -f /mnt/0
...
statfs64("/mnt/0", 84, {f_type="EXT2_SUPER_MAGIC", f_bsize=1024,
f_blocks=188403, f_bfree=182757, f_bavail=173029, f_files=48768,
f_ffree=48757, f_fsid={-1366779076, -459235834}, f_namelen=255,
f_frsize=1024}) = 0
  File: "/mnt/0"
    ID: ae889b3ce4a09e06 Namelen: 255     Type: ext2/ext3
Block size: 1024       Fundamental block size: 1024
Blocks: Total: 188403     Free: 182757     Available: 173029
Inodes: Total: 48768      Free: 48757

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-10 10:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-07 20:12 How to query ext2/3/4 total fs size while mounted? Mike Fleetwood
2012-09-08  0:39 ` Theodore Ts'o
2012-09-10 10:39   ` Mike Fleetwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).