Convert / root filesytem to use lvm over raid
Sat, 11/01/2008 - 16:57 — sandipI have outlined below the steps taken to move from a normal single disk system and convert to a raid1 using an additional drive:
Note: /boot cannot be on lvm nor any other raids other than raid1 partition.
Don't forget to make the essential backups prior.
Convert / to raid/lvm
-
fdisk /dev/sdb and make clone of sda (convert partition type to "Linux raid autodetect")
add /dev/sdb1 -- /boot - 13 blocks (100Mb) - type raid
add /dev/sdb2 -- rest - type raid
Create raid partitions:
partprobe
mdadm -C /dev/md0 --auto=yes -l 1 -n 2 missing /dev/sdb1
mdadm -C /dev/md1 --auto=yes -l 1 -n 2 missing /dev/sdb2
pvcreate /dev/md1
vgcreate vg0 /dev/md1
lvcreate -L 4G -n lv0 vg0
mke2fs -j /dev/vg0/lv0
mkdir /mnt/lv0
mount /dev/vg0/lv0 /mnt/lv0
find / -xdev | cpio -pvmd /mnt/lv0
cp -aux /dev /mnt/lv0
/dev/vg0/lv0 /   ;   ;   ;   ; ext3 defaults &nbs p; 1 1
mount --bind /dev /mnt/lv0/dev
chroot /mnt/lv0
mount -t proc /proc /proc
mount -t sysfs /sys /sys
vgscan
vgchange -ay
mkinitrd -v /boot/initrd-`uname -r`.lvm.img `uname -r`
umount /sys
umount /proc
exit
mv /mnt/lv0/boot/initrd-`uname -r`.lvm.img /boot
reboot