Skip to content

Logical Volume Management (LVM)

LVM, or Logical Volume Management, is a storage device management technology that gives users the power to pool and abstract the physical layout of component storage devices for easier and flexible administration. Utilizing the device mapper Linux kernel framework, the current iteration, LVM2, can be used to gather existing storage devices into groups and allocate logical units from the combined space as needed.

The main advantages of LVM are increased abstraction, flexibility, and control. Logical volumes can have meaningful names like “databases” or “root-backup”. Volumes can be resized dynamically as space requirements change and migrated between physical devices within the pool on a running system or exported easily. LVM also offers advanced features like snapshotting, striping, and mirroring.


LVM functions by layering abstractions on top of physical storage devices. The basic layers, starting with the most primitive, are:

LayerLVM PrefixDescription
Physical Volumespv...Physical block devices or other disk-like devices used by LVM as the raw building material. LVM writes a header to the device to allocate it for management.
Volume Groupsvg...LVM combines physical volumes into storage pools known as volume groups. Volume groups abstract the characteristics of the underlying devices and function as a unified logical device.
Logical Volumeslv...A volume group can be sliced up into any number of logical volumes. Logical volumes are functionally equivalent to partitions on a physical disk, but with much more flexibility.

In summary, LVM can be used to combine physical volumes into volume groups to unify the storage space available on a system. Afterwards, administrators can segment the volume group into arbitrary logical volumes, which act as flexible partitions.

Each volume within a volume group is segmented into small, fixed-size chunks called extents. The size of the extents is determined by the volume group (all volumes within the group conform to the same extent size).

  • Extents on a physical volume are called physical extents
  • Extents of a logical volume are called logical extents
  • A logical volume is simply a mapping that LVM maintains between logical and physical extents

Because of this relationship, the extent size represents the smallest amount of space that can be allocated by LVM. The logical extents that are presented as a unified device by LVM do not have to map to continuous physical extents. LVM can copy and reorganize the physical extents that compose a logical volume without any interruption to users. Logical volumes can also be easily expanded or shrunk by simply adding extents to or removing extents from the volume.


1. Mark the Physical Devices as Physical Volumes

Section titled “1. Mark the Physical Devices as Physical Volumes”

Scan the system for block devices that LVM can see and manage:

Terminal window
sudo lvmdiskscan
/dev/sda [ 200.00 GiB]
/dev/sdb [ 100.00 GiB]
2 disks
0 LVM physical volume whole disks
0 LVM physical volumes

Warning: Make sure that you double-check that the devices you intend to use with LVM do not have any important data already written to them. Using these devices within LVM will overwrite the current contents.

Mark devices as physical volumes:

Terminal window
sudo pvcreate /dev/sda /dev/sdb
Physical volume "/dev/sda" successfully created
Physical volume "/dev/sdb" successfully created

Verify that LVM has registered the physical volumes:

Terminal window
sudo pvs
PV VG Fmt Attr PSize PFree
/dev/sda lvm2 --- 200.00g 200.00g
/dev/sdb lvm2 --- 100.00g 100.00g

2. Add the Physical Volumes to a Volume Group

Section titled “2. Add the Physical Volumes to a Volume Group”

Create a volume group and add both physical volumes to it:

Terminal window
sudo vgcreate LVMVolGroup /dev/sda /dev/sdb
Volume group "LVMVolGroup" successfully created

See a brief summary of the volume group:

Terminal window
sudo vgs
VG #PV #LV #SN Attr VSize VFree
LVMVolGroup 2 0 0 wz--n- 299.99g 299.99g

3. Create Logical Volumes from the Volume Group Pool

Section titled “3. Create Logical Volumes from the Volume Group Pool”

Unlike conventional partitioning, when working with logical volumes, you do not need to know the layout of the volume since LVM maps and handles this for you. You only need to supply the size of the volume and a name.

Create logical volumes with the -L option (for size) and -n option (for name):

Terminal window
sudo lvcreate -L 10G -n projects LVMVolGroup
sudo lvcreate -L 5G -n www LVMVolGroup
sudo lvcreate -L 20G -n db LVMVolGroup
Logical volume "projects" created.
Logical volume "www" created.
Logical volume "db" created.

Allocate remaining space to a “workspace” volume using percentages:

Terminal window
sudo lvcreate -l 100%FREE -n workspace LVMVolGroup

View the result:

Terminal window
sudo vgs -o +lv_size,lv_name
VG #PV #LV #SN Attr VSize VFree LSize LV
LVMVolGroup 2 4 0 wz--n- 299.99g 0 10.00g projects
LVMVolGroup 2 4 0 wz--n- 299.99g 0 5.00g www
LVMVolGroup 2 4 0 wz--n- 299.99g 0 20.00g db
LVMVolGroup 2 4 0 wz--n- 299.99g 0 264.99g workspace

The logical devices are available within the /dev directory in two locations:

  • /dev/volume_group_name/logical_volume_name
  • /dev/mapper/volume_group_name-logical_volume_name

Format the logical volumes with the Ext4 filesystem:

Terminal window
sudo mkfs.ext4 /dev/LVMVolGroup/projects
sudo mkfs.ext4 /dev/LVMVolGroup/www
sudo mkfs.ext4 /dev/LVMVolGroup/db
sudo mkfs.ext4 /dev/LVMVolGroup/workspace

Create mount points:

Terminal window
sudo mkdir -p /mnt/{projects,www,db,workspace}

Mount the logical volumes:

Terminal window
sudo mount /dev/LVMVolGroup/projects /mnt/projects
sudo mount /dev/LVMVolGroup/www /mnt/www
sudo mount /dev/LVMVolGroup/db /mnt/db
sudo mount /dev/LVMVolGroup/workspace /mnt/workspace

Add them to /etc/fstab just like you would with normal block devices:

/dev/LVMVolGroup/projects /mnt/projects ext4 defaults,nofail 0 0
/dev/LVMVolGroup/www /mnt/www ext4 defaults,nofail 0 0
/dev/LVMVolGroup/db /mnt/db ext4 defaults,nofail 0 0
/dev/LVMVolGroup/workspace /mnt/workspace ext4 defaults,nofail 0 0

The operating system should now mount the LVM logical volumes automatically at boot.