什么是超级块

如果说inode块是Linux操作系统中文件的核心,那么超级块就是文件系统的心脏。启动Lnux操作系统后,发现某个文件系统无法使用,很有 可能就是超级块出现了问题。为什么这个超级块有这么大的作用呢?主要是因为在超级块中保存了全局文件信息,如硬盘已用空间、数据块可用空间、inode结 点信息等等。做一个形象的比喻,这个超级块就好像是企业的资产负债表,一个文件系统中有哪些资源都记录在这个表中。超级块保存在第一个块组内,并在其他块组留有备份。

ext系统的超级块-LMLPHP

ext系统查看超级块信息

例:

dumpe2fs /dev/sdb1:块分组管理命令,显示

[root@joker-7-01 ~]# dumpe2fs  /dev/sdb1
dumpe2fs 1.42.9 (28-Dec-2013)
Filesystem volume name: <none>
Last mounted on: <not available>
Filesystem UUID: fdc4a200-1962-4464-a9dc-c3d5c03bc324
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent 64bit 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: 196608
Block count: 786432
Reserved block count: 39321
Free blocks: 755396
Free inodes: 196597
First block: 0
Block size: 4096
Fragment size: 4096
Group descriptor size: 64
Reserved GDT blocks: 383
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 4 19:52:27 2017
Last mount time: n/a
Last write time: Mon Dec 4 19:52:27 2017
Mount count: 0
Maximum mount count: -1
Last checked: Mon Dec 4 19:52:27 2017
Check interval: 0 (<none>)
Lifetime writes: 66 MB
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
Default directory hash: half_md4
Directory Hash Seed: 3c095e2f-ab5b-4be9-9dfc-db9704902af0
Journal backup: inode blocks
Journal features: (none)
日志大小: 64M
Journal length: 16384
Journal sequence: 0x00000001
Journal start: 0

