文档中心 > 云服务器 ECS

云服务器 ECS Linux Super block 损坏修复方法

更新时间: 访问次数:1935

Linux 分区 Super block 损坏,可以尝试手工修复,本文对此进行简要说明。

注意:操作有风险!操作前请务必先手工创建快照,防止数据丢失!

 

1、查找 super block 位置

  
  
  1. $ dumpe2fs /dev/xvdb1 | grep --before-context=1 superblock
  2. dumpe2fs 1.41.12 (17-May-2010)
  3. Group 0: (Blocks 0-32767)
  4. Primary superblock at 0, Group descriptors at 1-1
  5. --
  6. Group 1: (Blocks 32768-65535)
  7. Backup superblock at 32768, Group descriptors at 32769-32769
  8. --
  9. Group 3: (Blocks 98304-131071)
  10. Backup superblock at 98304, Group descriptors at 98305-98305
  11. --
  12. Group 5: (Blocks 163840-196607)
  13. Backup superblock at 163840, Group descriptors at 163841-163841
  14. --
  15. Group 7: (Blocks 229376-262143)
  16. Backup superblock at 229376, Group descriptors at 229377-229377
  17. --
  18. Group 9: (Blocks 294912-327679)
  19. Backup superblock at 294912, Group descriptors at 294913-294913
  20. --
  21. Group 25: (Blocks 819200-851967)
  22. Backup superblock at 819200, Group descriptors at 819201-819201
  23. --
  24. Group 27: (Blocks 884736-917503)
  25. Backup superblock at 884736, Group descriptors at 884737-884737
  
  
  1. 从上面操作可以看出,在第 135792527 这几个 Block Group 上存放有 superblock 备份。所以 super block 放置在如下这些块上(mke2fs -n /dev/xvdb1 可以更直观的显示出来):
  2. 32768, 98304, 163840, 229376, 294912, 819200, 884736


2、破坏 super block 测试

  
  
  1. $ dd if=/dev/zero of=/dev/xvdb1 bs=1 count=1024 seek=1024
  2. 1024+0 records in
  3. 1024+0 records out
  4. 1024 bytes (1.0 kB) copied, 0.00852143 s, 120 kB/s
  5. 这时候我们根本无法从dumpe2fstune2fs看到Backup superblock的位置
  6. $ dumpe2fs /dev/xvdb1 | grep --before-context=1 superblock
  7. dumpe2fs 1.41.12 (17-May-2010)
  8. dumpe2fs: Bad magic number in super-block while trying to open /dev/xvdb1
  9. Couldn't find valid filesystem superblock.

3、mke2fs 方式修复示例

  
  
  1. $ mke2fs -S /dev/xvdb1
  2. 可以看到已经修复
  3. $ dumpe2fs /dev/xvdb1 | grep --before-context=1 superblock
  4. dumpe2fs 1.41.12 (17-May-2010)
  5. Group 0: (Blocks 0-32767)
  6. Primary superblock at 0, Group descriptors at 1-1
  7. --
  8. Group 1: (Blocks 32768-65535)
  9. Backup superblock at 32768, Group descriptors at 32769-32769
  10. --
  11. Group 3: (Blocks 98304-131071)
  12. Backup superblock at 98304, Group descriptors at 98305-98305
  13. --
  14. Group 5: (Blocks 163840-196607)
  15. Backup superblock at 163840, Group descriptors at 163841-163841
  16. --
  17. Group 7: (Blocks 229376-262143)
  18. Backup superblock at 229376, Group descriptors at 229377-229377
  19. --
  20. Group 9: (Blocks 294912-327679)
  21. Backup superblock at 294912, Group descriptors at 294913-294913
  22. --
  23. Group 25: (Blocks 819200-851967)
  24. Backup superblock at 819200, Group descriptors at 819201-819201
  25. --
  26. Group 27: (Blocks 884736-917503)
  27. Backup superblock at 884736, Group descriptors at 884737-884737

4、e2fsck 方式修复示例

  
  
  1. $ dd if=/dev/zero of=/dev/xvdb1 bs=1 count=1024 seek=1024
  2. $ e2fsck /dev/xvdb1
  3. 或者
  4. $ e2fsck -b 884736 /dev/xvdb1
  5. # 放置备份的super block的块

 

如果问题还未能解决,您可以到阿里云社区进行免费咨询,或联系云市场商家寻求帮助。

FAQ

关于此文档暂时还没有FAQ
返回
顶部