hi Jones, Sorry for the late reply. when I used your method to execute command: $guestfish -N fs:xfs -m /dev/sda1 statvfs / libguestfs: error: mkfs: xfs: /dev/sda1: mkfs.xfs: No such file or directory guestfish: error creating prepared disk image 'fs:xfs' on 'test1.img': failed to create filesystem (xfs): mkfs: xfs: /dev/sda1: mkfs.xfs: No such file or directory does I need to rebuild the iniramfs to include mkfs.xfs, is this the root reason that cause the different numbers ? then I used virt-rescure method , the filesystem type was ext2/ext3:
<rescue> mount /dev/sda1 /sysroot/ mount: /dev/sda1 is write-protected, mounting read-only mount: unknown filesystem type '(null)' <rescue> stat -f /sysroot File: "/sysroot" ID: ab0d9f3277e010fd Namelen: 255 Type: ext2/ext3 Block size: 4096 Fundamental block size: 4096 Blocks: Total: 1032112 Free: 941307 Available: 888879 Inodes: Total: 262144 Free: 250996 <rescue>
Thanks, Chen At 2018-01-05 00:22:46, "Richard W.M. Jones" <rjones@redhat.com> wrote:
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