Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a software RAID5 array with 4 + 1 disks in which 2 of the disks have failed. I'm hoping that with some percussive maintenance, I might get one of the failed disks working again long enough to do a block level copy to get the image off.

The plan would be to make images of 4 (or all 5) of the disks with dd, and then try rebuild the array on those images.

Is there something right off the bat that I've missed that would make this impossible? If not, how would I:

  1. Copy an image of each device to a file
  2. Mount these
  3. Reconfigure mdadm to use these images as the devices

Obviously, there are a lot of things that might have happened that make the data corrupt, but there are reasons to think the actual data might be intact across the 4 disks:

  1. The second disk failure might have been due to power loss
  2. The data I'm interested in recovering wasn't written after the first failure
share|improve this question
2  
Have you considered that at this point it may be simply easier to restore from backup? –  gparent May 27 '13 at 17:11
    
Restoring from backup is not an option. Let's not get into that discussion :) –  pufferfish May 27 '13 at 17:17
2  
Restoring from backup should always be an option, and probably the first option. –  Tom O'Connor May 27 '13 at 17:18
2  
Then again, not everything is backed up every nanosecond on multiple geographically diverse redundant sites, contrary to most people here's belief... –  gparent May 27 '13 at 17:21
2  
You cannot mount the image files. You can put a loop device on top of each and try to make mdadm create an mdraid device from these loop devices. if that does not work there are some tricks for binding the images together without mdadm. You just need to know where the kernel maps the sectors of the MD device. –  Hauke Laging May 27 '13 at 17:50

1 Answer 1

In general, this approach would work. As long as you have working disks (and you do not expect them to fail) you also could use the device mapper to create overlay snapshots instead of fully copying the data off the disks (might be a good thing to have the copies as a backup, though).

Once you have the image files, you would need to create loopback block devices off them

losetup /dev/loopX /path/to/imagefileX

after this is done, you can assemble your array using the loopback block devices. If you can't recover the latest failed disk so timestamps on your redundancy disk image will be differing from the rest, the array would refuse to assemble. As long as you are really only interested in data written before the failures, take a look at the "Recovering a failed software RAID" section of the Kernel RAID documentation. It should help you through to get the array assembled with at least some of the data recoverable.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.