我發現自己的系統磁碟處於一種奇怪的情況。它是具有 3 個分割區的 Linux 系統,引導分割區、交換分割區和檔案系統(ext4)。幾天前,我使用了 Pendrive 中的 knoppix(我自己從 knoppix 映像製作了可啟動 USB 驅動器),因為我想檢查一個不可讀的磁碟……我發現自己有 2 個不可讀的磁碟!
當我重新啟動系統時,我開始在螢幕上出現以下錯誤:
error: failure reading sector ... from 'hd0'.
經過幾次嘗試後我得到了 grub shell。
我用 Linux Mint 創建了另一個可啟動棒,並嘗試看看出了什麼問題。
當使用“磁碟”工具檢查磁碟時,它說磁碟沒問題,但有 8 個壞扇區(我不確定它們之前是否存在),檔案系統分割區在那裡,但資料分割區的類型未知。我嘗試運行testdisk。它找到了分割區,一旦我檢查了超級區塊並設定了檔案系統類型(ext4),我就可以看到 testdisk 本身的數據,但仍然無法掛載分割區。
Testdisk 建議執行 e2fsck -p -b 並且我嘗試了 testdisk 給我的所有超級區塊,但每次 fsck 嘗試修復某些內容時都會以磁碟寫入錯誤結束。
此時已經很晚了,所以我放棄了過夜,但有點放心,數據仍然可讀第二天,令我驚訝的是,資料不再存在了,可能運行一些fsck 會讓事情變得更糟,因為testdisk 不再給我任何超級區塊編號(而且無論我嘗試什麼,我都無法再看到testdisk 中的文件),如果我嘗試使用我之前獲得的數字(我已保存它們)運行 fsck,則
Bad magic number in super-block while trying to open /dev/sda3
無論數字如何此時,我用safecopy 製作了一個圖像(我承認,我應該作為第一件事做,但我有點驚慌,所以我沒有考慮這一點)並複製它,以便我可以測試不同的解決方案,製作一個新副本從每次我到達我不喜歡的點時開始的圖像
我嘗試過的所有方法都沒有幫助。我發現建議使用 mkfs 和 -S 選項,這樣它只會重建超級區塊,但是當我嘗試這樣做並隨後對其運行 fsck (按照工具的建議)時,它會讓我再次訪問分區,但是該分區將完全是空的。空得連 photorec 都找不到資料了(它會在運行 mkfs + fsck 之前在映像上找到資料)。
我在其中一個映像上運行 R-Linux,但它無法恢復任何內容,我擁有的只是名為 $Inode... 的“文件”,但沒有可辨別的文件或目錄結構。
這是結果smartctl -a /dev/sda
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.4.0-58-generic] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Toshiba 2.5" HDD MQ01ABD...
Device Model: TOSHIBA MQ01ABD100
Serial Number: 95CEC91QT
LU WWN Device Id: 5 000039 683983c2b
Firmware Version: AX0R2J
User Capacity: 1,000,204,886,016 bytes [1.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: 5400 rpm
Form Factor: 2.5 inches
Device is: In smartctl database [for details use: -P show]
ATA Version is: ATA8-ACS (minor revision not indicated)
SATA Version is: SATA 3.0, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is: Tue Jun 1 22:30:50 2021 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
General SMART Values:
Offline data collection status: (0x00) Offline data collection activity
was never started.
Auto Offline Data Collection: Disabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 120) seconds.
Offline data collection
capabilities: (0x5b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
No Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 246) minutes.
SCT capabilities: (0x003d) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000b 100 100 050 Pre-fail Always - 0
2 Throughput_Performance 0x0005 100 100 050 Pre-fail Offline - 0
3 Spin_Up_Time 0x0027 100 100 001 Pre-fail Always - 1815
4 Start_Stop_Count 0x0032 100 100 000 Old_age Always - 1377
5 Reallocated_Sector_Ct 0x0033 100 100 050 Pre-fail Always - 8
7 Seek_Error_Rate 0x000b 100 100 050 Pre-fail Always - 0
8 Seek_Time_Performance 0x0005 100 100 050 Pre-fail Offline - 0
9 Power_On_Hours 0x0032 053 053 000 Old_age Always - 19115
10 Spin_Retry_Count 0x0033 127 100 030 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 1368
191 G-Sense_Error_Rate 0x0032 100 100 000 Old_age Always - 275
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 50
193 Load_Cycle_Count 0x0032 100 100 000 Old_age Always - 4455
194 Temperature_Celsius 0x0022 100 100 000 Old_age Always - 30 (Min/Max 13/49)
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 1
197 Current_Pending_Sector 0x0032 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0030 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x0032 200 200 000 Old_age Always - 1
220 Disk_Shift 0x0002 100 100 000 Old_age Always - 0
222 Loaded_Hours 0x0032 053 053 000 Old_age Always - 18889
223 Load_Retry_Count 0x0032 100 100 000 Old_age Always - 0
224 Load_Friction 0x0022 100 100 000 Old_age Always - 0
226 Load-in_Time 0x0026 100 100 000 Old_age Always - 265
240 Head_Flying_Hours 0x0001 100 100 001 Pre-fail Offline - 0
SMART Error Log Version: 1
ATA Error Count: 2032 (device log contains only the most recent five errors)
CR = Command Register [HEX]
FR = Features Register [HEX]
SC = Sector Count Register [HEX]
SN = Sector Number Register [HEX]
CL = Cylinder Low Register [HEX]
CH = Cylinder High Register [HEX]
DH = Device/Head Register [HEX]
DC = Device Command Register [HEX]
ER = Error register [HEX]
ST = Status register [HEX]
Powered_Up_Time is measured from power on, and printed as
DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,
SS=sec, and sss=millisec. It "wraps" after 49.710 days.
Error 2032 occurred at disk power-on lifetime: 19112 hours (796 days + 8 hours)
When the command that caused the error occurred, the device was active or idle.
After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
40 41 38 00 d8 16 40 Error: UNC at LBA = 0x0016d800 = 1497088
Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
60 08 38 00 d8 16 40 00 1d+05:06:46.679 READ FPDMA QUEUED
ef 10 03 00 00 00 a0 00 1d+05:06:46.678 SET FEATURES [Enable SATA feature]
ef 10 02 00 00 00 a0 00 1d+05:06:46.678 SET FEATURES [Enable SATA feature]
27 00 00 00 00 00 e0 00 1d+05:06:46.678 READ NATIVE MAX ADDRESS EXT [OBS-ACS-3]
ec 00 00 00 00 00 a0 00 1d+05:06:46.677 IDENTIFY DEVICE
Error 2031 occurred at disk power-on lifetime: 19112 hours (796 days + 8 hours)
When the command that caused the error occurred, the device was active or idle.
After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
40 41 68 00 d8 16 40 Error: UNC at LBA = 0x0016d800 = 1497088
Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
60 08 68 00 d8 16 40 00 1d+05:06:45.909 READ FPDMA QUEUED
e5 00 00 00 00 00 00 00 1d+05:06:45.669 CHECK POWER MODE
e5 00 00 00 00 00 00 00 1d+05:06:40.669 CHECK POWER MODE
e5 00 00 00 00 00 00 00 1d+05:06:35.670 CHECK POWER MODE
e5 00 00 00 00 00 00 00 1d+05:06:30.669 CHECK POWER MODE
Error 2030 occurred at disk power-on lifetime: 19110 hours (796 days + 6 hours)
When the command that caused the error occurred, the device was active or idle.
After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
40 41 30 00 d8 16 40 Error: UNC at LBA = 0x0016d800 = 1497088
Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
60 00 00 e8 fd de 40 00 1d+02:46:45.118 READ FPDMA QUEUED
60 00 f8 e8 fc de 40 00 1d+02:46:45.117 READ FPDMA QUEUED
60 00 b8 e8 fb de 40 00 1d+02:46:45.116 READ FPDMA QUEUED
60 00 b0 e8 fa de 40 00 1d+02:46:45.116 READ FPDMA QUEUED
60 00 a8 e8 f9 de 40 00 1d+02:46:45.115 READ FPDMA QUEUED
Error 2029 occurred at disk power-on lifetime: 19110 hours (796 days + 6 hours)
When the command that caused the error occurred, the device was active or idle.
After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
40 41 a0 00 d8 16 40 Error: UNC at LBA = 0x0016d800 = 1497088
Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
60 00 08 e8 f8 de 40 00 1d+02:46:44.968 READ FPDMA QUEUED
60 00 00 e8 f7 de 40 00 1d+02:46:44.968 READ FPDMA QUEUED
60 00 f0 e8 f6 de 40 00 1d+02:46:44.966 READ FPDMA QUEUED
60 00 e8 e8 f5 de 40 00 1d+02:46:44.965 READ FPDMA QUEUED
60 00 e0 e8 f4 de 40 00 1d+02:46:44.964 READ FPDMA QUEUED
Error 2028 occurred at disk power-on lifetime: 19110 hours (796 days + 6 hours)
When the command that caused the error occurred, the device was active or idle.
After command completion occurred, registers were:
ER ST SC SN CL CH DH
-- -- -- -- -- -- --
40 41 88 00 d8 16 40 Error: UNC at LBA = 0x0016d800 = 1497088
Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
60 00 a0 e8 e8 de 40 00 1d+02:46:44.792 READ FPDMA QUEUED
60 00 98 e8 e7 de 40 00 1d+02:46:44.791 READ FPDMA QUEUED
60 00 90 e8 e6 de 40 00 1d+02:46:44.788 READ FPDMA QUEUED
60 00 78 e8 e5 de 40 00 1d+02:46:44.787 READ FPDMA QUEUED
60 00 70 e8 e4 de 40 00 1d+02:46:44.786 READ FPDMA QUEUED
SMART Self-test log structure revision number 1
No self-tests have been logged. [To run self-tests, use: smartctl -t]
SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
答案1
最後我意識到,當我使用U 盤上的實時版本時,Knoppix 弄亂了我的分區表,磁碟實際上沒問題(除了一些壞扇區),我嘗試了很多方法來恢復正確的分區,但沒有成功。
正如我在問題和幾條評論中所說,使用 mkfs 允許我重新安裝分區,但沒有數據,顯然這似乎是重建超級塊的唯一方法,但我找不到正確的方法來做到這一點。
經過兩週的嘗試,我決定格式化所有內容並從頭開始,因為無論如何我需要的所有重要資料都儲存在儲存庫中。
答案2
在盲目做某事之前一定要閱讀文檔。man mkfs.ext4
並尋找-S
旗幟,它會告訴你e2fsck
之後必須逃跑。
我懷疑如果您已寫入已儲存的磁碟副本,那麼它現在也已失效。磁碟復原的規則 1 是盡快取得副本。規則 2 是永遠不要寫入您儲存的副本。
我注意到的一件事是您將磁碟 ( /dev/sda
) 與分割區 ( /dev/sda3
) 混淆了。在您確定要運行的地方,mkfs -S /dev/sda
您嘗試在磁碟而不是分割區上重新建立檔案系統。如果你可以還原分區表可能能夠mkfs -S /dev/sda3
成功運行。或透過循環設備進行等效操作。
注意:請不要再嘗試寫入即將失效的磁碟和唯一已儲存的副本。取得副本的新副本並進行處理。