-n Causes mke2fs to not actually create a filesystem, but display what it would do if it were to create a filesystem. This can be used to determine the location of the backup superblocks for a particular filesystem, so long as the mke2fs parameters that were passed when the filesystem was originally created are used again. (With the -n option added, of course!)
[root@server1 ~]# mke2fs -n /dev/sdb
mke2fs 1.41.12 (17-May-2010)
/dev/sdb is entire device, not just one partition!
无论如何也要继续? (y,n) y
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 --------------->>> 超级块的备份位置就在这里
-b superblock Instead of using the normal superblock, use an alternative superblock specified by superblock. This option is normally used when the primary superblock has been corrupted. The location of the backup superblock is dependent on the filesystem’s blocksize. For filesystems with 1k blocksizes, a backup superblock can be found at block 8193; for filesystems with 2k blocksizes, at block 16384; and for 4k blocksizes, at block 32768.
Additional backup superblocks can be determined by using the mke2fs program using the -n option to print out where the superblocks were created. The -b option to mke2fs, which specifies blocksize of the filesystem must be specified in order for the superblock locations that are printed out to be accurate.
If an alternative superblock is specified and the filesystem is not opened read-only, e2fsck will make sure that the primary superblock is updated appropriately upon completion of the filesystem check.
效果如下:
[root@server1 ~]# e2fsck -b 32768 /dev/sdb
e2fsck 1.41.12 (17-May-2010)
/dev/sdb was not cleanly unmounted, 强制检查.
第一步: 检查inode,块,和大小
第二步: 检查目录结构
第3步: 检查目录连接性
Pass 4: Checking reference counts
第5步: 检查簇概要信息
/dev/sdb: ***** 文件系统已修改 *****
/dev/sdb: 11/655360 files (0.0% non-contiguous), 79663/2621440 blocks
[root@server1 ~]# dumpe2fs /dev/sdb|more
dumpe2fs 1.41.12 (17-May-2010)
Filesystem volume name: <none>
Last mounted on: <not available>
Filesystem UUID: c6421bf7-8497-45c0-86b0-dfac1b21989a
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file
uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 655360
Block count: 2621440
Reserved block count: 131072
Free blocks: 2541777
Free inodes: 655349
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 639
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8192
Inode blocks per group: 512
Flex block group size: 16
Filesystem created: Sat Nov 11 13:23:30 2017
Last mount time: n/a
Last write time: Sat Nov 11 16:57:39 2017
Mount count: 0
Maximum mount count: 33
Last checked: Sat Nov 11 16:57:39 2017
[root@server1 /]# dd if=/dev/zero of=/dev/sdb bs=1 count=4096 seek=4096
记录了4096+0 的读入
记录了4096+0 的写出
4096字节(4.1 kB)已复制,0.0795117 秒,51.5 kB/秒
[root@server1 /]# mount /dev/sdb /data/
mount: wrong fs type, bad option, bad superblock on /dev/sdb,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
[root@server1 /]# dmesg |tail -5
EXT4-fs (sdb): mounted filesystem with ordered data mode. Opts:
EXT4-fs (sdb): ext4_check_descriptors: Checksum for group 0 failed (43116!=0)
EXT4-fs (sdb): group descriptors corrupted!
EXT4-fs (sdb): ext4_check_descriptors: Checksum for group 0 failed (43116!=0)
EXT4-fs (sdb): group descriptors corrupted!