Did you ever get anywhere with this?
I just wanted to add that I recently had to do a disk recovery for someone so I wanted to add some notes on that, because if you have a pool without enough redundancy to repair itself, then cloning one of the failed disks may be be your only option after trying everything else.
If you find that one of your disks is consistently failing, you may want to try cloning it onto a new disk of the same size to see if you can get ZFS to accept the clone as a replacement. To do this you'll want to use the tool ddrescue – it's possible to just use the regular dd tool but ddrescue has extra features that make it better for recovering problem drives.
To use ddrescue you'll run the command something like so:
- Code: Select all
ddrescue /dev/diskX /dev/rdiskY ~/Desktop/ddrescue.mapfile
Where /dev/diskX is replaced with the correct path for the failing disk (e.g- /dev/disk4) – you want to use the whole disk device (not a partition) and you want to use the buffered device to reduce the risk of kernel panics (it's just safer for a disk you suspect is failing). Meanwhile /dev/rdiskY is the path for your replacement disk (e.g- /dev/rdisk5) – I'm using the unbuffered (rdiskY instead of diskY) device in this case because it will be a lot faster than buffered writes, and ddrescue tracks its progress so there's limited risk from interruptions. Lastly, the ~/Desktop/ddrescue.mapfile bit tells ddrescue where to store its progress – you want this because ddrescue can take a long time and if it gets interrupted for any reason it can use the mapfile to resume.
Since the clone target is a device, you'll probably need to add the -f flag (ddrescue -f /dev/diskX etc.), but I prefer to keep that off until I've triple checked I've entered the correct devices. You may also want to add the -s flag with the size of the source disk in bytes so you can get an accurate progress reading, you can get the size in bytes using: diskutil info diskX
For safety it is probably best to do this without attempting to import your pool (or restart if you already tried and got stuck), this may make it trickier to work out which disk you need to specify, so triple check you've got the correct source disk (and target replacement disk). And always triple check the device IDs if you ever need to resume ddrescue, as they can change after a restart or disk disconnection.
Once you've cloned the disk (or as much as ddrescue can manage, as there may be sectors it simply cannot read) then you can shutdown, remove the old disk, then try to import your pool with the cloned replacement (ZFS
should recognise it in place of the old disk, but you can try zpool online if it doesn't).