Articles‎ > ‎Linux‎ > ‎

LVM - Logical Volume Management

If you've ever wondered how you could rebuild the filesystem and disk parts of your computer without having to redo everything, LVM is the answer.

Explained most simply, LVM is what is used to allow your Linux operating system to access the hard drive partitions through a layer that is flexible enough to be changed without requiring changes to the structures actually stored on the disk.

You can do the following things with LVM:

  1. Add more drive space to an existing system
  2. Reapportion space when necessary, taking away from one and giving to another.
  3. Protect your data with RAID
  4. Combine multiple physical drives into a single system

This topic deserves more discussion which I will be adding shortly -BMC

Logical Volume Management is one way of virtualizing resources. See the discussion on Virtualization for more general information.

How LVM works

LVM consists of three manageable sections:

  1. Physical Extents - resources allowed for use with LVM
  2. Volume Groups - groupings of physical extents to create virtual drives
  3. Logical Volumes - virtual partitions

It is possible to combine drives and partitions in pretty much any way imaginable and treat them as a single drive or split them into virtual drives. The Physical Extents create managed sections that can be managed at the most basic layer. Think of it as virtual drive blocks. The Volume Groups create what are best thought of as virtual hard drives and at the last layer, the Logical Volumes are virtual partitions.

These separations give administrators the ability with Physical Volumes to move data between sets of blocks and to optimize those blocks without requiring modifications to the systems using them. Further with Volume Groups, the system can combine, do basic RAID, or split the physical extents into virtual drives. Finally, the Logical Volumes can be used as virtual partitions, but expanded or contracted to match the changing layer below.

  1. Evaluating available space
  2. Carving off some free space

Carving off some free space

Evaluating available space

# pvdisplay
"/dev/sda7" is a new physical volume of "52.51 GiB"
--- NEW Physical volume ---
PV Name /dev/sda7
VG Name
PV Size 52.51 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID zTMnIW-1hq1-x9ly-NxFX-xof6-Mr4C-iP3Mrn

Note the PE Size. This is the size of the "Physical Extents" or physical sections assigned to this volume group. The Free PE are the physical extents that are available to be assigned to something new and by multiplying the space per extent by the numbers of extents, you can determine how much space is available to be assigned.

In this example, there are 52GB of unassigned space. 

To make that space available for use, it has to be assigned to a volume group.

 # vgcreate 52GLVM

Now you will see that the Volume Group name has it assigned:

# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda7
  VG Name               52GLVM
  PV Size               52.51 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              13441
  Free PE               13441
  Allocated PE          0
  PV UUID               zTMnIW-1hq1-x9ly-NxFX-xof6-Mr4C-iP3Mrn

To create a logical volume of 10GB carved out of volume group 52GLVM with a name of mylv:

lvcreate -L 10G -n mylv 52GLVM

Don't forget to activate the LVM:

# lvchange -a y /dev/52GLVM/mylv

Really short cut


  1. mount device to be resized from an inactive state (alt os) and take measurements of free space, multiply space used by 120% for space needed. Compare space needed to space available, and shrink only if the resulting size will be smaller than the current size
  2. consider the physical space, make sure that there is plenty of available space
  3. umount the device, and if ext3, run:
    1. fsck -n /dev/path
    2. tune2fs -O ^has_journal /dev/path
    3. e2fsck -f /dev/path
    4. resize2fs /dev/path 10G
      ''Where you want the resulting partition to be slightly larger than 10G
  4. resize the LVM with lvresize to larger than the current file system
  5. * resize again with resize2fs if using ext3