訪問失去超級塊及其備份的 ext4 磁碟
我發現自己的系統磁碟很奇怪。它是具有 3 個分區、引導、交換和文件系統 (ext4) 的 Linux 系統。幾天前,我使用了 pendrive 中的 knoppix(我自己使用 knoppix 映像製作了可啟動的 USB 驅動器),因為我想檢查一個無法讀取的磁碟……我發現自己有 2 個無法讀取的磁碟!
當我重新啟動系統時,我開始出現這樣的螢幕錯誤:
error: failure reading sector ... from 'hd0'.
然後經過幾次嘗試,我得到了 grub 外殼。
- 我用 Linux Mint 創建了另一個可啟動棒,我試圖看看出了什麼問題。
當使用“磁碟”工具檢查磁碟時,它說磁碟沒問題,但有 8 個壞扇區(我不確定它們以前是否存在),文件系統分區在那裡,但數據分區的類型未知。 2. 我嘗試執行 testdisk。它找到了分區,一旦我檢查了超級塊並設置了文件系統類型(ext4),我就可以看到來自 testdisk 本身的數據,但仍然無法掛載分區。 3. Testdisk 建議執行 e2fsck -p -b 並且我嘗試了 testdisk 給我的所有超級塊,但是每次 fsck 嘗試修復某些東西時,它都會以磁碟寫入錯誤結束。
此時已經很晚了,所以我放棄了過夜,但有點放心,數據仍然可讀 4. 第二天,我驚訝地發現數據不存在了,可能是一些 fsck 執行讓事情變得更糟,因為 testdisk 不再給我任何超級塊編號(而且無論我嘗試什麼,我都無法再看到來自 testdisk 的文件),如果我嘗試使用之前獲得的數字執行 fsck(我已經保存了它們),
Bad magic number in super-block while trying to open /dev/sda3
無論數字如何,我都會得到 5. 在這一點上,我用 safecopy 製作了一個圖像(我承認,我應該首先做,但我有點驚慌,所以我沒有考慮這一點)並複制它,以便我可以測試不同的解決方案,製作一個新副本每次我到達一個我不喜歡的點時,從起始圖像開始 6. 我嘗試過的所有事情都沒有幫助。我發現了一個使用帶有 -S 選項的 mkfs 的建議,這樣它只會重建超級塊,但是當我嘗試這樣做並隨後在其上執行 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.
最後我意識到,當我使用 U 盤中的 live 版本時,Knoppix 搞砸了我的分區表,磁碟實際上是好的(除了一些壞扇區),我嘗試了很多方法來恢復正確的分區但沒有利用。
正如我在我的問題和幾條評論中所說,使用 mkfs 允許我重新掛載分區但沒有數據,顯然這似乎是重建超級塊的唯一方法,但我找不到合適的方法來做到這一點。
經過 2 週的嘗試,我決定格式化所有內容並從頭開始,因為我需要的所有重要數據都儲存在儲存庫中。