Windows XP Windows 7 Windows 2003 Windows Vista Windows教程綜合 Linux 系統教程
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟件教程
 Windows教程網 >> Linux系統教程 >> Linux教程 >> 恢復EXT3 Superblock(bad superblock) 的正確方法

恢復EXT3 Superblock(bad superblock) 的正確方法

日期:2017/2/7 14:35:49      編輯:Linux教程
 

前幾天遇到一個 Linux Ext3 文件系統超級塊(Superblock)錯誤問題.

.... bad superblock on /dev/hdc1一個同事做的恢復, 結果把數據都抹掉了. 後來想想, 當時的直接 fsck 的恢復方法不對. 正確的方法應該是這樣的:

1 獲取錯誤的出錯磁盤(或者設備)塊的大小.
有很多種方法可以得到. 比如,
# tune2fs -l /dev/hdc1其實大多數情況下是 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).
 

可能您也會看出來,超級塊的保存位置是按照 1,3,5,7 這樣的規律的. 具體的位置在 BlockSize(8192)*N+1. 在超過 500M 的空間上是這樣的規律.小於 500M 的我不知道.那位知道告訴我一下,謝謝.

Copyright © Windows教程網 All Rights Reserved