# Crashed hard drive



## Hornpipe2 (Jun 11, 2012)

HD crash.  Normally I wouldn't care, but it looks like I missed a spot in my backup plan: my MySQL DB, web root, and SCM repo are on the drive with no copy anywhere else.  Time to break out the usual tools and see what has survived.

Insert FreeBSD 9.0 net-install CD
Make a fakeroot to install pkg_add stuff, 
`mkdir /tmp/fakeroot`
Get ddrescue
`cd /tmp/fakeroot`
`pkg_add -P `pwd` -r ddrescue`
Mount second hard drive to store disk image
`mkdir -p mnt/nas`
`mount -t ufs /dev/ada0s1d mnt/nas`
Begin the rescue operation
`cd bin`
`./ddrescue -R --max-retries=3 /dev/ada1 ../mnt/nas/ada1.bin ../mnt/nas/ada1.log`
(wait 4 hours)
As usual, ddrescue does a fantastic job: everything's golden except for about 80kb of unreadable data near the front of the disk.  Clicking noises when trying to access that portion seems to indicate I'm not likely to get that back 

Now, I need to get that data off the image.  If possible, I'd like to rebuild / recover the partition table, and then mount it (loopback), and then scp the important data to another machine for safekeeping.

But the next step eludes me: I now have a disk image, but neither fdisk nor gpart want to tell me about it.  In fact it doesn't seem to want to operate on anything but a (real) disk device, out in /dev somewhere.


```
> fdisk ./ada1.bin
fdisk: unable to get correct path for ./ada1.bin: Inappropriate file type or format
```

What am I missing?  BTW here is output from fdisk on the "real" ada1 drive:


```
*** Working on device /dev/ada1 ***
parameters extracted from in-core disklabel are:
cylinders=79656 heads=16 sectors/track=63 (1008 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=79656 heads=16 sectors/track=63 (1008 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 238 (0xee),(EFI GPT)
    start 1, size 80293247 (39205 Meg), flag 80 (Active)
        beg: cyl 0/ head 0/ sector 2;
        end: cyl 1023/ head 255/ sector 63
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>
```

And for gpart:

```
gpart show /dev/ada1
=>       34  80293181  ada1  GPT  (38G)
         34       128     1  freebsd-boot  (64k)
        162  75497344     2  freebsd-ufs   (36G)
   75497506   4014080     3  freebsd-swap  (1.9G)
   79511586    781629        - free -      (381M)
```

In any case, given this info, I should have enough to mount it, right?


----------



## kpa (Jun 11, 2012)

mdconfig(8). For example:

`# mdconfig -a -t vnode -f ada1.bin`
`# gpart show md0`


----------



## wblock@ (Jun 11, 2012)

-a and -t are implied by -f, so that can be just
`# mdconfig -f ada1.bin`


----------



## jb_fvwm2 (Jun 12, 2012)

FWIW, I once saved 98 percent of the files from a crashed drive by putting it in the freezer for a half hour between 3-minute copy-files-off (It warms up while powered up and the files disappear again...).  Twice since then, the process has failed (those latter drives crashed more drastically).


----------



## Hornpipe2 (Jun 12, 2012)

Thanks for the tips.  I was able to use mdconfig to mount the rescued image.  Bad news: the drive I stored the image to *also* has errors.  I did notice the first drive was really warm when I pulled it out originally and the second drive sat practically on top of it.  Maybe the one burned up and took out the other as well.

Now I've got a shiny new 500GB drive to recover to, with a desk fan on full blast pointed at them to keep them cool.

The freezer trick didn't work for me: when I pulled it out of the freezer, condensation collected on the drive, and I actually ended up with more errors until it dried out.  Be careful!


----------



## Beastie (Jun 12, 2012)

Hornpipe2 said:
			
		

> when I pulled it out of the freezer, condensation collected on the drive


Two very useful items:

 zipper storage bags
 adhesive tape


----------



## jb_fvwm2 (Jun 12, 2012)

Forgot to mention that I had it wrapped in paper towels and those secured with rubber bands.


----------

