I started with
/ = md0 (sda1, sda2) and
/home = md1 (sda2, sda3).
Then I broke the raid with
mdadm —manage /dev/md0 —fail /dev/sdb1
mdadm —managed /dev/md1 —fail /dev/sdb2.
I then validated that it was possible to use mdadm —zero-superblock /dev/sdb1 and mount e2fsck /dev/sdb1 as a single device directly (with new enough version of md metadata).
On to LVM…
I repartitioned /dev/sdb into one large sdb1 at the 1MB boundary.
mdadm —create /dev/md3 -l1 -n2 /dev/sdb1 mising
pvcreate /dev/md3
vgcreate raid1 /dev/md3
Now I wanted to migrate the existing md0 and md1 to lv root and lv home. Using mdadm -D I could get the KB sive of each md device and feed that into lvcreate.
lvcreate -nroot -L 10490304K raid1
lvcreate -nhome -L 1938828544K raid1
Note the message rounding to the nearest extent size (a few MB). This was able to work because I had removed /dev/sdb3 which was originally for swap space.
Here’s where the interesting part came in…
I now added the lv volumes to md0 and md1.
mdadm —manage /md0 —add /dev/raid1/root
mdadm —manage /md1 —add /dev/raid1/home
Wait for resync…
Now to remove the sda devices from md0 and md1, repartition sda like sdb, and add sda1 to md3.
mdadm —manage /dev/md0 —fail /dev/sda1
mdadm —manage /dev/md1 —fail /dev/sda2
sfdisk /dev/sdb —dump | sfdisk /dev/sda
mdadm —managed /dev/md3 —add /dev/sda1
Wait for resync…
Update mdadm.conf by removing the md0 and md1 lines and append md/3 outputted from this command
mdadm —examine —scan
also comment out DEVICE partitions line so that md0 and md1 don’t come up on this next reboot.
Edit /etc/fstab to change the / and /home mount points to point to the new lvs.
update-initramfs -u
update-grub
Reboot with fingers crossed. It should come up fine with the lvs mounted and only md/3.
Now clear the md0 and md1 superblocks
mdadm —zero-superblock /dev/raid1/root
mdadm —zero-superblock /dev/raid1/home
and put back the DEVICE partitions line in mdadm.conf.
Reboot once more.
Edit: The confusion grub had before rebooting required some repair with the live CD.
Now the two lv filesystems cat be grown to fit the new lv size (rounded up) with resize2fs.
No comments:
Post a Comment