• 1
  • 2
  • 3
  • 4
  • 5
Linux操作系统运维问题 首 页  »  帮助中心  »  云服务器  »  Linux操作系统运维问题
ECS linux Super block损坏的手工修复
发布日期:2015-12-18 22:12:13

  分区Super block损坏,可尝试手工修复

  温馨提示:操作有风险,操作前请您先手工创建快照防止数据丢失。

  1、查找super block位置

  [root@iZ23b9qm9haZ ~]# dumpe2fs /dev/xvdb1 | grep --before-context=1 superblock

  dumpe2fs 1.41.12 (17-May-2010)

  Group 0: (Blocks 0-32767)

  Primary superblock at 0, Group descriptors at 1-1

  --

  Group 1: (Blocks 32768-65535)

  Backup superblock at 32768, Group descriptors at 32769-32769

  --

  Group 3: (Blocks 98304-131071)

  Backup superblock at 98304, Group descriptors at 98305-98305

  --

  Group 5: (Blocks 163840-196607)

  Backup superblock at 163840, Group descriptors at 163841-163841

  --

  Group 7: (Blocks 229376-262143)

  Backup superblock at 229376, Group descriptors at 229377-229377

  --

  Group 9: (Blocks 294912-327679)

  Backup superblock at 294912, Group descriptors at 294913-294913

  --

  Group 25: (Blocks 819200-851967)

  Backup superblock at 819200, Group descriptors at 819201-819201

  --

  Group 27: (Blocks 884736-917503)

  Backup superblock at 884736, Group descriptors at 884737-884737

  从上面操作可以看出,在第1、3、5、7、9、25、27这几个Block Group上存放有superblock备份。

  所以super block放置在如下这些块上(mke2fs -n /dev/xvdb1可以更直观的显示出来)

  32768, 98304, 163840, 229376, 294912, 819200, 884736

  2、破坏super block

  [root@iZ23b9qm9haZ ~]# dd if=/dev/zero of=/dev/xvdb1 bs=1 count=1024 seek=1024

  1024+0 records in

  1024+0 records out

  1024 bytes (1.0 kB) copied, 0.00852143 s, 120 kB/s

  这时候我们根本无法从dumpe2fs和tune2fs看到Backup superblock的位置

  [root@iZ23b9qm9haZ ~]# dumpe2fs /dev/xvdb1 | grep --before-context=1 superblock

  dumpe2fs 1.41.12 (17-May-2010)

  dumpe2fs: Bad magic number in super-block while trying to open /dev/xvdb1

  Couldn't find valid filesystem superblock.

  3、mke2fs方式修复

  [root@iZ23b9qm9haZ ~]# mke2fs -S /dev/xvdb1

  可以看到已经修复

  [root@iZ23b9qm9haZ ~]# dumpe2fs /dev/xvdb1 | grep --before-context=1 superblock

  dumpe2fs 1.41.12 (17-May-2010)

  Group 0: (Blocks 0-32767)

  Primary superblock at 0, Group descriptors at 1-1

  --

  Group 1: (Blocks 32768-65535)

  Backup superblock at 32768, Group descriptors at 32769-32769

  --

  Group 3: (Blocks 98304-131071)

  Backup superblock at 98304, Group descriptors at 98305-98305

  --

  Group 5: (Blocks 163840-196607)

  Backup superblock at 163840, Group descriptors at 163841-163841

  --

  Group 7: (Blocks 229376-262143)

  Backup superblock at 229376, Group descriptors at 229377-229377

  --

  Group 9: (Blocks 294912-327679)

  Backup superblock at 294912, Group descriptors at 294913-294913

  --

  Group 25: (Blocks 819200-851967)

  Backup superblock at 819200, Group descriptors at 819201-819201

  --

  Group 27: (Blocks 884736-917503)

  Backup superblock at 884736, Group descriptors at 884737-884737

  4、e2fsck方式修复

  [root@iZ23b9qm9haZ ~]# dd if=/dev/zero of=/dev/xvdb1 bs=1 count=1024 seek=1024

  [root@iZ23b9qm9haZ ~]# e2fsck /dev/xvdb1

  或者

  [root@iZ23b9qm9haZ ~]# e2fsck -b 884736 /dev/xvdb1 //放置备份的super block的块