免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 735 | 回复: 0
打印 上一主题 下一主题

恢复 EXT3 Superblock 的正确方法 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-06-09 13:05 |只看该作者 |倒序浏览

前几天遇到一个 Linux Ext3 文件系统超级块(Superblock)错误问题.
.... bad superblock on /dev/hda4一个同事做的恢复, 结果把数据都抹掉了. 后来想想, 当时的直接 fsck 的恢复方法不对. 正确的方法应该是这样的:
1 获取错误的出错磁盘(或者设备)块的大小.
有很多种方法可以得到. 比如,
# tune2fs -l /dev/hda4其实大多数情况下是 1 K.
2 对当前的出错磁盘备份.
恢复超级块(Superblock)的过程其实也是一个有风险的过程.能做备份就做好备份. 如果有其他空闲设备, 用 dd 命令把该设备上的内容备份起来.
3 一般来说, 超级块错基本上也就是主超级块错, 在 Ext2/Ext3 文件系统创建的时候, 会同时在屏幕上提示我们在已经在几个地方备份了超级块.那么怎么发现这些超级块在什么地方呢? 我们看看帮助信息:
-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 loca-
tion 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 spec-
ifies 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.
4 开始恢复.如果文件系统块大小为1K, 则我们可以用如下命令恢复:
# /sbin/fsck.ext3 -b 8193 /dev/hda4
如果这个备用块(8193)也有问题,那么 可以尝试 24577(8192*3+1) ,或者是 40961 (8192*5+1).
原文作者: Fenng    编辑:
linux数据恢复
中心


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/82831/showart_1959561.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP