Home > Linux > LVM (Logical Volume Manager)

LVM (Logical Volume Manager)

January 16th, 2009 Leave a comment Go to comments

What is LVM

LVM is a Logical Volume Manager for the Linux operating system. There are now two version of LVM for Linux:

  • LVM 2 – The latest and greatest version of LVM for Linux.LVM 2 is almost completely backward compatible with volumes created with LVM 1. The exception to this is snapshots (You must remove snapshot volumes before upgrading to LVM 2)LVM 2 uses the device mapper kernel driver. Device mapper support is in the 2.6 kernel tree and there are patches available for current 2.4 kernels.
  • LVM 1 – The version that is in the 2.4 series kernel,LVM 1 is a mature product that has been considered stable for a couple of years. The kernel driver for LVM 1 is included in the 2.4 series kernels


The LVM can:

  • Resize volume groups online by absorbing new physical volumes (PV) or ejecting exiting  ones.
  • Resize logical volumes (LV) online by concatenating extents onto them or truncatiing    extents from them.
  • Create read-only snapshots of logical volumes (LVM1).
  • Create read-write snapshots of logical volumes (LVM2).
  • Stripe whole or parts of logical volumes across multiple PVs, in a fashion similar to R AID0.
  • Mirror whole or parts of logical volumes, in a fashion similar to RAID1.
  • Move online logical volumes between PVs.
  • Split or merge volume groups in situ (as long as no logical volumes span the split).  The    can be useful when migrating whole logical volumes to or from offline storage.

 The LVM will also work in a shared-storage cluster (where disks holding the PVs are shared between multiple host computers), but requires an additional daemon to propagate state changes between cluster nodes.

LVM does not:

  • Provide parity-based redundancy across LVs, as with RAID4, RAID5 or RAID6. This functionality is instead provided by Linux metadisks, which can be used as LVM physical volumes.

LVM Terminology

Physical Volume (PV) :- A PV is nothing more than a physical medium with some administrative data added to it – once you have added this, LVM will recognise it .

A Physical Volume, containing Physical Extents:

+-----[ Physical Volume ]------+
| PE | PE | PE | PE | PE | PE  |

b. Physical Extents (PE) :- Physical Extents are like really big blocks, often with a size of megabytes.

c. Volume Group (VG) :- A VG is made up of a number of Physical Extents (which may have come from multiple Physical Volumes or hard drives). While it may be tempting to think of a VG as being made up of several hard drives (/dev/hda and /dev/sda for example), it’s more accurate to say that it contains PEs which are provided by these hard drives.

A Volume Group, containing 2 Physical Volumes (PVs) with 6 Physical Extents:

+------[ Volume Group ]-----------------+
|  +--[PV]--------+  +--[PV]---------+  |
|  | PE | PE | PE |  | PE | PE | PE  |  |
|  +--------------+  +---------------+  |
We now further expand this:

+------[ Volume Group ]-----------------+
|  +--[PV]--------+  +--[PV]---------+  |
|  | PE | PE | PE |  | PE | PE | PE  |  |
|  +--+---+---+---+  +-+----+----+---+  |
|     |   |   | +-----/     |    |      |
|     |   |   | |           |    |      |
|   +-+---+---+-+      +----+----+--+   |
|   |  Logical  |      |  Logical   |   |
|   |  Volume   |      |   Volume   |   |
|   |           |      |            |   |
|   |  /home    |      |    /var    |   |
|   +-----------+      +------------+   |

You can use pvdisplay,vgdisplay and lvdisplay commands to show the physical volume,
volume group and logical volume status respectively.

Categories: Linux Tags:
  1. Mohd Anas
    January 19th, 2009 at 11:20 | #1


    Its a great one clearing the concept of LVM.
    But it can improved by mentioning the advantages of using

  2. January 21st, 2009 at 09:14 | #2

    Hi anas,

    I have already mentioned the features of LVM.

  3. Mohd Anas
    February 6th, 2009 at 06:35 | #3

    Reduce size of logical volumes in RHEL5:

    Following example assumes that you already have created a Logical Volume (/dev/volgrp1/logvol1) of some size (say 100M).

    1- Unmount the logical volume if it s already mounted.
    #umount /mount-point

    2- Run e2fsck -f to force check any errors in that volume.
    #e2fsck -f /dev/volgrp1/logvol1

    3- Run ‘resize2fs’ to resize the ext3/ext2 file system of new size.
    #resize2fs /dev/volgrp1/logvol1 40M
    (Note: 40M will be the new size of logical volume).

    4- Run ‘lvreduce’ to resize the logical volume.
    #lvreduce -L -60M /dev/volgrp1/logvol1
    Note: -60M is taken because in resize2fs cmd we specified that the new size of filesystem will be 40M.

    5- Run ‘lvdisplay’ to check the size of logical volume.

    6- Mount the Logical volume again and run ‘df’ cmd to check its new size.
    #mount /dev/volgrp1/logvol1 /mount-point
    #df -hT

  1. No trackbacks yet.

I'm happy to use Increase Sociability.