Filesystems
如何從損壞的驅動器中瀏覽 img(恢復失去的數據)
目前我相信我遇到了驅動器 (HDD) 故障。它是用於額外儲存的單個分區驅動器。當我嘗試安裝它時,出現以下錯誤:
# mount /dev/sdc1 /mnt mount: wrong fs type, bad option, bad superblock on /dev/sdc1, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so.
按照建議檢查 dmesg:
# dmesg | tail [12641.405658] blk_update_request: critical medium error, dev sdc, sector 2064 [12641.410139] Buffer I/O error on dev sdc1, logical block 2, async page read [12641.415774] EXT4-fs (sdc1): couldn't mount as ext3 due to feature incompatibilities [12641.420578] EXT4-fs (sdc1): couldn't mount as ext2 due to feature incompatibilities [12644.186523] sd 5:0:0:0: [sdc] tag#0 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [12644.186543] sd 5:0:0:0: [sdc] tag#0 Sense Key : Medium Error [current] [12644.186556] sd 5:0:0:0: [sdc] tag#0 Add. Sense: Unrecovered read error [12644.186570] sd 5:0:0:0: [sdc] tag#0 CDB: Read(10) 28 00 00 00 08 10 00 00 08 00 [12644.186580] blk_update_request: critical medium error, dev sdc, sector 2064 [12644.191255] EXT4-fs (sdc1): can't read group descriptor 1
正如我所說,我假設驅動器將在夜間行駛,所以我想至少保存我在那裡的所有資訊(順便說一句,這是更重要的一面)。我嘗試從驅動器上切下 500GB,看看它是否可以工作:
# ddrescue -d -s 500G /dev/sdc data.img data.log
不幸的是,我在 ssh 上執行它並且我的管道壞了或其他什麼,所以我最終得到了一個 ~150GB 的
img
文件,當我嘗試掛載時,我得到了與嘗試掛載驅動器本身時相同的錯誤(duh):# mount data.img /mnt -o loop mount: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so.
如何獲取應該保存的資訊?
對於發現此問題的任何人,我都設法解決了該問題,而無需求助於
photorec
或其他打撈工具。我製作了一個完整的磁碟映像,以防萬一,ddrescue
但最終不需要它。執行
badblocks
並查看 SMART 數據我確定有 1 個損壞的扇區位於驅動器的開頭某處。顯然它是儲存超級塊的地方,這就是分區無法辨識且無法安裝的原因。我試著跑步
e2fsck -cfpv /dev/sdc1
並得到了e2fsck: Attempt to read block from filesystem resulted in short read while trying to open /dev/sdc1 Could this be a zero-length partition?
我是菜鳥,我不知道發生了什麼,但顯然用零覆蓋該扇區並重新執行
e2fsck
會產生某種魔力並修復分區,之後我能夠安裝分區並複制我之前的所有文件把硬碟扔出窗外。e2fsck
這是我發出的命令(是的,一旦我注意到分區被辨識並且可以掛載,我立即停止了):# dd if=/dev/zero of=/dev/sdc1 bs=4096 count=1 seek=0 1+0 records in 1+0 records out 4096 bytes (4.1 kB, 4.0 KiB) copied, 0.000367146 s, 11.2 MB/s # e2fsck -fy -b 32768 /dev/sdc1 e2fsck 1.46.2 (28-Feb-2021) Superblock needs_recovery flag is clear, but journal has data. Recovery flag not set in backup superblock, so running journal anyway. /dev/sdc1: recovering journal Pass 1: Checking inodes, blocks, and sizes ^C/dev/sdc1: e2fsck canceled. /dev/sdc1: ***** FILE SYSTEM WAS MODIFIED *****
完整的解釋和所有的功勞都歸功於這個人,我希望宇宙向他發送大量的健康和財富,並滿足他最深切的願望!