Understanding LVM in Linux with Examples


LVM (Logical Volume Manager) is a system used in Linux to manage disk storage, allowing the creation and management of logical volumes (logical partitions), which can be resized, created, or deleted without affecting the underlying physical disk.

LVM Examples:

vg_name ==> Name of volume group like vg_oel1
lv_name ==> Name of logical volumne like lvol1

1) Listing LVM physical volumes:

pvdisplay

2) Listing LVM volume groups:

vgdisplay

3) Listing LVM logical volumes:

lvdisplay

4) Creating a new physical volume:

pvcreate /dev/sdb

5) Creating a new volume group:

vgcreate vg_name /dev/sdb

6) Creating a new logical volume:

lvcreate -L 10G -n lv_name vg_name

7) Extending an existing logical volume:

lvextend -L +5G /dev/vg_name/lv_name

8) Reducing the size of a logical volume:

lvreduce -L 5G /dev/vg_name/lv_name

9) Removing a logical volume:

lvremove /dev/vg_name/lv_name

10) Removing a volume group:

vgremove vg_name

Note: These commands should be run as root or with appropriate sudo privileges.










If you like please follow and comment