LVM (Logical Volume Management)
With LVM, we can create logical partitions that can span across one or more physical hard drives. First, the hard drives are divided into physical volumes, then those physical volumes are combined together to create the volume group and finally the logical volumes are created from volume group.
How to Create LVM
fdisk /dev/sda
n (create 3 new partition)
t (change partition ID to 8e)
w (save partition)
partprobe /dev/sda
pvcreate /dev/sda{8,9,10} (To create physical volume)
pvdisplay (To get detail of physical volume)
vgcreate vg00 /dev/sda{8,9,10} (To create virtual Group)
vgdisplay (To get detail of virtual Group)
lvcreate -L +100M -n lv01 /dev/vg00 (To create 1st logical volume)
lvcreate -L +100M -n lv02 /dev/vg00 (To create 2nd logical volume)
lvdisplay (To get detail of logical volume)
mke2fs -j /dev/vg00/01 (To format 1st logical volume)
mke2fs -j /dev/vg00/02 (To format 2nd logical volume)
mkdir xyz
mkdir xyz1
mount /dev/vg00/lv01 xyz (To mount 1st logical volume)
mount /dev/vg00/lv02 xyz1 (To mount 2nd logical volume)
mount -a (update mount)
vi /etc/fstab (update entry)
Expand and Reduce LV
lvextend –L +50M /dev/vg00/lv01
lvdisplay /dev/vg00/lv01
lvextend –L +50M /dev/vg00/lv01
Remove LV, VG, PV partition
umount xyz
umount xyz1
lvremove /dev/bg00/lv01
lvremove /dev/bg00/lv02
vgremove /dev/vg00
pvremove /dev/sda{8,9,10}
vi /etc/fstab (To delete entry)
fdisk /dev/sda (press d to delete partition )