解析ext4檔案系統的佈局
阿新 • • 發佈:2019-02-05
顯然,圖片中展示的是ext2檔案系統的第一個塊組(因為超級快位於起始1024位元組後),可以看出對於一個block group來說,Super Block和Group Descriptors(一般1block)以及Reserverd GDT Blocks後面跟的Block Bitmap為1個塊大小,同樣inode Bitmap也是一個塊大小,inode Table佔固定塊大小,也就是說從硬碟資料的佈局來看,一個標準塊組裡面只包含自身塊組的的block bitmap、inode Bitmap以及inode
Table,可能包括super block和group description table的備份。一個典型的例子如下圖所示:
但是,我在使用dumpe2fs命令檢視ubuntu的ext4檔案系統時,發現從ext2塊組的硬碟佈局來說,一個塊組所包括的塊範圍中可能並不止是包含自己塊組的block bitmap、inode Bitmap以及inode Table,一個塊組內可能存放著其他塊組的block bitmap、inode Bitmap以及inode Table。它是每16個塊組為單位,將這16個塊組的所有block bitmap、inode Bitmap以及inode Table都放在16個塊組的第一個塊組內,同理,某個快組範圍內的塊可能不包括自己塊組的block bitmap,inode bitmap和inode Table.具體見下面ext4檔案系統結構資訊。
Filesystem volume name: <none> Last mounted on: / Filesystem UUID: 0fbdfdd4-80ea-4962-84e8-9173c5ef1cb5 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize Filesystem flags: signed_directory_hash Default mount options: user_xattr acl Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 6037504 Block count: 24146432 Reserved block count: 1207321 Free blocks: 20876199 Free inodes: 5787665 First block: 0 Block size: 4096 Fragment size: 4096 Reserved GDT blocks: 1018 Blocks per group: 32768 Fragments per group: 32768 Inodes per group: 8192 Inode blocks per group: 512 Flex block group size: 16 Filesystem created: Sun Jan 8 01:10:30 2017 Last mount time: Sat Feb 18 11:26:16 2017 Last write time: Sat Feb 18 19:26:08 2017 Mount count: 150 Maximum mount count: -1 Last checked: Sun Jan 8 01:10:30 2017 Check interval: 0 (<none>) Lifetime writes: 31 GB Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 Inode size: 256 Required extra isize: 28 Desired extra isize: 28 Journal inode: 8 First orphan inode: 2250909 Default directory hash: half_md4 Directory Hash Seed: 4c440967-7d09-4b9b-b3be-74a8d8bc47ca Journal backup: inode blocks Journal features: journal_incompat_revoke Journal size: 128M Journal length: 32768 Journal sequence: 0x0001f82e Journal start: 1 Group 0: (Blocks 0-32767) [ITABLE_ZEROED] Checksum 0x5119, unused inodes 5265 Primary superblock at 0, Group descriptors at 1-6 Reserved GDT blocks at 7-1024 Block bitmap at 1025 (+1025), Inode bitmap at 1041 (+1041) Inode table at 1057-1568 (+1057) 22919 free blocks, 5287 free inodes, 592 directories, 5265 unused inodes Free blocks: 9255-9350, 9354-9500, 9529-10104, 10461-10462, 10490-10492, 10673-32767 Free inodes: 1219-1226, 1335-1345, 1637-1639, 2928-8192 Group 1: (Blocks 32768-65535) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0xd779, unused inodes 8192 Backup superblock at 32768, Group descriptors at 32769-32774 Reserved GDT blocks at 32775-33792 Block bitmap at 1026 (bg #0 + 1026), Inode bitmap at 1042 (bg #0 + 1042) Inode table at 1569-2080 (bg #0 + 1569) 23155 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 34151-34160, 34784-34812, 34868-34904, 34906-35013, 35064-35071, 35182-35839, 35865-36735, 36806-38911, 38936-38938, 39054-39057, 39061-39080, 39082-39849, 39932-39934, 39936-39939, 39948-39976, 39980-40027, 41007-41009, 41015-41016, 41018-41020, 41022, 41651-41653, 41655, 41694-41696, 41761, 41767-41830, 41832-41906, 41922, 41934, 42028-42029, 42033-55295, 56576-56622, 56640-56656, 56832-56879, 57344-59391, 59538-60415, 60896-60912, 63565-65535 Free inodes: 8193-16384 Group 2: (Blocks 65536-98303) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0x2ad8, unused inodes 8192 Block bitmap at 1027 (bg #0 + 1027), Inode bitmap at 1043 (bg #0 + 1043) Inode table at 2081-2592 (bg #0 + 2081) 28124 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 65536-71423, 71458-71551, 71627-71679, 73728-74541, 74981-75775, 77824-98303 Free inodes: 16385-24576 Group 3: (Blocks 98304-131071) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0x7ac4, unused inodes 8192 Backup superblock at 98304, Group descriptors at 98305-98310 Reserved GDT blocks at 98311-99328 Block bitmap at 1028 (bg #0 + 1028), Inode bitmap at 1044 (bg #0 + 1044) Inode table at 2593-3104 (bg #0 + 2593) 29970 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 99355-99359, 99391-101375, 102400-102911, 102964-103423, 103988-116223, 116300-131071 Free inodes: 24577-32768 Group 4: (Blocks 131072-163839) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0xafa8, unused inodes 8192 Block bitmap at 1029 (bg #0 + 1029), Inode bitmap at 1045 (bg #0 + 1045) Inode table at 3105-3616 (bg #0 + 3105) 32768 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 131072-163839 Free inodes: 32769-40960 Group 5: (Blocks 163840-196607) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0x35b1, unused inodes 8192 Backup superblock at 163840, Group descriptors at 163841-163846 Reserved GDT blocks at 163847-164864 Block bitmap at 1030 (bg #0 + 1030), Inode bitmap at 1046 (bg #0 + 1046) Inode table at 3617-4128 (bg #0 + 3617) 31743 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 164865-196607 Free inodes: 40961-49152 Group 6: (Blocks 196608-229375) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0x7786, unused inodes 8192 Block bitmap at 1031 (bg #0 + 1031), Inode bitmap at 1047 (bg #0 + 1047) Inode table at 4129-4640 (bg #0 + 4129) 32768 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 196608-229375 Free inodes: 49153-57344 Group 7: (Blocks 229376-262143) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0xadb9, unused inodes 8192 Backup superblock at 229376, Group descriptors at 229377-229382 Reserved GDT blocks at 229383-230400 Block bitmap at 1032 (bg #0 + 1032), Inode bitmap at 1048 (bg #0 + 1048) Inode table at 4641-5152 (bg #0 + 4641) 31743 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 230401-262143 Free inodes: 57345-65536 Group 8: (Blocks 262144-294911) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0xd0b4, unused inodes 8192 Block bitmap at 1033 (bg #0 + 1033), Inode bitmap at 1049 (bg #0 + 1049) Inode table at 5153-5664 (bg #0 + 5153) 32758 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 262144-267903, 267913-267974, 267976-294911 Free inodes: 65537-73728 Group 9: (Blocks 294912-327679) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0x300f, unused inodes 8192 Backup superblock at 294912, Group descriptors at 294913-294918 Reserved GDT blocks at 294919-295936 Block bitmap at 1034 (bg #0 + 1034), Inode bitmap at 1050 (bg #0 + 1050) Inode table at 5665-6176 (bg #0 + 5665) 31743 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 295937-327679 Free inodes: 73729-81920 Group 10: (Blocks 327680-360447) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0xe32a, unused inodes 8192 Block bitmap at 1035 (bg #0 + 1035), Inode bitmap at 1051 (bg #0 + 1051) Inode table at 6177-6688 (bg #0 + 6177) 32768 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 327680-360447 Free inodes: 81921-90112 Group 11: (Blocks 360448-393215) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0x63e2, unused inodes 8192 Block bitmap at 1036 (bg #0 + 1036), Inode bitmap at 1052 (bg #0 + 1052) Inode table at 6689-7200 (bg #0 + 6689) 32768 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 360448-393215 Free inodes: 90113-98304 Group 12: (Blocks 393216-425983) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0xa97c, unused inodes 8192 Block bitmap at 1037 (bg #0 + 1037), Inode bitmap at 1053 (bg #0 + 1053) Inode table at 7201-7712 (bg #0 + 7201) 32768 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 393216-425983 Free inodes: 98305-106496 Group 13: (Blocks 425984-458751) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0x1656, unused inodes 8192 Block bitmap at 1038 (bg #0 + 1038), Inode bitmap at 1054 (bg #0 + 1054) Inode table at 7713-8224 (bg #0 + 7713) 32768 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 425984-458751 Free inodes: 106497-114688 Group 14: (Blocks 458752-491519) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0x1375, unused inodes 8192 Block bitmap at 1039 (bg #0 + 1039), Inode bitmap at 1055 (bg #0 + 1055) Inode table at 8225-8736 (bg #0 + 8225) 32768 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 458752-491519 Free inodes: 114689-122880 Group 15: (Blocks 491520-524287) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0xc64f, unused inodes 8192 Block bitmap at 1040 (bg #0 + 1040), Inode bitmap at 1056 (bg #0 + 1056) Inode table at 8737-9248 (bg #0 + 8737) 27511 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 491520-504959, 505048-516095, 521237-522911, 522940-524287 Free inodes: 122881-131072 Group 16: (Blocks 524288-557055) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0xe6b2, unused inodes 8192 Block bitmap at 524288 (+0), Inode bitmap at 524304 (+16) Inode table at 524320-524831 (+32) 24544 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 532512-557055 Free inodes: 131073-139264 Group 17: (Blocks 557056-589823) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0x6b5f, unused inodes 8192 Block bitmap at 524289 (bg #16 + 1), Inode bitmap at 524305 (bg #16 + 17) Inode table at 524832-525343 (bg #16 + 544) 28480 free blocks, 8192 free inodes, 0 directories, 8192 unused inodes Free blocks: 561244-561279, 561380-589823 Free inodes: 139265-147456
參考資料: