Logical Volume Manager (LVM) adds a flexible layer between physical disks and file systems on Linux. Instead of fixed partitions, you create logical volumes that you can resize, move and snapshot, often without downtime. This guide explains how LVM works and how to create an LVM partition step by step.

The building blocks
| Component | Meaning | Example |
|---|---|---|
| Physical volume (PV) | A disk or partition prepared for LVM | /dev/sdb |
| Volume group (VG) | A pool built from one or more PVs | vg_data |
| Logical volume (LV) | A “virtual partition” carved from the VG | /dev/vg_data/lv_app |
| Physical extent (PE) | The small, fixed-size unit LVM allocates (4 MiB by default) | — |
Think of the VG as a storage pool and LVs as flexible slices of it.
Benefits of LVM
- Resize volumes online, often without unmounting.
- Combine several disks into one large volume.
- Take snapshots for backups or testing.
- Move data between disks while the system runs (
pvmove). - Add capacity by adding disks to the volume group.
Step-by-step: create an LVM partition
In this example, a new empty disk /dev/sdb becomes a 20 GB volume for application data. Warning: double-check the disk name with lsblk, because these commands erase data.
1. Identify the disk
lsblk2. Create a physical volume
sudo pvcreate /dev/sdb
sudo pvsYou can use the whole disk, as here, or a partition with the Linux LVM type.
3. Create a volume group
sudo vgcreate vg_data /dev/sdb
sudo vgs4. Create a logical volume
sudo lvcreate -L 20G -n lv_app vg_data
sudo lvsUse -l 100%FREE instead of -L 20G to use all free space.
5. Create a file system
sudo mkfs.xfs /dev/vg_data/lv_app
# or: sudo mkfs.ext4 /dev/vg_data/lv_app6. Mount it
sudo mkdir -p /data
sudo mount /dev/vg_data/lv_app /data
df -h /data7. Mount it at boot
Add a line to /etc/fstab:
/dev/vg_data/lv_app /data xfs defaults 0 0Then test with sudo mount -a before rebooting, because a wrong entry can stop the system from booting.
Extending a logical volume
When space runs low, extend the LV and file system in one command:
sudo lvextend -r -L +10G /dev/vg_data/lv_appThe -r option resizes the file system too. If the volume group has no free space, first add a new disk with pvcreate and vgextend vg_data /dev/sdc.
Note that XFS can grow but cannot shrink. Ext4 can shrink, but only while unmounted, so plan carefully.
Snapshots
A snapshot captures a volume’s state at one moment:
sudo lvcreate -s -L 5G -n lv_app_snap /dev/vg_data/lv_appSnapshots are useful before upgrades or for consistent backups. However, they are not backups by themselves, and they slow writes while they exist, so remove them when done.
Useful commands
| Task | Command |
|---|---|
| Show PVs, VGs, LVs | pvs, vgs, lvs |
| Detailed info | pvdisplay, vgdisplay, lvdisplay |
| Remove an LV | lvremove /dev/vg_data/lv_app |
Related guides
Sources
Running Linux servers in production? Our Linux server hardening & security audit checks configuration, patching, SSH and logging. You can also use our free Linux server hardening checklist, or contact us.

Pingback: Linux Interview Questions - Youngster Company