Configuring RAID over LVM
Network NUTS – the best training institute for RedHat linux in Asia Pacific. In Network NUTS we always tries to give the WOW in training. This topic is again the most sought after topic in live environments. Just a few days back Network NUTS had successfully imparted training to IAF on Linux servers.
This is one of the topics I always wanted to write about. How to manage RAID (mdadm) with LVM.
The benefit of LVM is that we can never be short of space. And the benefit of RAID is that we get data redundancy. Now how to eat the cake and have it too. That is how to get the benefits of both the LVM and RAID. Here are the steps which might help.
Do it after understanding the sequence.
1. Suppose I have three HDD (or partitions) and I want to implement RAID-5 with LVM. First create the RAID-5 device.
mdadm –create –verbose /dev/md0 –level=5 –raid-devices=3 /dev/sda8 /dev/sda9 /dev/sda10
2. Check the status
mdadm –detail /dev/md0
3. Add this RAID to LVM system, first create the physical volume.
4. Now create a volume group out of it. (in my case the VG name is lvm-raid)
vgcreate lvm-raid /dev/md0
5. [OPTIONAL] Configure the correct physical extent size. The default value for the physical extent size can be too low for a large RAID array. In those cases you’ll need to specify the -s option with a larger than default physical extent size. The maximum number of physical extents is approximately 65k so take your maximum volume size and divide it by 65k then round it to the next nice round number. For example, to successfully create a 550G RAID let’s figure that’s approximately 550,000 megabytes and divide by 65,000 which gives you roughly 8.46. Round it up to the next nice round number and use 16M (for 16 megabytes) as the physical extent size and you’ll be fine:
vgcreate -s 16M <volume group name>
6. Check the status of VG (lvm-raid)
(note down the PE from the output, say it is 88888)
7. Now create a Logical Volume out of the Volume Group.
lvcreate -l 88888 lvm-raid -n lvm0
8. Finally mount it on some location and use it.
mount /dev/lvm-raid/lvm0 /mnt
9. Cross-check it using df command
(your /mnt should be mounted on lvm-raid)
do visit – http://www.networknuts.net
Alok Srivastava – 91-9911962206 / firstname.lastname@example.org