Archive

Archive for January 16th, 2009

LVM (Logical Volume Manager)

January 16th, 2009 3 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

Features

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: