uechi.io/_posts/2018-02-15-data-recovery.markdown

52 lines
1.8 KiB
Markdown
Raw Normal View History

2018-02-15 13:24:45 +09:00
---
2018-02-15 13:36:47 +09:00
title: Guide to recover data from damaged HDD
2018-02-15 13:24:45 +09:00
date: 2018-02-15 12:45:00 +09:00
---
This is a complete guide describes how to rescue your data from old and wrecked HDD.
Suppose you are using macOS and your endangered disk is formatted with HFS+.
# Beforehand
## Inspect
2018-08-03 14:06:51 +09:00
2018-02-15 13:32:45 +09:00
Use `diskutil list` to verify that which drive is damaged.
2018-02-15 13:34:31 +09:00
This article assumes that `disk2` is the damaged AND a partition `disk2s2` is what you expected to be rescued. You don't want to save `disk2s1` that is usually EFI partition.
2018-02-15 13:24:45 +09:00
## Damage Control
2018-08-03 14:06:51 +09:00
2018-02-15 13:24:45 +09:00
To prevent extra load, unmount the damaged disk: `diskutil unmountDisk disk2`.
# Rescue
2018-08-03 14:06:51 +09:00
2018-02-15 13:24:45 +09:00
If you never been `ddrescue`, `brew install ddrescue` to install them on your machine.
```bash
cd /Volumes/AnotherDriveLargerThanDamagedDrive
sudo ddrescue -n -v /dev/disk2s2 ./hdimage.dmg ./mapfile
```
So this command will start rescuing your data from `/dev/disk2s2` partition to `hdimage.dmg` while writing log to `mapfile`.
2018-02-15 13:34:31 +09:00
2018-08-03 14:06:51 +09:00
You might want to rescue data as fast as possible. option `-n` is here for. This will skip scraping phase that causes aggressive disk access.
2018-02-15 13:34:31 +09:00
2018-02-15 13:24:45 +09:00
Option `-v` stand for verbose logging.
```bash
sudo ddrescue -r5 -v /dev/rdisk2s2 ./hdimage.dmg ./mapfile
```
When the first command completed, do it again with different parameters to aggressively scrape bad area failed to access the first time.
2018-02-15 13:34:31 +09:00
2018-02-15 13:24:45 +09:00
Option `-r5` means ddrescue will try rescuing damaged area for 5 times.
2018-02-15 13:34:31 +09:00
2018-02-15 13:38:47 +09:00
And `/dev/disk2s2` become `/dev/rdisk2s2` this time. `r` stand for raw so this will access the disk more direct way.
2018-02-15 13:34:31 +09:00
2018-02-15 13:42:05 +09:00
> Beware: You MUST use same `hdimage.dmg` and `mapfile` between two commands. `mapfile` remains information of which blocks were rescued.
2018-02-15 13:24:45 +09:00
# Aftercare
2018-08-03 14:06:51 +09:00
Mount `hdimage.dmg` and copy files and directories to a new drive. If the image is broken, you can recover it using `testdisk`.