Setting Up LVM On Top Of Software RAID Subsystem - RHEL & Fedora - Page 2

Want to support HowtoForge? Become a subscriber!
 
Submitted by SKRHCE2006 (Contact Author) (Forums) on Wed, 2008-03-26 17:05. ::

Step 9:

Using fdisk, change the partition ID of /dev/sda5 from 8e to fd (raid type), save by typing “w” in the fdisk menu.

then do:

# partprobe

 

Step 10:

Create the RAID ARRAY with /dev/sda5 and 1 missing device (/dev/sda6). Remember that RAID 1 requires a min. of 2 active devices, we will add /dev/sda6 later.

# mdadm - -create /dev/md0 - -level 1 –n 2 /dev/sda5 missing

 

Step 11:

Create PV on /dev/md0 and add it to the VG vg1.

# pvcreate /dev/md0

# vgextend vg1 /dev/md0

 

Step12:

Then move the Physical Extents on PV, /dev/sda6 to /dev/md0 and pull /dev/sda6 out of VG.

# pvmove /dev/sda6 /dev/md0

# vgreduce vg1 /dev/sda6

# pvremove /dev/sda6

Use pvdisplay, vgdisplay and lvdisplay to get the status of PV’s, VG and LV’s. Note the size of /dev/md0from the output of pvdisplay.

 

Step13:

Using fdisk change the partition type ID of /dev/sda6 to fd (raid), save by “w” and then do

# partprobe

 

Step 14:

Now add the /dev/sda6 to the RAID array /dev/md0.

# mdadm - -manage /dev/md0 - -add /dev/sda6

# pvresize /dev/md0 (Resize the PV on /dev/md0)

# mdadm - -grow /dev/md0 –z max (Refresh the Array)

The GROW mode is used for changing the size or shape of an active array. " –z max" means, amount (in Kilobytes) of space to use from each drive in /dev/md0. This value is set with --grow for RAID l since, the array was created with a size smaller than the currently active drives. Now the extra space can be accessed using --grow.

Use pvdisplay, vgdisplay and lvdisplay to get the status of PV’s, VG and LV’s. Can you notice the changes in the output of the pvdisplay command?

 

Step 15:

Get the details of /dev/md0 and add to /etc/mdadm.conf. First copy the mdadm.conf.sample file to the /etc directory. This step is usefull to rectify situations where after creating RAID array and rebooting the system, you get error saying "no /dev/md0 found".

# cp /usr/share/doc/mdadm*/mdadm.conf-sample /etc/mdadm.conf

# mdadm - -detail /dev/md0

Note down the UUID of the raid array.

# vi /etc/mdadm.conf

And add these two lines:

DEVICE /dev/sda5 /dev/sda6
ARRAY /dev/md0 UUID=<ID>

Save the file using Esc:wq. Then do:

# mdadm - -detail /dev/md0

So we have seen that the LVM (LV-lv1) sits on top of RAID 1 array, called the LVM mirrored set. This method of configuration does not need to unmount the LV and also prevents data loss. We will further go one step ahead and see how to add a spare drive if a device in the array fails or becomes faulty.

Open a new terminal (ctrl+alt+F2) and type:

# watch cat /proc/mdstat (to see the live status of RAID array /dev/md0)

Make /dev/sda6 faulty and then remove it from the raid array.

# mdadm - -manage /dev/md0 - -fail /dev/sda6 - -remove /dev/sda6

Create a new partition of type fd. Here, /dev/sda7.

# fdisk /dev/sda

      n-> l-> +2048M (/dev/sda7)-> t ->7 -> fd -> w

# partprobe

Add the /dev/sda7 device to the raid array:

# mdadm - -manage /dev/md0 - -add /dev/sda7

# vi /etc/mdadm.conf

Change the DEVICE line:

DEVICE /dev/sda5 /dev/sda7

Save the file using Esc:wq. Then do:

# mdadm - -detail /dev/md0

# pvresize /dev/md0

# mdadm - -grow /dev/md0 –z max

This will refresh and resize the PV and RAID array respectively.

 

Conclusion:

You can test this setup with different Physical Hard Disks. Combing LVM and RAID gives more Flexibility as well as safeguards the data to great extent.

Idea and Concepts: Datacentre Planning & Implementation, (For a Govt. Organization at Port Blair).

By

Swapan Karmakar (RHCE, BCA)

TECHNICAL SUPPORT EXEC.-LINUX (SELF HELP GROUP, ALUG)

Andaman & Nicobar Islands.

My mission is to bring Linux & OSS Into these beautiful Islands of Andaman & Nicobar.


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Duncan Corps (not registered) on Mon, 2009-06-15 09:59.

Is this meant to be a HowTo? It looked like just a list of commands to type with little or no explanation. Now I've read it I know what the author typed to make his system how he likes it, but have no idea how to make my system how I like it nor how any of this works.

'Explanations' like "Each physical volume (PV) is of 2GB.VG=4 GB, LV=1GB and “RAID 1” array of 2GB." and "Create PV on /dev/md0 and add it to the VG vg1." are no help. VG? LV? vg1? Too cryptic for, and frustrated, me.

It's clear that the author knows what he's talking about, but could improve this HowTo by making it more general (applicable to different systems) and clearer (it's OK to be more wordy if it means that the audience spends less time trying to work out what you mean).