How to create a Logical Volume Management
First create the physical disk to physical volume
#pvcreate /dev/sdb1 /dev/sdb2 (my case sdb is my hard drive)
or
#pvcreate /dev/sdb{1,2}
#pvdisplay [to display the physical volume]
#pvs ( to PV scan)
To create volume group
#vgcreate nameofvolume /dev/sdb{1,2}
e,g: #vgcreate intel /dev/sdb{1,2}
#vgdisplay
* TOTAL PE = total size / PE size { Physical Extend}
* TOTAL PE = 4 GB / 4MB = 1026
TO CREATE LV - Logical Volume
#lvcreate -L 1G -n newlogicalvolumename name of volumegroup
eg: #lvcreate -L 1G -n lv1 intel
-L size of logical volume
-n name of new logical volume
#lvdisplay [to display junks]
To cross check issue the below commands.
#vgdisplay
#pvdisplay
#lvcreate -L 1G -n lv2 intel [To create another logical volume]
Creating file system type
#mkfs.ext3 /dev/inte/lv1 [to make file system for LV1]
#mkfs.ext3 /dev/inte/lv2 [to make file system for LV2]
#mount /dev/intel/lv1
#df -h
you can notice the mount point
/dev/mapper/intel-lv1
Here "mapper" is the control device for LVM
#cd /dev/mapper
#ls
this will display the list of logical volumes
NOW WE WILL EXTEND ONE LV AND SHRINK ANOTHER LV
#lvextend -L +500M /dev/intel/lv1
-L length of size
*Now the volume will be increased, to increase we need to increase the FILE SYSTEM.
#resize2fs /dev/intel/lv1
now the whole partition is extended
* For shrinking first we need to shrink the filesystem and then shrink the Logical Volume
#umount /mountpoint
#resize2fs /dev/intel/lv2 500MB { need to specify the file system size after shrink}
#e2fsck -f /dev/intel/lv2
Then resize again to make successful
#resize2fs /dev/intel/lv2 500MB
#mount /dev/intel/lv2 /mountpoint
#df -h [now the file system is reduced]
To reduce the Logical Volume
#lvreduce -L -500MB /dev/intel/lv2
Now remove a Logical Volume
#umount /mountpoint1
#umount /mountpoint2
#lvremove /dev/intel/lv1
#lvremove /dev/intel/lv2
#lvdisplay ( nothing will be there ,, all removed )
#vgremove volumegroupname
#vgremove intel
#pvremove /dev/sdb1
#pvremove /dev/sdb2
Hope the above is useful to someone who have in middle of LVM configuring.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home