Linux – How to attach an existing RAID1 to a fresh Linux system

linuxraidraid1software-raid

I have a RAID1 currently operating on a single hard drive (yes, the mirror is absent). Is it possible to reorganize my system using the following algorithm?

  1. I set up another single-disk RAID1 (onto another HDD of the same type), partition it and install a new instance of Debian on it.
  2. I mount the old single-disk RAID1 setup and copy all the data from it to the new RAID.
  3. I then reformat the old disk and include it into the new RAID setup.

I mostly doubt the second point – how should I do it?

Best Answer

Well, I did it, and it turned out to be quite painless: the old RAID setup was automatically detected as /dev/md0, so all I had to do was mount /dev/md0 /mnt, then copy all the data from it to whereever appropriate.

After that I issued:

mdadm --stop /dev/md0
mdadm --remove /dev/md0
sfdisk -d /dev/sda | sfdisk /dev/sdc
mdadm --add /dev/md1 /dev/sdc1
mdadm --add /dev/md2 /dev/sdc2
mdadm --add /dev/md3 /dev/sdc3

If I understand everything correctly, that was all I needed to do, since mdadm --detail now reports the drives to be actively synced.