Logical Volume Management

The Linux Logical Volume Manager (LVM) is a mechanism to virtualize the disks. It can create “virtual” disk partitions out of one or more physical hard drives, allowing you to grow, shrink, or move those partitions from drive to drive as your needs change. It also allows you to create larger partitions than you could achieve with a single drive. Traditional uses of LVM have included databases and company file servers, but even home users may want large partitions for music or video collections, or for storing online backups. LVM can also be convenient ways to gain redundancy without sacrificing flexibility.
A typical example for the need of LVM can be, assuming that we are having a disk of size 2GB and we start adding the data in the form of a single file, eventually it grows to the size of 2GB. In this case the possibility is, you go for another disk which is larger than 2GB, let’s say 4GB. But what if the file again grows more than 4GB? How far you will be migrating file from one disk to another so on and so forth? It requires a down time as well which is not possible in real time, so to avoid these circumstances we implement LVM and store data in LV’s whose size can be easily increased whenever required without a downtime.

The above picture shows the structure of LVM. LVM consists of Physical Volumes, Volume Group, Logical Volumes, and finally file systems. The Physical partitions are known as Physical Extents (PE), and the logical partitions are known as logical Extents (LE).


Components of LVM in Linux:
 Physical Volumes (PV)
 Physical Extent (PE)
 Volume Group (VG)
 Logical Volume (LV)
 Logical Extent (LE)

Physical Volume (PV)
It is the standard partition that you add to the LVM. Normally, a physical volume is a standard primary or logical partition with the hex code 8e.
Physical Extent (PE)
It is a chunk of disk space. Every PV is divided into a number of equal-sized PEs.
Volume Group (VG)
It is composed of a group of PV’s and LV’s. It is the organizational group for LVM.
Logical Volume (LV)
It is composed of a group of LEs. You can format and mount any file system on an LV. The size of these LV’s can easily be increased or decreased as per the requirement.
Logical Extent (LE)
It is also a chunk of disk space. Every LE is mapped to a specific PE.

 

LVM Command

Function

pvs

Displays all the physical volumes

vgs

Displays all volume groups in the system

lvs

Displays all the logical volumes in the system

pvdisplay

Displays detailed information on physical volumes

vgdisplay

Displays detailed information on volume groups

lvdisplay

Displays detailed information on logical volumes

pvcreate

Create a new physical volume

vgcreate

Create a new volume group.

lvcreate

Creates a new logical volume

vgextend

Add a new physical disk to a volume group.

lvextend

Extends a logical volume

lvresize

Resizes a logical volume

lvreduce

Reduces a logical volume

pvmove

Moves/migrates data from one physical volume to another

vgreduce

Reduces a volume group by removing a PV from it.

pvremove

Deletes a physical volume

vgremove

Removes /Deletes a volume group

lvremove

Removes /Deletes a logical volume

Leave a Reply

Your email address will not be published. Required fields are marked *