Tuesday, August 24, 2010

LVM

1. Logical Volume Manager is the esier way to manage hard disk by resizing

logical volumes.

2. The LVM2 packge is used for kernel 2.6.

3. In LVM structure there are three levels of organisation :-

physical volume - volume group - logical volume

4. Linux LVM partition has 8e code.

5. The physical partitions i.e. physical volumes turns into volume groups

that then turns into logical volumes.

This logical volumes are assigned mount points and file system types

like ext2, ext3.

When "partitions" reach their full capacity, free space from the volume

group can be added to the logical volume to increase the size of the

partition. When a new hard drive is added to the system, it can be added

to the volume group,and partitions that are logical volumes can be

increased in size.



#############################################



STEPS TO CONFIGURE LVM :



# Creating Physical Volumes

# Creating Volume Groups

# Creating Logical Volumes and assigning mount points.

# Resizing VG and LVs.

# Removing PV, VG and LVs.

# Monitoring PV, VG and LVS.





######## LOGICAL VOLUME MANAGER CONFIGURETION #######



1)To create the partition.

#fdisk /dev/sda

#partprobe /dev/sda



2)To create the PV (physical volume)

# pvcreate /dev/sda9 /dev/sda10 /dev/sda11

Physical volume "/dev/sda9" successfully created

Physical volume "/dev/sda10" successfully created

Physical volume "/dev/sda11" successfully created



3)To check PV

#pvdisplay



4)To create the VG (volume group)

#vgcreate india /dev/sda9 /dev/sda10 /dev/sda11

Volume group "india" successfully created



5)To check VG

#vgdisplay



6)To create the LV (logical volume).

#lvcreate -L 20m india -n mumbai

#lvcreate -L 20m india -n chennai

#lvcreate -L 20m india -n dehli



7)To check LV.

#lvdisplay



8)To extend the VG.

#fdisk -l

#fdisk /dev/sda

#partprobe /dev/sda

#pvcreate /dev/sda12

Physical volume "/dev/sda12" successfully created

#vgextend india /dev/sda12

Volume group "india" successfully extended



9)To resize the LV.

#lvresize -L +50m /dev/india/mumbai

Rounding up size to full physical extent 52.00 MB

Extending logical volume mumbai to 72.00 MB

Logical volume mumbai successfully resized



10)To check the LV by mounting.



1)To create mount point.

#mkdir /mumbai

#mkdir /chennai

#mkdir /delhi



2)To format the LV.

#mkfs.ext3 /dev/india/mumbai

#mkfs.ext3 /dev/india/chennai

#mkfs.ext3 /dev/india/delhi



3)To mount on mount point.

#mount /dev/india/mumbai /mumbai

#mount /dev/india/mumbai /chennai

#mount /dev/india/mumbai /delhi



4)To check.

#mount

/dev/mapper/india-mumbai on /mumbai type ext3 (rw)

#umount



11)LV Remove.

#lvremove /dev/india/mumbai

Do you really want to remove active logical volume "mumbai"? [y/n]: y

Logical volume "mumbai" successfully removed

#lvremove /dev/india/chennai

#lvremove /dev/india/delhi



12)VG Remove.

#vgremove india

Volume group "india" successfully removed



13)PV Remove.

#pvremove /dev/sda9 /dev/sda10 /dev/sda11 /dev/sda12

Labels on physical volume "/dev/sda9" successfully wiped

Labels on physical volume "/dev/sda10" successfully wiped

Labels on physical volume "/dev/sda11" successfully wiped

Labels on physical volume "/dev/sda12" successfully wiped



14)To update the logical volume with kernel.

#resize2fs /dev/share/mkt