All pastes #2050604 Raw Edit

nasty LVM hacks

public text v1 · immutable
#2050604 ·published 2011-04-25 20:17 UTC
rendered paste body
Broken_raid

how to go from mirroring raid to LVM on mirroring raid on the fly

1/ remove one of the drives from the raid we wish to migrate from
2/ build a new mirroring raid with 1 drive and one missing. edit /etc/mdadm.conf
3/ set-up LVM stuff, format LVM's etc
4/ mount lvm tree some place
5/ copy everything across cp -ax is probably what you want
6/ check SElinux contexts, if selinix is enforcing then the selinux dir will not have copied
7/ edit fstab on new file system to reflect new layout
8/ edit grub, just one entry for now..
9/ make a new initrd file, this is important so that the initrd reflects the new root and also has the right drivers in there. bad things happen if not done

# mkinitrd --fstab=/mnt/newfs/etc/fstab --force-raid-probe --force-lvm-probe /boot/initrd-2.6.18-53.el5.img 2.6.18-53.el5

10/ check new initrd for any surprises, particularly missing device drivers or wrong root reference.
to unpack to a dir, make a dir then # gunzip </boot/initrd |cpio -i
11/ mark new drive for a new selinux labelling session. Issue a touch /mnt/newfs/.autorelable cp -ax should have copied the contexts but this is probably no harm on a new system 
12/ reboot (& hope..) if all good then remove old raid device & add that drive to the new running raid. edit /etc/mdadm.conf
13/ wait for rebuild
14/reboot again, if all is good then you are done (perhaps new initrd for other kernels and a grub.conf tidy