[Libguestfs] virtdf outputs on host differs from df in guest

Richard W.M. Jones rjones at redhat.com
Thu Jan 4 16:22:46 UTC 2018


To summarise:

>[In guest]
> python -c 'import os; s = os.statvfs ("/boot"); print s'
> posix.statvfs_result(f_bsize=4096, f_frsize=4096, f_blocks=127147,
> f_bfree=93815, f_bavail=93815, f_files=512000, f_ffree=511626,
> f_favail=511626, f_flag=4096, f_namemax=255)

>[From the host via libguestfs]
> # sudo guestfish --ro -d rpm-build-for-7.2 -i statvfs /boot
> bsize: 4096
> frsize: 4096
> blocks: 127147
> bfree: 100215
> bavail: 100215
> files: 512000
> ffree: 511626
> favail: 511626
> fsid: 2049
> flag: 4097
> namemax: 255

[In virt-rescue]
> Block size: 4096       Fundamental block size: 4096
> Blocks: Total: 127147     Free: 93815      Available: 93815
> Inodes: Total: 512000     Free: 511626

The block stats are the same as the "in guest" results above,
but slightly different from libguestfs.

		- * - * - * -

I wanted to see if I could reproduce this with a very simple and
reproducible example.  I made the assumption that this guest is using XFS.

(1) Make an XFS filesystem and use libguestfs to query the statvfs:

$ guestfish -N fs:xfs -m /dev/sda1 statvfs /
bsize: 4096
frsize: 4096
blocks: 24713
bfree: 23347
bavail: 23347
files: 51136
ffree: 51133
favail: 51133
fsid: 2049
flag: 4096
namemax: 255

(2) Open the same disk image in virt-rescue and examine with stat
command:

$ virt-rescue -a test1.img
><rescue> mount /dev/sda1 /sysroot
><rescue> stat -f /sysroot
  File: "/sysroot"
    ID: 80100000000 Namelen: 255     Type: xfs
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 24713      Free: 23347      Available: 23347
Inodes: Total: 51136      Free: 51133


In this case the numbers are the same ...

I would really like a bit more information though:

(a) Are you using XFS or another filesystem?

(b) Can you make a small independent reproducer like mine above?

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org




More information about the Libguestfs mailing list