Skip to content

Logical Volume Management (LVM) in Linux

On this page, you will learn how to use Logical Volume Management in Linux. LVM provides a flexible way to manage storage by creating an abstraction layer between physical devices and filesystems. Instead of being limited by fixed partitions, LVM allows you to combine multiple disks or partitions into a single storage pool called a Volume Group. From this pool, you can create Logical Volumes that act like virtual partitions. These volumes can be resized, extended, or reduced without repartitioning, making storage management dynamic and efficient. LVM also supports RAID techniques within a Volume Group, allowing you to implement mirroring or striping for redundancy or performance.

  • Physical Volume (PV): Actual storage device or partition (e.g., /dev/sda1).
  • Volume Group (VG): Pool of storage made up of one or more PVs (e.g., vg_data).
  • Logical Volume (LV): Virtual partition created from a VG. Acts like a “normal partition” (e.g., lv_webcontent).

The following diagram shows the typical LVM structure from the physical disk to the mount point.

Disk: /dev/sda
└── Partition: /dev/sda1
└── Physical Volume (PV): /dev/sda1
└── Volume Group (VG): vg_data
└── Logical Volume (LV): lv_webcontent
└── Filesystem: ext4 or xfs
└── Mount Point: /var/www

Note: Keep in mind that a PV acts as a claim for a physical disk or partition. This way you don’t need a partition and you can just claim the whole disk by using pvcreate /dev/sda. This will utillize the whole disk without partitioning. This will result in not being able to use the disk for anything else then LVM as long as its in use.

The following commands show how to create and manage LVM components step by step.

This initializes a disk or partition for LVM use.

Terminal window
pvcreate /dev/sda1

This combines one or more physical volumes into a storage pool.

Terminal window
vgcreate vg_data /dev/sda1 /dev/sdb1

Note: This combines PV’s, no matter if they are built on disks or partitions, nor where they are. So this can span across disk, and use full disks and only patritions on other disks.

Logical volumes are created from the volume group and act like partitions.

Terminal window
lvcreate -n lv_webcontent -L 64M vg_data
  • -n: Name of the logical volume (here: lv_webcontent).
  • -L: Size of the logical volume (here: 64 MB).
  • Last argument: VG name (vg_data).

Note: Each LV can be formatted with it’s own (different) fileystem, without affecting other LV’s, despite might being on the same physical disk.

You can use these commands to display details about PVs, VGs, and LVs.

Terminal window
pvdisplay
vgdisplay
lvdisplay

To increase the size of a logical volume and then resize the filesystem, you use these commands.

Terminal window
lvextend -L +500M /dev/vg_data/lv_webcontent
resize2fs /dev/vg_data/lv_webcontent # For ext4 filesystem

To shrink logical volumes, you can use these commands to unmount the disk, shrink the filesystem and shrink the volume.

Terminal window
umount /mnt/webcontent
e2fsck -f /dev/vg_data/lv_webcontent
resize2fs /dev/vg_data/lv_webcontent 100M
lvreduce -L 100M /dev/vg_data/lv_webcontent

Warning: Shrinking a logical volume is risky and should always be done offline.


LVM supports RAID techniques inside a volume group for redundancy or performance. You can use mirror (RAID1 ) for redundancy or striping (RAID0) for performance. The commands below will configure that.

Terminal window
lvcreate --type raid1 -m1 -L 1G -n lv_mirror vg_data
lvcreate --type raid0 -i2 -L 2G -n lv_striped vg_data
  • --type: RAID level (raid0, raid1, raid5, raid6, raid10).
  • -m: number of mirrors (RAID1).
  • -i: number of stripes (RAID0).

After creating a logical volume, you can format it with a filesystem and mount it, so it can be used.

Terminal window
mkfs.ext4 /dev/vg_data/lv_webcontent

To be able to realy use the volume, now with filesystem, as a folder you can put stuff in, you have to mount it. This can be done by a single mount command like shown below. Here is de www folder in the path /var/www the mountpoint. Simply put, all contents of that folder, are actualy stored on the LV lv-webcontent.

Terminal window
mount /dev/vg_data/lv_webcontent /var/www

To make a mount persistant and automatically mounted at every boot, you can add the mount to /etc/fstab like shown below.

/dev/vg_data/lv_webcontent /var/www ext4 defaults 0 2
FieldDescription
/dev/vg_data/lv_webcontentThe device or logical volume to mount.
/var/wwwThe directory where the filesystem will be mounted.
ext4The type of filesystem used on the volume.
defaultsMount options (e.g. read/write, exec, auto). Uses system defaults.
0Dump flag. Usually 0 to disable backup with dump.
2fsck order. 1 is for root filesystem, 2 is for others, 0 disables check.

After mounting, you can manage the folder and it’s contents with the Linux permissions. You can see Filesystem permissions in Linux for more information about the different permissions you can assign in Linux to files and folders.


With the commands below, you can check the current configuration of your machine.

  • Check free space in VG: vgs
  • List LVs: lvs
  • List VGs: vgs
  • List PVs: pvs
  • Mount overview: lsblk, df -h