LVM Commands

Liquidweb 728x90.jpg

LVM consists of the following components:

Volume Group (VG)
The Volume Group is the high level container which holds one or more logical volumes and physical volumes.

Physical Volume (PV)
A physical volume represents a storage device such as a disk drive or other storage media.

Logical Volume (LV)
A logical volume is the equivalent to a disk partition and, as with a disk partition, can contain a file system.

Physical Extent (PE)
Each physical volume (PV) is divided into equal size blocks known as physical extents.

Logical Extent (LE)
Each logical volume (LV) is divided into equal size blocks called logical extents.

Logical Volumes

Volume management creates a layer of abstraction over physical storage, allowing you to create logical storage volumes.


  • When using logical volumes, file systems can extend across multiple disks, since you can aggregate disks and partitions into a single logical volume.
  • You can extend logical volumes or reduce logical volumes in size with simple software commands, without reformatting and repartitioning the underlying disk devices.
  • You can create a logical volume that stripes data across two or more disks. This can dramatically increase throughput.
  • Logical volumes provide a convenient way to configure a mirror for your data.
  • Using logical volumes, you can take device snapshots for consistent backups or to test the effect of changes without affecting the real data.


Full list is here:

Create a Logical Volume:

lvcreate -v -L 50MB new_vg
# -v (verbose)
# -L (Size)
# new_vg (name of the volume)

Use the pvcreate command to initialize a block device to be used as a physical volume.

The following command initializes /dev/sdd as LVM physical volumes for later use as part of LVM logical volumes.

pvcreate /dev/sdd

To initialize partitions rather than whole disks: run the pvcreate command on the partition.

pvcreate /dev/sdd1

The pvdisplay command provides a verbose multi-line output for each physical volume.

# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdc1
  VG Name               new_vg
  PV Size               17.14 GB / not usable 3.40 MB
  Allocatable           yes
  PE Size (KByte)       4096
  Total PE              4388
  Free PE               4375
  Allocated PE          13
  PV UUID               Joqlch-yWSj-kuEn-IdwM-01S9-XO8M-mcpsVe

To create a volume group from one or more physical volumes, use the vgcreate command

The following command creates a volume group named vg1 that contains physical volumes /dev/sdd1 and /dev/sde1.

vgcreate vg1 /dev/sdd1 /dev/sde1

To add additional physical volumes to an existing volume group, use the vgextend command.

The following command adds the physical volume /dev/sdf1 to the volume group vg1.

vgextend vg1 /dev/sdf1

The vgdisplay command displays volume group properties (such as size, extents, number of physical volumes, etc.) in a fixed form.

vgdisplay new_vg
  --- Volume group ---
  VG Name               new_vg
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  11
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               0
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               51.42 GB
  PE Size               4.00 MB
  Total PE              13164
  Alloc PE / Size       13 / 52.00 MB
  Free  PE / Size       13151 / 51.37 GB
  VG UUID               jxQJ0a-ZKk0-OpMO-0118-nlwO-wwqd-fD5D32

LVM Snapshots

The following command creates a snapshot logical volume that is 100 MB in size named /dev/vg00/snap. This creates a snapshot of the origin logical volume named /dev/vg00/lvol1. If the original logical volume contains a file system, you can mount the snapshot logical volume on an arbitrary directory in order to access the contents of the file system to run a backup while the original file system continues to get updated.

lvcreate --size 100M --snapshot --name snap /dev/vg00/lvol1

The lvs command, by default, displays the origin volume and the current percentage of the snapshot volume being used for each snapshot volume. The following example shows the default output for the lvs command for a system that includes the logical volume /dev/new_vg/lvol0, for which a snapshot volume /dev/new_vg/newvgsnap has been created.

# lvs
  LV         VG     Attr   LSize  Origin Snap%  Move Log Copy%
  lvol0      new_vg owi-a- 52.00M
  newvgsnap1 new_vg swi-a-  8.00M lvol0    0.20


Built-in System Rollback

  • File system snapshots, which are quick and easy to create, make it simple to roll a system back to a prior, known-good state if something goes wrong.

Built-in Compression

  • This makes saving space easier.

Checksum Functionality

  • This improves error detection.

CEO & Founder in Gravitation Ltd

Recent Posts