为什么 hf -h 返回正确的总磁盘空间,但 hf 默认返回错误的 1024 块数?

为什么 hf -h 返回正确的总磁盘空间,但 hf 默认返回错误的 1024 块数?

我正在 VirtualBox VM、Lubuntu 上测试hf命令,分配了 30 Gb 的虚拟驱动器(注意:真正的 Gb 不是 gibi/mebi 的东西)。但是当我使用hf命令时会发生一些非常奇怪的事情:

root@vbox:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           292M  1,2M  291M   1% /run
/dev/sda1        30G   20G  8,2G  71% /
tmpfs           1,5G     0  1,5G   0% /dev/shm
tmpfs           5,0M  4,0K  5,0M   1% /run/lock
tmpfs           4,0M     0  4,0M   0% /sys/fs/cgroup
tmpfs           292M   92K  292M   1% /run/user/1000
root@vbox:~# df
Filesystem     1K-blocks     Used Available Use% Mounted on
tmpfs             298632     1180    297452   1% /run
/dev/sda1       30833564 20826180   8523272  71% /
tmpfs            1493144        0   1493144   0% /dev/shm
tmpfs               5120        4      5116   1% /run/lock
tmpfs               4096        0      4096   0% /sys/fs/cgroup
tmpfs             298628       92    298536   1% /run/user/1000
root@vbox:~# df --block-size=1
Filesystem       1B-blocks        Used  Available Use% Mounted on
tmpfs            305799168     1208320  304590848   1% /run
/dev/sda1      31573569536 21326008320 8727830528  71% /
tmpfs           1528979456           0 1528979456   0% /dev/shm
tmpfs              5242880        4096    5238784   1% /run/lock
tmpfs              4194304           0    4194304   0% /sys/fs/cgroup
tmpfs            305795072       94208  305700864   1% /run/user/1000
root@vbox:~# tune2fs -l /dev/sda1
tune2fs 1.46.5 (30-Dec-2021)
Filesystem volume name:   <none>
Last mounted on:          /
Filesystem UUID:          eb1f771e-14d9-461b-98b4-1e399a7ddeb0
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              1974272
Block count:              7865088
Reserved block count:     366932
Free blocks:              3060668
Free inodes:              1637218
First block:              0
Block size:               4096
Fragment size:            4096
Group descriptor size:    64
Reserved GDT blocks:      1023
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Flex block group size:    16
Filesystem created:       Mon Dec  7 20:34:27 2020
Last mount time:          Sat Jul 29 08:28:43 2023
Last write time:          Sat Jul 29 08:28:43 2023
Mount count:              31
Maximum mount count:      -1
Last checked:             Mon Dec  7 20:34:27 2020
Check interval:           0 (<none>)
Lifetime writes:          36 GB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               256
Required extra isize:     32
Desired extra isize:      32
Journal inode:            8
First orphan inode:       1186725
Default directory hash:   half_md4
Directory Hash Seed:      fd016d91-9723-4dcc-9880-0b2a65e0bb49
Journal backup:           inode blocks
Checksum type:            crc32c
Checksum:                 0x54deee1a

正如您所看到的,df -h返回了正确的精确 30 Gb,而裸露dfdf --block-size=1返回了大约600 000 000字节。

更有趣的是,tune2fs -l /dev/sda1显示了 4k 块的正确数量,总计为32 215 400 448字节或30.0029 Gb

这当然不是 5% 保留块的问题,因为df Size列必须返回绝对字节总数。这该如何解释呢?

相关内容