![如何计算 ext2 文件系统上的“每组 Inode 块”?](https://linux22.com/image/123585/%E5%A6%82%E4%BD%95%E8%AE%A1%E7%AE%97%20ext2%20%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E4%B8%8A%E7%9A%84%E2%80%9C%E6%AF%8F%E7%BB%84%20Inode%20%E5%9D%97%E2%80%9D%EF%BC%9F.png)
为了学习,我分配了100M的大小并将驱动器格式化为ext2。
这是以下的输出dumpe2fs
:
[root@ ext2fs]# dumpe2fs /dev/sda2
dumpe2fs 1.42.9 (28-Dec-2013)
Filesystem volume name: <none>
Last mounted on: /home
Filesystem UUID: dd4a8792-84b0-48a3-8356-682229114afd
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: ext_attr resize_inode dir_index filetype sparse_super
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: not clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 25688
Block count: 102400
Reserved block count: 5120
Free blocks: 97577
Free inodes: 25662
First block: 1
Block size: 1024
Fragment size: 1024
Reserved GDT blocks: 256
Blocks per group: 8192
Fragments per group: 8192
Inodes per group: 1976
***Inode blocks per group: 247***
Filesystem created: Tue Dec 12 10:08:16 2017
Last mount time: Wed Dec 13 09:23:29 2017
Last write time: Wed Dec 13 09:23:29 2017
Mount count: 4
Maximum mount count: -1
Last checked: Tue Dec 12 10:08:16 2017
Check interval: 0 (<none>)
Lifetime writes: 58 kB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Default directory hash: half_md4
Directory Hash Seed: a24eb501-5513-40fe-afeb-04b93ae8d11f
我想知道“每组 Inode 块”是如何计算的,在本例中为 247。
答案1
索引节点只是打包在块中,大小都是 2 的幂,因此它们完全适合。从这些数字可以看出:
Block size: 1024
Inodes per group: 1976
Inode size: 128
我们得到
1024 B/块 -------------- = 8 个 inode/块 128 B/索引节点 1976 个索引节点/组 ------------------- = 247(索引节点)块/组 8 个索引节点/块
这是预期的结果。
我认为索引节点也均匀分布在所有块组上,因此比率(inodes/group) / (total inodes)
和(blocks/group) / (total blocks)
也应该相等(直到四舍五入,因为最后一个块组未满)。