Skip to content
Peter Eriksson edited this page Feb 10, 2017 · 2 revisions


Logical Volume Manager (LVM) is a layer between your file system and the actual block device.

A volume group (vg) is a collection of physical volumes - a local harddrive, iscsi lun or similar device.

This document will talk about a LVM system based around a single SATA harddrive (/dev/sda)

Create Physical Volume (pv)

pvcreate /dev/sda uses the entire /dev/sda as a physical volume.


Be careful! This will rewrite the partition information of this harddrive. Any partitions currently on the harddrive will be lost.

Create Volume Group

vgcreate vg0 /dev/sda 

This will create a volume group named vg0 on one pv

Create Logical Volume (lv)

Now let's create a 10GB volume called shelf on vg0:

lvcreate -n shelf -L 10G vg0 
  • -n is the name
  • -L is size in human form ( -l is in logical extents )
  • And last the name of the vg where the lv should live.

Create the file system with mkfs.ext4 /dev/vg0/shelf

Mount lv

blkid /dev/vg0/shelf

in fstab:

UUID=uuid /mount/point filesystem defaults 0 2

Increase size of lv

lvresize -L +5G /dev/vg0/shelf 

This will add 5G to /dev/vg0/shelf for a total of 15G

After we have added 5G to shelf we also have to resize the filesystem:

ext4: resize2fs /dev/vg0/shelf 
btrf: btrfs filesystem resize max /shelf (For btrf you supply the mountpoint and not the lv-device)

Decrease size of lv

To make a LV smaller we have to umount the filesystem, fsck, resize2fs and then resize the lv with lvresize -5G


This should usually not be done unless you know what you are doing. A better solution - if you have the space - is to create a new LV, copy your data, and destroy the old LV.

Delete lv

umount the logical volume and then lvremove /dev/vg0/shelf

Get LVM information

To get LVM information you have various scanning and display commands, listed below

Command Description
pvscan list PV's in system
lvscan list LV's
vgscan list VG's
lvdisplay /dev/vg0/shelf show details about the shelf lv
vgdisplay vg0 to see details of vg0
vgdisplay to see details of all vg's
You can’t perform that action at this time.