lan*_*oni 8 osx filesystems data-recovery hard-disk hfs+
我有一个带有HFS+分区的朋友的 Mac OS X 磁盘。我应该从这个磁盘恢复个人数据,我还不确定文件系统是否已损坏或磁盘是否正在死亡)。
背景:完整的症状如下。该驱动器被 Linux 识别,甚至被自动挂载(Xfce在此处使用):
liv@liv-HP-Compaq-dc7900:~$ cat /etc/mtab | grep -i hfs
/dev/sdb2 /media/Macintosh\040HD hfsplus ro,nosuid,nodev,uhelper=udisks 0 0
Run Code Online (Sandbox Code Playgroud)
内核报告如下:
[ 4382.681310] usb 2-5: USB disconnect, device number 2
[ 4390.104044] usb 2-5: new high-speed USB device number 3 using ehci_hcd
[ 4390.259178] Initializing USB Mass Storage driver...
[ 4390.259983] scsi6 : usb-storage 2-5:1.0
[ 4390.260077] usbcore: registered new interface driver usb-storage
[ 4390.260079] USB Mass Storage support registered.
[ 4391.260684] scsi 6:0:0:0: Direct-Access ASMT 2105 0 PQ: 0 ANSI: 6
[ 4391.261346] sd 6:0:0:0: Attached scsi generic sg2 type 0
[ 4391.494924] sd 6:0:0:0: [sdb] 488397168 512-byte logical blocks: (250 GB/232 GiB)
[ 4391.495668] sd 6:0:0:0: [sdb] Write Protect is off
[ 4391.495672] sd 6:0:0:0: [sdb] Mode Sense: 43 00 00 00
[ 4391.496551] sd 6:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 4391.560091] sdb: sdb1 sdb2
[ 4391.565039] sd 6:0:0:0: [sdb] Attached SCSI disk
[..]
[10376.614742] hfs: Filesystem was not cleanly unmounted, running fsck.hfsplus is recommended. mounting read-only.
[10380.531230] sd 6:0:0:0: [sdb] Unhandled sense code
[10380.531234] sd 6:0:0:0: [sdb] Result: hostbyte=invalid driverbyte=DRIVER_SENSE
[10380.531239] sd 6:0:0:0: [sdb] Sense Key : Medium Error [current]
[10380.531243] sd 6:0:0:0: [sdb] Add. Sense: Unrecovered read error
[10380.531253] sd 6:0:0:0: [sdb] CDB: Read(10): 28 00 00 1e 22 e8 00 00 08 00
[10380.531259] end_request: critical target error, dev sdb, sector 1975016
[10380.531264] Buffer I/O error on device sdb2, logical block 195672
[10384.353981] sd 6:0:0:0: [sdb] Unhandled sense code
[10384.353985] sd 6:0:0:0: [sdb] Result: hostbyte=invalid driverbyte=DRIVER_SENSE
[10384.353990] sd 6:0:0:0: [sdb] Sense Key : Medium Error [current]
[10384.353995] sd 6:0:0:0: [sdb] Add. Sense: Unrecovered read error
[10384.354004] sd 6:0:0:0: [sdb] CDB: Read(10): 28 00 00 1e 22 e8 00 00 08 00
[10384.354011] end_request: critical target error, dev sdb, sector 1975016
[10384.354015] Buffer I/O error on device sdb2, logical block 195672
Run Code Online (Sandbox Code Playgroud)
这是来自的相关输出lshw:
*-scsi
physical id: 3
bus info: usb@2:5
logical name: scsi7
capabilities: emulated scsi-host
configuration: driver=usb-storage
*-disk
description: SCSI Disk
product: 2105
vendor: ASMT
physical id: 0.0.0
bus info: scsi@7:0.0.0
logical name: /dev/sdb
version: 0
serial: 00000000000000000000
size: 232GiB (250GB)
capabilities: gpt-1.00 partitioned partitioned:gpt
configuration: ansiversion=6 guid=6b43402b-9887-4a33-a329-9801b59ccdc7
*-volume:0
description: Windows FAT volume
vendor: BSD 4.4
physical id: 1
bus info: scsi@7:0.0.0,1
logical name: /dev/sdb1
version: FAT32
serial: 70d6-1701
size: 199MiB
capacity: 199MiB
capabilities: boot fat initialized
configuration: FATs=2 filesystem=fat label=EFI name=EFI System Partition
*-volume:1
description: Apple HFS partition
vendor: Mac OS X (fsck)
physical id: 2
bus info: scsi@7:0.0.0,2
logical name: /dev/sdb2
version: 4
serial: d9a741cc-8313-cc78-0000-000000800000
size: 232GiB
capabilities: journaled bootable osx hfsplus initialized
configuration: boot=osx checked=2009-09-24 02:29:07 created=2009-09-23 17:29:07 filesystem=hfsplus lastmountedby=fsck modified=2013-11-03 01:02:00 name=Customer state=unclean
Run Code Online (Sandbox Code Playgroud)
当我打开驱动器Thunar,我收到以下错误信息:"Failed to open directory "Macintosh HD". Error when getting information for file '/media/Macintosh HD/.journal': Input/output error."(我可以访问安装点和一些子目录,不过,如果我使用emelFM2。)

