0

I'd like to image my software RAID5 configuration (3 drives), then move it to a new set of hard drives. Since CloneZilla doesn't support software RAID, I was hoping to do the following:

  1. Create an image of each device using CloneZilla on an external HDD (from /dev/sda/ to sda.img and likewise for sdb and sdc).

  2. Connect the new hard drives to the machine.

  3. Restore each image to a respective device using Clonezilla (from sda.img to the new /dev/sda and likewise for sdb and sdc)

  4. Create a new RAID5 from sda, sdb, sdc using mdadm.

Would this procedure work? I'm concerned about whether taking an image of the drives individually would allow it to work with a new RAID.

0
0

You may clone the hard drives like you were thinking, but I recommend removing CloneZilla from the equation entirely.

Here's how I think you should go about doing this:

  1. Make sure you keep track of which drives are the old ones and which are new, and which disk image is from which drive.
  2. Absolutely make sure that the md device is unmounted and stopped! Assuming it is /dev/md0, do (as root) umount /dev/md0 then mdadm --stop /dev/md0.
  3. Ensure that there is a filesystem on your external hard drive and mount it. I will use /mnt as the mountpoint for my demonstration.
  4. Ensure that you have the xz compressor available. If you don't, you may use gzip, but make sure to replace xz with gzip in commands and use .gz files instead of .xz!
  5. For each drive, run (in a root shell) cat /dev/sdX | xz > /mnt/sdY.img.xz. /dev/sdX would be the drive that you're cloning from, and sdY.img.xz is the name of the image that we will be creating. Make sure that you replace sdX with the appropriate drive (e.g. /dev/sda) and name your image respectively. (for the first drive cloned, name it sd1.img.xz). As I would imagine your external drive would get filled rather quickly, you should probably do step 4 and return to step 3 for the next drive. This way the external drive would serve as a buffer for only one hard drive instead of all of the ones in the array.
  6. Now we want to restore the drive(s). When you have your external hard drive mounted and your new drive(s) connected, run (in a root shell) cat /mnt/sdY.img.xz | xz -d > /dev/sdX where sdY.img.xz is your disk image and /dev/sdX is the new drive you would like to clone to.
  7. Now you should have two copies of each drive, so we need to make sure that mdadm doesn't get confused over which drive is which. We can do this by overwriting the old drives, but we will just overwrite the first 64 MiB to ensure that all of the superblocks and partition tables are gone. For each of the old drives do (as root!) dd if=/dev/zero of=/dev/sdX bs=4M count=8. If you wish to overwrite the drive completely (likely to securely erase its contents), you may do cat /dev/zero > /dev/sdX as root instead.
  8. Now you should only have one copy of each drive, all on the new drives! mdadm should see them the same way, so you shouldn't have to do any re-configuring.
4
  • Thanks John. I'll bring this approach to the man in charge and well try it out.
    – Voriki
    Nov 14 '16 at 3:22
  • Are you really suggesting that at step 4 you byte-copy a disk that's in use? This is really asking for trouble; even more so when you need to repeat this for three parts of a RAID5 array. Your entire process needs to be perfomed from a Live or Rescue disk - which you've omitted to mention anywhere. And if you're going to do that you might as well just clone the RAID md device itself.
    – roaima
    Nov 14 '16 at 8:55
  • @roaima you're absolutely right about byte copying a drive that's in use, so I changed step 2. However, cloning the md device would require a reconfiguration of the array. Not to mention he might not have an external drive large enough to store the entire array. Nov 14 '16 at 12:51
  • @JohnLeuenhagen So we ended up rsyncing a backup to the external drive, replacing the RAID, then rsyncing back. This seemed like the simpler approach. I've marked this as correct though because it's a great answer.
    – Voriki
    Nov 24 '16 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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