Tuesday, November 22, 2011

LVM and RAID

LVM (Logical Volume manager):-


LVM is an extensible partitioning tool using which we can modify or resize any partition without changing our existing data.

/dev/hdax
                                                Figure
/dev/hdax

In order to create LV ( logical volume) we need to create a partition.
#fdisk /dev/had
Press( m for Help): n
l : logical
p : Physical
Type ‘l’
First Cylinder : Press Enter
Last Cylinder (+sizeM or +sizeK) : +100M
Command : t                          : t for change the type
Partition no : x                                   : x is the number of partititon
Type : 8e                                 : 8e for LVM
Command : w
#partprobe

Now we create a Physical Volume (PV)
#pvcreate /dev/hda8
Display the PV Information
#pvdisplay
Now we create Volume group
#vgcreate Vg00 /dev/hda8
Display the Vg information
#vgdisplay
Finally we create a logical volume
#lvcreate –n lv00 –L+50M vg00
Where
-n : logical name
-L: size
Display the LV information
#lvdisplay
After creating the logical volume, we need to format
#mkfs.ext3 /dev/vg00/lv00
Finally we mount it on /lvm
#mkdir /lvm
#mount /dev/vg00/lv00 /lvm

Extending the size of LVM
#lvextend –L+50M /dev/vg00/lv00
After adding we need to run resize2fs command in order to assign file system type to the added size
#resize2fs /dev/vg00/lv00

Reducing the size of LVM
#lvreduce –L-20M /dev/vg00/lv00
If the size of the logical volume is full and we need more space to store data we need to create new partition , change its type to LVM by ‘8e’ then create the physical volume and add that with volume group (vg00)
#vgextend vg00 /dev/hda9
After that extend the size of logical volume
In order to delete the logical volume
#umount /lvm
#lvremove /dev/vg00/lv00
#vgremove vg00
#pvremove /dev/hda9
#pvremove /dev/hda8
Then finally using the fdisk remove hda8 and hda9

 RAID (Redundant Array Of Inexpensive Disk):-

RAID is a series of disk which can save your data even if there is catastrophic failure on one of the disk
RAID are classified as RAID0, RAID1 and RAID 5
RAID 0 : require minimum 2 HDD and also known as stripping without parity
RAID 1: require minimum 2 HDD and also known as disk mirroring
RAID 5: minimum 3 HDD requirement and also known as stripping with parity

First we create the two partition say each of 100MB and then change its type to (‘fd’) Raid
Now we create a RAID
#mdadm –C /dev/md0 –level=1 –raid-disks=2 /dev/hda8 /dev/hda9
Now check the raid
#cat /proc/mdstat
‘OR’
#mdadm --detail /dev/md0
Format the newly created RAID
#mkfs.ext3 /dev/md0
Now mount it
#mkdir /raid
#mount /dev/md0 /raid
In order to check first we fail any one of the partition
#mdadm --manage /dev/md0 --fail /dev/hda8
Check the status of the RAID
#mdadm --detail /dev/md0
Removing the failure partition
#mdadm --manage /dev/md0 --remove /dev/hda8
To add new disk partition
#mdadm --manage /dev/md0 --add /dev/hda10

Note:
In order to add new partition first we create the partition and change  its type to ‘fd’

Thanks ,


No comments:

Post a Comment