我发现自己的系统磁盘处于一种奇怪的情况。它是具有 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
成功运行。或通过循环设备进行等效操作。
注意:请不要再尝试写入即将失效的磁盘和唯一保存的副本。获取副本的新副本并进行处理。