如果我尝试ls挂载点,我会收到一堆 I/O 错误:
liv@liv-HP-Compaq-dc7900:/media/Macintosh HD$ ls -lha
ls: cannot access .hotfiles.btree: Input/output error
ls: cannot access .journal: Input/output error
ls: cannot access .journal_info_block: Input/output error
ls: cannot access .Spotlight-V100: Input/output error
ls: cannot access .Trashes: Input/output error
ls: cannot access home: Input/output error
ls: cannot access libpeerconnection.log: Input/output error
ls: cannot access net: Input/output error
ls: reading directory .: Input/output error
total 20M
drwxrwxr-t 1 root 80 35 Oct 13 22:56 .
drwxr-xr-x 3 root root 4.0K Jan 16 21:09 ..
drwxrwxr-x 1 root 80 53 Oct 18 22:07 Applications
drwxr-xr-x 1 root root 39 Sep 26 00:51 bin
drwxrwxr-t 1 root 80 2 Jul 9 2009 cores
dr-xr-xr-x 1 root root 2 Jul 9 2009 dev
-rw-rw-r-- 1 501 80 16K Sep 8 14:19 .DS_Store
lrwxr-xr-x 1 root root 11 Sep 24 2009 etc -> private/etc
---------- 1 root 80 0 Jul 9 2009 .file
drwx------ 1 99 99 246 Nov 3 00:29 .fseventsd
lrwxr-xr-x 1 root 80 60 Mar 20 2010 Guides de l’utilisateur et informations -> /Library/Documentation/User Guides and Information.localized
dr-xr-xr-t 1 root root 2 Sep 24 2009 .HFS+ Private Directory Data?
d????????? ? ? ? ? ? home
-????????? ? ? ? ? ? .hotfiles.btree
-????????? ? ? ? ? ? .journal
-????????? ? ? ? ? ? .journal_info_block
-????????? ? ? ? ? ? libpeerconnection.log
drwxrwxr-t 1 root 80 58 Mar 27 2013 Library
drwxrwxrwt 1 root root 4 Sep 18 2012 lost+found
-rw-r--r-- 1 root root 20M Jun 8 2011 mach_kernel
d????????? ? ? ? ? ? net
drwxr-xr-x 1 root root 2 Jul 9 2009 Network
drwxr-xr-x 1 501 80 3 Oct 26 2010 opt
drwxr-xr-x 1 root root 6 Sep 24 2009 private
drwxr-xr-x 1 root root 67 Sep 26 00:52 sbin
d????????? ? ? ? ? ? .Spotlight-V100
drwxr-xr-x 1 root root 4 Jul 3 2011 System
lrwxr-xr-x 1 root root 11 Sep 24 2009 tmp -> private/tmp
d????????? ? ? ? ? ? .Trashes
drwxr-xr-x 1 root root 2 May 18 2009 .vol
-rw-r--r-- 1 501 80 70K Jun 26 2013 .VolumeIcon.icns
Run Code Online (Sandbox Code Playgroud)
最后,我已经尝试安装hfsprogs并运行fsck.hfsplus,但运气不佳:
root@liv-HP-Compaq-dc7900:/home/liv# fsck.hfsplus -q /dev/sdb2
** /dev/sdb2
QUICKCHECK ONLY; FILESYSTEM DIRTY
root@liv-HP-Compaq-dc7900:/home/liv# fsck.hfsplus -d /dev/sdb2
** /dev/sdb2
Using cacheBlockSize=32K cacheTotalBlock=1024 cacheSize=32768K.
** Checking HFS Plus volume.
Invalid B-tree node size
(8, 0)
** Volume check failed.
volume check failed with error 7
volume type is pure HFS+
primary MDB is at block 0 0x00
alternate MDB is at block 0 0x00
primary VHB is at block 2 0x02
alternate VHB is at block 487725342 0x1d12191e
sector size = 512 0x200
VolumeObject flags = 0x07
total sectors for volume = 487725344 0x1d121920
total sectors for embedded volume = 0 0x00
Run Code Online (Sandbox Code Playgroud)
问题:根据上面的错误消息,是文件系统损坏还是驱动器出现故障?如何修复损坏的文件系统?如果这不是问题,我如何从部分出现故障的磁盘中恢复用户数据?
更新1:
鉴于我从“smartctl -d”选项中获得的有用输入,我应该在这个硬盘上使用“scsi”还是“ata”?,我现在设法smartctl在硬盘上成功运行:
root@liv-HP-Compaq-dc7900:/home/liv# smartctl -d sat -H -i -c -A -l error -l selftest -l selective '/dev/sdb'
smartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.2.0-57-generic] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net
=== START OF INFORMATION SECTION ===
Device Model: TOSHIBA MK2555GSXF
Serial Number: 10J9SA69S
LU WWN Device Id: 5 000039 245a067fd
Firmware Version: FH205B
User Capacity: 250,059,350,016 bytes [250 GB]
Sector Size: 512 bytes logical/physical
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 8
ATA Standard is: Exact ATA specification draft version not indicated
Local Time is: Fri Jan 17 18:02:43 2014 CET
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
[..]
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 - 1031
4 Start_Stop_Count 0x0032 100 100 000 Old_age Always - 16237
5 Reallocated_Sector_Ct 0x0033 100 100 050 Pre-fail Always - 18
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 081 081 000 Old_age Always - 7987
10 Spin_Retry_Count 0x0033 253 100 030 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 5274
191 G-Sense_Error_Rate 0x0032 100 100 000 Old_age Always - 1119
192 Power-Off_Retract_Count 0x0032 084 084 000 Old_age Always - 8196
193 Load_Cycle_Count 0x0032 037 037 000 Old_age Always - 635340
194 Temperature_Celsius 0x0022 100 100 000 Old_age Always - 25 (Min/Max 7/49)
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 3
197 Current_Pending_Sector 0x0032 100 100 000 Old_age Always - 124
198 Offline_Uncorrectable 0x0030 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x0032 200 253 000 Old_age Always - 0
220 Disk_Shift 0x0002 100 100 000 Old_age Always - 57
222 Loaded_Hours 0x0032 087 087 000 Old_age Always - 5415
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 - 346
240 Head_Flying_Hours 0x0001 100 100 001 Pre-fail Offline - 0
254 Free_Fall_Sensor 0x0032 100 100 000 Old_age Always - 8107
SMART Error Log Version: 1
ATA Error Count: 1210 (device log contains only the most recent five errors)
[..]
Error 1210 occurred at disk power-on lifetime: 7984 hours (332 days + 16 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 51 08 e8 22 1e 40 Error: UNC 8 sectors at LBA = 0x001e22e8 = 1975016
Commands leading to the command that caused the error were:
CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
-- -- -- -- -- -- -- -- ---------------- --------------------
25 da 08 e8 22 1e 40 00 00:08:36.484 READ DMA EXT
25 da 08 e8 22 1e 40 00 00:08:32.637 READ DMA EXT
25 da 08 00 66 22 40 00 00:08:32.637 READ DMA EXT
25 da 08 f8 65 22 40 00 00:08:32.625 READ DMA EXT
25 da 08 50 c3 28 40 00 00:08:32.625 READ DMA EXT
[..]
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.
Run Code Online (Sandbox Code Playgroud)
我不知道如何解析这个输出,但有两件事让我眼前一亮:
SMART overall-health self-assessment test result: PASSEDATA Error Count: 1210 (device log contains only the most recent five errors)那么它有多糟糕?我应该如何进行?
更新2:
按照评论中的建议,我使用 Mac OS X 运行diskutil verifyVolume:
mac:~ admin$ diskutil list
[..]
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *250.1 GB disk1
1: EFI 209.7 MB disk1s1
2: Apple_HFS Macintosh HD 249.7 GB disk1s2
mac:~ admin$ diskutil verifyVolume /dev/disk1s2
Started filesystem verification on disk1s2 Macintosh HD
Checking Journaled HFS Plus volume
Invalid B-tree node size
The volume Macintosh HD could not be verified completely
Error: -9957: Filesystem verify or repair failed
Underlying error: 8: POSIX reports: Exec format error
Run Code Online (Sandbox Code Playgroud)
并且fsck:
mac:~ admin$ fsck -d /dev/disk1s2
** /dev/rdisk1s2
BAD SUPER BLOCK: MAGIC NUMBER WRONG
LOOK FOR ALTERNATE SUPERBLOCKS? [yn] y
SEARCH FOR ALTERNATE SUPER-BLOCK FAILED. YOU MUST USE THE
-b OPTION TO FSCK TO SPECIFY THE LOCATION OF AN ALTERNATE
SUPER-BLOCK TO SUPPLY NEEDED INFORMATION; SEE fsck(8).
Run Code Online (Sandbox Code Playgroud)
那么,这些错误信息有多糟糕?是驱动吐司吗?
更新3:
我玩了更多,smartctl在我看来(但请确认!!)驱动器绝对是吐司:
# 'smartctl' -d sat,16 -H -i -c -A -l error -l selftest -l selective '/dev/sdb'
smartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.2.0-57-generic] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net
=== START OF INFORMATION SECTION ===
Device Model: TOSHIBA MK2555GSXF
Serial Number: 10J9SA69S
LU WWN Device Id: 5 000039 245a067fd
Firmware Version: FH205B
User Capacity: 250,059,350,016 bytes [250 GB]
Sector Size: 512 bytes logical/physical
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 8
ATA Standard is: Exact ATA specification draft version not indicated
Local Time is: Mon Jan 27 15:20:57 2014 CET
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: FAILED!
Drive failure expected in less than 24 hours. SAVE ALL DATA.
See vendor-specific Attribute list for failed Attributes.
General SMART Values:
Offline data collection status: (0x00) Offline data collection activity
was never started.
Auto Offline Data Collection: Disabled.
Self-test execution status: ( 88) The previous self-test completed having
the electrical element of the test
failed.
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: ( 90) minutes.
SCT capabilities: (0x0039) 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 - 1025
4 Start_Stop_Count 0x0032 100 100 000 Old_age Always - 1
5 Reallocated_Sector_Ct 0x0033 100 100 050 Pre-fail Always - 0
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 100 100 000 Old_age Always - 0
10 Spin_Retry_Count 0x0033 100 100 030 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 1
191 G-Sense_Error_Rate 0x0032 100 100 000 Old_age Always - 0
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 0
193 Load_Cycle_Count 0x0032 100 100 000 Old_age Always - 3
194 Temperature_Celsius 0x0022 100 100 000 Old_age Always - 27 (Min/Max 26/30)
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
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 253 000 Old_age Always - 0
220 Disk_Shift 0x0002 100 100 000 Old_age Always - 57
222 Loaded_Hours 0x0032 100 100 000 Old_age Always - 0
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 - 353
240 Head_Flying_Hours 0x0001 001 001 001 Pre-fail Offline FAILING_NOW 3
254 Free_Fall_Sensor 0x0032 100 100 000 Old_age Always - 0
Error SMART Error Log Read failed: scsi error badly formed scsi parameters
Smartctl: SMART Error Log Read Failed
Error SMART Error Self-Test Log Read failed: scsi error badly formed scsi parameters
Smartctl: SMART Self Test Log Read Failed
Error SMART Read Selective Self-Test Log failed: scsi error badly formed scsi parameters
Smartctl: SMART Selective Self Test Log Read Failed
Run Code Online (Sandbox Code Playgroud)
我可以单挑:
SMART overall-health self-assessment test result: FAILED! Drive failure expected in less
看来我发现这个帖子太晚了,但对于这个帖子的未来读者:
在进行数据救援时,您的第一步应该是使用 dd 或类似的东西制作驱动器的完整映像(cloneZilla 是一种流行的选择)。
换句话说,按原样获取驱动器的印记,以便在尝试挽救数据时不会进一步损坏卷。
根据第一个智能日志,您可能有 124 个坏扇区——这部分:
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 3
197 Current_Pending_Sector 0x0032 100 100 000 Old_age Always - 124
Run Code Online (Sandbox Code Playgroud)
您应该执行全面扫描以确定实际数量。有些文件肯定已损坏。这就是为什么你有 Error Count: 1210 ,每次读取损坏的扇区时,你都会得到 +1 错误。如果您想让磁盘正常工作,则必须向这些扇区写入零,因为只有在写入扇区时才能重新定位这些扇区。我无法告诉你如何操作 hfs 文件系统,因为我从未使用过它。如果您有 ext4,您可以使用带有以下选项的 fsck:
-c Check for bad blocks and add them to the badblock list
-l bad_blocks_file Add to badblocks list
Run Code Online (Sandbox Code Playgroud)
因此,您可以获得所有坏块的列表,然后您可以知道它们的位置,这可以帮助估计坏块是否损坏了常规文件或其他内容。我正在使用debugfs. 然后您可以通过以下方式向这些扇区写入零:
# hdparm --yes-i-know-what-i-am-doing --write-sector 104284160 /dev/sdb
Run Code Online (Sandbox Code Playgroud)
并删除损坏的文件。
从您提供的日志来看:
ls: cannot access .hotfiles.btree: Input/output error
ls: cannot access .journal: Input/output error
ls: cannot access .journal_info_block: Input/output error
ls: cannot access .Spotlight-V100: Input/output error
ls: cannot access .Trashes: Input/output error
ls: cannot access home: Input/output error
ls: cannot access libpeerconnection.log: Input/output error
ls: cannot access net: Input/output error
ls: reading directory .: Input/output error
Run Code Online (Sandbox Code Playgroud)
您知道哪些文件已损坏。
接下来是以下参数的值:
193 Load_Cycle_Count 0x0032 037 037 000 Old_age Always - 635340
Run Code Online (Sandbox Code Playgroud)
这会杀死你的磁盘,或者已经杀死它。例如,我的磁盘的使用寿命为 500k。当它达到 350k 时我发现了这一点...最终,我在磁盘固件中禁用了此功能,并且到目前为止它仍然有效。
接下来是文件系统超级块。对于这种情况,您应该对该块进行复制,并且在删除坏块后,您可以恢复超级块。如果超级块损坏,并且您没有备份,或者您不记得备份扇区的位置,则将无法恢复数据。尝试使用:
# file -s /dev/sdb1
# file -s /dev/sdb
Run Code Online (Sandbox Code Playgroud)
但是您可以读取文件系统(ls 命令),所以它并没有那么糟糕,我认为在删除坏块并删除一些文件后,一切都应该没问题。
| 归档时间: |
|
| 查看次数: |
104159 次 |
| 最近记录: |