< Back to index

LVM is an implementation of a logical volume manager for the Linux kernel. It was originally written in 1998 by Heinz Mauelshagen, who based its design on that of the LVM in HP-UX.

The installers for the Fedora, SuSE and Debian distributions are LVM-aware and can install a bootable system with a root filesystem on an logical volume (LV).

The LVM can:
* Resize volume groups (VG) online by absorbing new physical volumes (PV) or ejecting existing ones.
* Resize LVs online by concatenating extents onto them or truncating extents from them.
* Create read-only snapshots of LVs (LVM1).
* Create read-write snapshots of LVs (LVM2).
* Stripe whole or parts of LVs across multiple PVs, in a fashion similar to RAID0.
* Move online logical volumes between PVs.
* Split or merge VGs in situ (as long as no LVs span the split). This can be useful when migrating whole LVs to or from offline storage.

It cannot:
* Mirror whole or parts of LVs, in a fashion similar to RAID1 or RAID5 mirroring of LVs. For this, it is recommended that one use the Linux software RAID driver to mirror the underlying PVs to achieve redundancy.

Implementation



LVM keeps a metadata header at the start of every PV, each of which is uniquely identified by a UUID. Each PV's header is a complete copy of the entire volume group's layout, including the UUIDs of all other PV, the UUIDs of all logical volumes and an allocation map of PEs to LEs.

In the 2.6-series Linux kernels, the LVM is implemented in terms of the device mapper, a block-level scheme for creating virtual block devices and mapping their contents onto other block devices. This minimizes the amount of the relatively hard-to-debug kernel code needed to implement the LVM and also allows its I/O redirection services to be shared with other volume managers (such as EVMS).

Any LVM-specific code is pushed out into its user-space tools. To bring a VG online, for example, the "vgchange" tool:

# Searches for PVs in all available block devices.
# Parses the metadata header in each PV found.
# Computes the layouts of all visible VGs.

# Loops over each LV in the VG to be brought online and:
## Checks if the LV to be brought online has all its PVs visible.
## Creates a new, empty device mapping.
## Maps it (with the "linear" target) onto the data areas of the PVs the LV belongs to.

To move an online LV between PVs, the "pvmove" tool:

# Creates a new, empty device mapping for the destination.
# Applies the "mirror" target to the original and destination maps. The kernel will start the mirror in "degraded" mode and begin copying data from the original to the destination to bring it into sync.
# Replaces the original mapping with the destination when the mirror comes into sync, then destroys the original.

These device mapper operations take place transparently, without applications or filesystems being aware that their underlying storage is moving.
This entry uses material from from Wikipedia, the leading user-contributed encyclopedia. It is licensed under the GNU Free Documentation License. Disclaimer.