Linux下恢复EXT3 Superblock的正确方法
创始人
2024-04-30 12:01:19
0

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 locaion 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 specifies 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).

可能您也会看出来,超级块的保存位置是按照 1,3,5,7 这样的规律的. 具体的位置在 BlockSize(8192)*N 1. 在超过 500M 的空间上是这样的规律.小于 500M 的我不知道.那位知道告诉我一下,谢谢。

【编辑推荐】

  1. 修改Linux系统下22端口的两种方法
  2. Linux下使用网站主机作为加密代理服务器
  3. Mac和Linux将面临新的漏洞攻击

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...
德国电信门户网站可实时显示全球... 德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...
为啥国人偏爱 Mybatis,... 关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...
《非诚勿扰》红人闫凤娇被曝厕所... 【51CTO.com 综合消息360安全专家提醒说,“闫凤娇”、“非诚勿扰”已经被黑客盯上成为了“木...
2012年第四季度互联网状况报... [[71653]]  北京时间4月25日消息,据国外媒体报道,全球知名的云平台公司Akamai Te...