首页 > 代码库 > 修复文件系统的思路

修复文件系统的思路

 fsck -fy /dev/sda1

dumpe2fs /dev/sda1|grep superblock查看 备份的superblock

root@Defcon:/tmp# dumpe2fs /dev/sda1|grep super

dumpe2fs 1.42 (29-Nov-2011)

Filesystem features:      ext_attr resize_inode dir_index filetype sparse_super

  Primary superblock at 1, Group descriptors at 2-2

  Backup superblock at 8193, Group descriptors at 8194-8194

  Backup superblock at 24577, Group descriptors at 24578-24578

  Backup superblock at 40961, Group descriptors at 40962-40962

  Backup superblock at 57345, Group descriptors at 57346-57346

  Backup superblock at 73729, Group descriptors at 73730-73730

  Backup superblock at 204801, Group descriptors at 204802-204802

  Backup superblock at 221185, Group descriptors at 221186-221186

然后执行 fsck -b 8193 /dev/sda1,如果成功,尝试mount 系统,如果失败,继续使用下一个备份superblock

mount sb=8193 /dev/sda1 /mnt

如果以上步骤都失败,需要用dd 备份坏掉的磁盘到新的硬盘上

dd conv=noerror if=/dev/sda of=/mnt/recovery/sdaimage.dd

然后执行

fsck /mnt/recovery/sdaimage.dd

如果是一个单独的分区,可以这样

mount -o loop /mnt/recovery/sdaimage.dd /mnt/sdaimage

如果是多个分区中的一个坏掉,可以这样

fdisk -lu /mnt/recovery/sdaimage.dd

如果是第二个分区柱面从80300开始,单位是512bit,那么总共是80300×512=4113600bit 

那就要这样执行

mount -o loop,offset=41113600 /mnt/recover/sdaimage.raw /mnt/sdaimage

然后写一个新磁盘

dd if=/mnt/recovery/sdaimage.raw of=/dev/sdb



本文出自 “天涯海阁” 博客,请务必保留此出处http://shanker.blog.51cto.com/1189689/1535654