Group 0: (Blocks 0-32767)
Checksum 0x02c2, unused inodes 8181
主 superblock at 0, Group descriptors at 1-1
保留的GDT块位于 2-384
Block bitmap at 385 (+385), Inode bitmap at 401 (+401)
Inode表位于 417-928 (+417)
24153 free blocks, 8181 free inodes, 2 directories, 8181个未使用的inodes
可用块数: 8615-32767
可用inode数: 12-8192
Group 1: (Blocks 32768-65535) [INODE_UNINIT]
Checksum 0xf1a2, unused inodes 8192
备份 superblock at 32768, Group descriptors at 32769-32769
保留的GDT块位于 32770-33152
Block bitmap at 386 (bg #0 + 386), Inode bitmap at 402 (bg #0 + 402)
Inode表位于 929-1440 (bg #0 + 929)
32383 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 33153-65535
可用inode数: 8193-16384
Group 2: (Blocks 65536-98303) [INODE_UNINIT, BLOCK_UNINIT]
Checksum 0xa943, unused inodes 8192
Block bitmap at 387 (bg #0 + 387), Inode bitmap at 403 (bg #0 + 403)
Inode表位于 1441-1952 (bg #0 + 1441)
32768 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 65536-98303
可用inode数: 16385-24576
Group 3: (Blocks 98304-131071) [INODE_UNINIT]
Checksum 0xa96c, unused inodes 8192
备份 superblock at 98304, Group descriptors at 98305-98305
保留的GDT块位于 98306-98688
Block bitmap at 388 (bg #0 + 388), Inode bitmap at 404 (bg #0 + 404)
Inode表位于 1953-2464 (bg #0 + 1953)
32383 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 98689-131071
可用inode数: 24577-32768
Group 4: (Blocks 131072-163839) [INODE_UNINIT, BLOCK_UNINIT]
Checksum 0x4c00, unused inodes 8192
Block bitmap at 389 (bg #0 + 389), Inode bitmap at 405 (bg #0 + 405)
Inode表位于 2465-2976 (bg #0 + 2465)
32768 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 131072-163839
可用inode数: 32769-40960
Group 5: (Blocks 163840-196607) [INODE_UNINIT]
Checksum 0x8821, unused inodes 8192
备份 superblock at 163840, Group descriptors at 163841-163841
保留的GDT块位于 163842-164224
Block bitmap at 390 (bg #0 + 390), Inode bitmap at 406 (bg #0 + 406)
Inode表位于 2977-3488 (bg #0 + 2977)
32383 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 164225-196607
可用inode数: 40961-49152
Group 6: (Blocks 196608-229375) [INODE_UNINIT, BLOCK_UNINIT]
Checksum 0xd0c0, unused inodes 8192
Block bitmap at 391 (bg #0 + 391), Inode bitmap at 407 (bg #0 + 407)
Inode表位于 3489-4000 (bg #0 + 3489)
32768 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 196608-229375
可用inode数: 49153-57344
Group 7: (Blocks 229376-262143) [INODE_UNINIT]
Checksum 0x18f0, unused inodes 8192
备份 superblock at 229376, Group descriptors at 229377-229377
保留的GDT块位于 229378-229760
Block bitmap at 392 (bg #0 + 392), Inode bitmap at 408 (bg #0 + 408)
Inode表位于 4001-4512 (bg #0 + 4001)
32383 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 229761-262143
可用inode数: 57345-65536
Group 8: (Blocks 262144-294911) [INODE_UNINIT, BLOCK_UNINIT]
Checksum 0xc685, unused inodes 8192
Block bitmap at 393 (bg #0 + 393), Inode bitmap at 409 (bg #0 + 409)
Inode表位于 4513-5024 (bg #0 + 4513)
32768 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 262144-294911
可用inode数: 65537-73728
Group 9: (Blocks 294912-327679) [INODE_UNINIT]
Checksum 0x02a4, unused inodes 8192
备份 superblock at 294912, Group descriptors at 294913-294913
保留的GDT块位于 294914-295296
Block bitmap at 394 (bg #0 + 394), Inode bitmap at 410 (bg #0 + 410)
Inode表位于 5025-5536 (bg #0 + 5025)
32383 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 295297-327679
可用inode数: 73729-81920
Group 10: (Blocks 327680-360447) [INODE_UNINIT, BLOCK_UNINIT]
Checksum 0x5a45, unused inodes 8192
Block bitmap at 395 (bg #0 + 395), Inode bitmap at 411 (bg #0 + 411)
Inode表位于 5537-6048 (bg #0 + 5537)
32768 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 327680-360447
可用inode数: 81921-90112
Group 11: (Blocks 360448-393215) [INODE_UNINIT]
Checksum 0xcc42, unused inodes 8192
Block bitmap at 396 (bg #0 + 396), Inode bitmap at 412 (bg #0 + 412)
Inode表位于 6049-6560 (bg #0 + 6049)
16384 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 376832-393215
可用inode数: 90113-98304
Group 12: (Blocks 393216-425983) [INODE_UNINIT, BLOCK_UNINIT]
Checksum 0xbf06, unused inodes 8192
Block bitmap at 397 (bg #0 + 397), Inode bitmap at 413 (bg #0 + 413)
Inode表位于 6561-7072 (bg #0 + 6561)
32768 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 393216-425983
可用inode数: 98305-106496
Group 13: (Blocks 425984-458751) [INODE_UNINIT, BLOCK_UNINIT]
Checksum 0x9361, unused inodes 8192
Block bitmap at 398 (bg #0 + 398), Inode bitmap at 414 (bg #0 + 414)
Inode表位于 7073-7584 (bg #0 + 7073)
32768 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 425984-458751
可用inode数: 106497-114688
Group 14: (Blocks 458752-491519) [INODE_UNINIT, BLOCK_UNINIT]
Checksum 0x23c6, unused inodes 8192
Block bitmap at 399 (bg #0 + 399), Inode bitmap at 415 (bg #0 + 415)
Inode表位于 7585-8096 (bg #0 + 7585)
32768 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 458752-491519
可用inode数: 114689-122880
Group 15: (Blocks 491520-524287) [INODE_UNINIT, BLOCK_UNINIT]
Checksum 0x53eb, unused inodes 8192
Block bitmap at 400 (bg #0 + 400), Inode bitmap at 416 (bg #0 + 416)
Inode表位于 8097-8608 (bg #0 + 8097)
32768 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 491520-524287
可用inode数: 122881-131072
Group 16: (Blocks 524288-557055) [INODE_UNINIT]
Checksum 0x7228, unused inodes 8192
Block bitmap at 524288 (+0), Inode bitmap at 524304 (+16)
Inode表位于 524320-524831 (+32)
28656 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 524296-524303, 524312-524319, 528416-557055
可用inode数: 131073-139264
Group 17: (Blocks 557056-589823) [INODE_UNINIT, BLOCK_UNINIT]
Checksum 0x6388, unused inodes 8192
Block bitmap at 524289 (bg #16 + 1), Inode bitmap at 524305 (bg #16 + 17)
Inode表位于 524832-525343 (bg #16 + 544)
32768 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 557056-589823
可用inode数: 139265-147456
Group 18: (Blocks 589824-622591) [INODE_UNINIT, BLOCK_UNINIT]
Checksum 0xb128, unused inodes 8192
Block bitmap at 524290 (bg #16 + 2), Inode bitmap at 524306 (bg #16 + 18)
Inode表位于 525344-525855 (bg #16 + 1056)
32768 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 589824-622591
可用inode数: 147457-155648
Group 19: (Blocks 622592-655359) [INODE_UNINIT, BLOCK_UNINIT]
Checksum 0xff48, unused inodes 8192
Block bitmap at 524291 (bg #16 + 3), Inode bitmap at 524307 (bg #16 + 19)
Inode表位于 525856-526367 (bg #16 + 1568)
32768 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 622592-655359
可用inode数: 155649-163840
Group 20: (Blocks 655360-688127) [INODE_UNINIT, BLOCK_UNINIT]
Checksum 0x546b, unused inodes 8192
Block bitmap at 524292 (bg #16 + 4), Inode bitmap at 524308 (bg #16 + 20)
Inode表位于 526368-526879 (bg #16 + 2080)
32768 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 655360-688127
可用inode数: 163841-172032
Group 21: (Blocks 688128-720895) [INODE_UNINIT, BLOCK_UNINIT]
Checksum 0x1a0b, unused inodes 8192
Block bitmap at 524293 (bg #16 + 5), Inode bitmap at 524309 (bg #16 + 21)
Inode表位于 526880-527391 (bg #16 + 2592)
32768 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 688128-720895
可用inode数: 172033-180224
Group 22: (Blocks 720896-753663) [INODE_UNINIT, BLOCK_UNINIT]
Checksum 0xc8ab, unused inodes 8192
Block bitmap at 524294 (bg #16 + 6), Inode bitmap at 524310 (bg #16 + 22)
Inode表位于 527392-527903 (bg #16 + 3104)
32768 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 720896-753663
可用inode数: 180225-188416
Group 23: (Blocks 753664-786431) [INODE_UNINIT]
Checksum 0xe548, unused inodes 8192
Block bitmap at 524295 (bg #16 + 7), Inode bitmap at 524311 (bg #16 + 23)
Inode表位于 527904-528415 (bg #16 + 3616)
32768 free blocks, 8192 free inodes, 0 directories, 8192个未使用的inodes
可用块数: 753664-786431
可用inode数: 188417-196608

dumpe2fs -h /dev/sdb1   查看sdb1的ext系统的超级块信息(-h 查看超级块信息,不显示分组信息)

由以上的信息可以看出,超级块保存在块组0的第一个块内,并在1、3、5、7、9几个块组的第一个块留有备份(如果文件系统的块比较多,后面还会有备份)

注意:在创建文件系统时,也会有超级块存储位置的明确位置的。

直接查看超级块保存的位置: dumpe2fs /dev/sdb1 | grep  -i superblock
[root@joker-7-01 ~]# dumpe2fs /dev/sdb1 | grep -i superblock
dumpe2fs 1.42.9 (28-Dec-2013)
主 superblock at 0, Group descriptors at 1-1
备份 superblock at 32768, Group descriptors at 32769-32769
备份 superblock at 98304, Group descriptors at 98305-98305
备份 superblock at 163840, Group descriptors at 163841-163841
备份 superblock at 229376, Group descriptors at 229377-229377
备份 superblock at 294912, Group descriptors at 294913-294913

修复ext系列文件系统

fsck和e2fsck可以修复ext的文件系统

fsck -a /dev/sdb1  如果文件系统有错,则自动修复

05-26 17:14