BOoRFGOnZ 发表于 2009-3-20 12:00:56

修复ext3超级块

The EXT2 Superblock

The Superblock contains a description of the basic size and shape of this file system. The information within it allows the file system manager to use and maintain the file system. Usually only the Superblock in Block Group 0 is read when the file system is mounted but each Block Group contains a duplicate copy in case of file system corruption. Amongst other information it holds the:

Magic Number
    This allows the mounting software to check that this is indeed the Superblock for an EXT2 file system. For the current version of EXT2 this is 0xEF53.
Revision Level
    The major and minor revision levels allow the mounting code to determine whether or not this file system supports features that are only available in particular revisions of the file system. There are also feature compatibility fields which help the mounting code to determine which new features can safely be used on this file system,
Mount Count and Maximum Mount Count
    Together these allow the system to determine if the file system should be fully checked. The mount count is incremented each time the file system is mounted and when it equals the maximum mount count the warning message ``maximal mount count reached, running e2fsck is recommended'' is displayed,
Block Group Number
    The Block Group number that holds this copy of the Superblock,
Block Size
    The size of the block for this file system in bytes, for example 1024 bytes,
Blocks per Group
    The number of blocks in a group. Like the block size this is fixed when the file system is created,
Free Blocks
    The number of free blocks in the file system,
Free Inodes
    The number of free Inodes in the file system,
First Inode
    This is the inode number of the first inode in the file system. The first inode in an EXT2 root file system would be the directory entry for the '/' directory.

BOoRFGOnZ 发表于 2009-3-20 12:01:17

超级块:从磁盘上读出来的第一块信息就是超级块(superblock),它记录了磁盘的几何尺寸,可用空间容量最重要的是记录了第一个inode位置,就是"/ "的拉,ext2/3文件存取都是通过inode定位的,比如使用/home/blue/test这个文件,首先先找到/的inode,然后找到 /home的inode,再找到blue的inode最后找到test的inode,可见没有超级块,文件系统就没有使用意义。来看看ext2/3文件系统的结构图:可以看出,ext2/3文件系统是由许多的块组组成,在其他的块组中保存了超级块的复本通常只有块组0的超级块会被程序读取,比如mount,e2fsck 默认就只读取块组0的。如果超级块被写上其他的数据,比如被mkswap后,超级块保存的信息就丢失了mount,fsck就会报告超级块损坏,无法正常挂载系统了 :(鉴于超级块如此重要,文件系统的设计者将这些超级块拷贝了许多份分散在整个文件系统的块组中。我们要做的就是用分散在其他块组中超级块替换已经损坏的,就万事大吉啦。首先找出超级块都被藏到哪去了 注意: -n 参数表示只列出文件系统的信息,并不真的格式化分区,使用mke2fs时一定要加倍小心不然真给格了一定要小心。mke2fs -n /dev/hda10
mke2fs 1.35 (28-Feb-2004)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)883008 inodes, 1763125 blocks88156 blocks (5.00%) reserved for the super userFirst data block=054 block groups32768 blocks per group, 32768 fragments per group16352 inodes per groupSuperblock backups stored on blocks:      32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
原来藏在32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632下面就使用e2fsck命令修复。
e2fsck -b 32768 /dev/hda10 -b参数指定超级块位置,不使用默认的超级块,默认的都坏掉了。
按照提示,一路y后。

[ 本帖最后由 BOoRFGOnZ 于 2009-3-20 12:04 编辑 ]
页: [1]
查看完整版本: 修复ext3超级块