Ubuntu: Add disk and use software raid



Question:

I have a lvm partition on a disk, and another, identical drive with no data on it.

Would it be possible to set up these two drives in RAID 1 using mdadm, with the same lvm data on top?

Perhaps by creating a RAID array that's missing a drive, copying all of the data from the partition over to it, and then formatting the partition, and adding it to the array?


Solution:1

Yes, you can do it this way. For example (when you have sda with parition sda2 which is PV in VG space:

  1. create new raid with missing device and add it to vg

    mdadm --create /dev/md1 --level raid1 --raid-devices=2 /dev/sdb2 missing pcreate /dev/md1 vgextend space /dev/md1

  2. move existing volume to md1:

    pvmove -v /dev/sda2 /dev/md1

  3. when it finish, reduce VG and add sda2 to array:

    vgreduce space /dev/sda2 mdadm -a /dev/md1 /dev/sda2

remember to add array to mdadm.conf (mdadm -E --scan >>/etc/mdadm/mdadm.conf) and add it to initrd when it's needed (for example when root is on lvm)


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »