In this tutorial we are going to learn how to create raid over lvm.
LVM is basically a device mapper that provides logical volume management for linux creating on multiple physical volumes. And actually Lvm is made on volume group and Volume group can be resized by absorbing physical volumes.
RAID knows as redundant array of inexpensive disks, is a data storage virtualization technology that combines multiple physical disk drive components into a single logical units for the purposes of data redundancy.
FOllow these steps to create raid over lvm :
- Create three partitions
[root@localhost ~]# fdisk /dev/sdc The number of cylinders for this disk is set to 1634. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (1-1634, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-1634, default 1634): +800M Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (99-1634, default 99): Using default value 99 Last cylinder or +size or +sizeM or +sizeK (99-1634, default 1634): +800M Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (197-1634, default 197): Using default value 197 Last cylinder or +size or +sizeM or +sizeK (197-1634, default 1634): +800M Command (m for help): p Disk /dev/sdc: 13.4 GB, 13445111808 bytes 255 heads, 63 sectors/track, 1634 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdc4 1 1634 13125073+ 5 Extended /dev/sdc5 1 98 787122 83 Linux /dev/sdc6 99 196 787153+ 83 Linux /dev/sdc7 197 294 787153+ 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks.
- Now we have to convert these partitions into physical volumes.
[root@localhost ~]# pvcreate /dev/sdc5 /dev/sdc6 /dev/sdc7 Physical volume "/dev/sdc5" successfully created Physical volume "/dev/sdc6" successfully created Physical volume "/dev/sdc7" successfully created
- After creating physical volumes we have to create volume groups over physical volumes.
[root@localhost ~]# vgcreate vg00 /dev/sdc5 /dev/sdc6 /dev/sdc7 Volume group "vg00" successfully created
- Now we will create logical volume over volume group
[root@localhost ~]# lvcreate -L +500M -n lv1 vg00 Logical volume "lv1" created [root@localhost ~]# lvcreate -L +500M -n lv2 vg00 Logical volume "lv2" created
- Now its time to configure raid over lvm
[root@localhost ~]# mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/vg00/lv1 /dev/vg00/lv2 mdadm: array /dev/md1 started.
- You can check
[root@localhost ~]# cat /proc/mdstat Personalities : [raid6] [raid5] [raid4] [raid1] md1 : active raid1 dm-1 dm-0 511936 blocks [2/2] [UU] md6 : active raid6 sda6 sda5 995712 blocks level 6, 64k chunk, algorithm 2 [4/2] [UU__] unused devices: <none>