RAID and LVM
From Ece
Incomplete - all the parts are here, but it is incoherent
In this example, we will take a PC with one drive, add another drive, create a RAID 1 array between the drives and use LVM for the mounts that we can. We will then migrate the data from the original drive to the RAID array.
- Install the second drive in the PC.
- Run fdisk and set the partitions for the second drive. In this example we will create two partitions. The first partition will hold /boot (~100MB) and the second partition will encompass the rest of the drive. An LVM, which contains the swap and root volumes, will be created on the second partition. Make sure to toggle each partition type to "Linux raid auto" (fd). We separate the /boot partition from the rest of the LVMs to make it easier for Linux to boot. Some can't boot for LVMs.
- Create a RAID 1 array on the first and second partitions.
mdadm -C /dev/md0 --level=1 --raid-devices=2 missing /dev/hdb1 --auto=yes
mdadm -C /dev/md1 --level=1 --raid-devices=2 missing /dev/hdb2 --auto=yes
- Now we create the LVM (physical volume and volume group) on the second RAID partition.
pvcreate /dev/md1
vgcreate VolGroup01 /dev/md1
- After the LVM volume group is created, we create a logical volume for swap (2GB) and root (120GB).
lvcreate -L2000 -nswap VolGroup01
lvcreate -L120000 -nroot VolGroup01
- Make a swap partition.
mkswap /dev/VolGroup01/swap
- Create a filesystem on the root volume. We chose to use ext3.
mkfs.ext3 /dev/VolGroup01/root
mkfs.ext3 /dev/md0
setup grub edit fstab
mkinitrd --preload raid1 /boot/initrd-`uname -r`.img `uname -r`
mount both /dev/md0 and /dev/VolGroup01/root
find / -mount -depth -print | cpio -pdmv /PATH_TO_ROOT_MOUNT
find /boot -mount -depth -print | cpio -pdmv /PATH_TO_BOOT_MOUNT
chroot to LVM root volume and run grub-install
reboot
mdadm /dev/md0 --add /dev/hda1
mdadm /dev/md1 --add /dev/hda2




