ArticleslgStudy

computer science

Logical Volume Manager (Linux)

Logical Volume Manager (Linux) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Logical Volume Manager (Linux) rather than just read about it. In short: In Linux, Logical Volume Manager (LVM) is a device mapper framework that provides logical volume management for the Linux kernel. Most modern Linux distributions are LVM-aware to the point of being able to have their root file systems on a logical volume.

Logical Volume Manager (Linux) — main illustration
Logical Volume Manager (Linux) — illustration

Key takeaways

  • Logical Volume Manager (Linux) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Logical Volume Manager (Linux) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Logical Volume Manager (Linux) from memory before moving on to harder problems.

Reference excerpt

In Linux, Logical Volume Manager (LVM) is a device mapper framework that provides logical volume management for the Linux kernel. Most modern Linux distributions are LVM-aware to the point of being able to have their root file systems on a logical volume. Heinz Mauelshagen wrote the original LVM code in 1998, when he was working at Sistina Software, taking its primary design guidelines from the HP-UX's volume manager.

Uses LVM is used for the following purposes:

Creating single logical volumes of multiple physical volumes or entire hard disks (somewhat similar to RAID 0, but more similar to JBOD), allowing for dynamic volume resizing. Managing large hard disk farms by allowing disks to be added and replaced without downtime or service disruption, in combination with hot swapping. On small systems (like a desktop), instead of having to estimate at installation time how big a partition might need to be, LVM allows filesystems to be easily resized as needed. Performing consistent backups by taking snapshots of the logical volumes. Encrypting multiple physical partitions with one password. LVM can be considered as a thin software layer on top of the hard disks and partitions, which creates an abstraction of continuity and ease-of-use for managing hard drive replacement, repartitioning and backup.

Features

Basic functionality Volume groups (VGs) can be resized online by absorbing new physical volumes (PVs) or ejecting existing ones. Logical volumes (LVs) can be resized online by concatenating extents onto them or truncating extents from them. LVs can be moved between PVs. Creation of read-only snapshots of logical volumes (LVM1), leveraging a copy on write (CoW) feature, or read/write snapshots (LVM2) VGs can be split or merged in situ as long as no LVs span the split. This can be useful when migrating whole LVs to or from offline storage. LVM objects can be tagged for administrative convenience. VGs and LVs can be made active as the underlying devices become available through use of the lvmetad daemon.

Advanced functionality Hybrid volumes can be created using the dm-cache target, which allows one or more fast storage devices, such as flash-based SSDs, to act as a cache for one or more slower hard disk drives. Thinly provisioned LVs can be allocated from a pool. On newer versions of device mapper, LVM is integrated with the rest of device mapper enough to ignore the individual paths that back a dm-multipath device if devices/multipath_component_detection=1 is set in lvm.conf. This prevents LVM from activating volumes on an individual path instead of the multipath device.

RAID LVs can be created to include RAID functionality, including RAID 1, 5 and 6. Entire LVs or their parts can be striped across multiple PVs, similarly to RAID 0. A RAID 1 backend device (a PV) can be configured as "write-mostly", resulting in reads being avoided to such devices unless necessary. Recovery rate can be limited using lvchange --raidmaxrecoveryrate and lvchange --raidminrecoveryrate to maintain acceptable I/O performance while rebuilding a LV that includes RAID functionality.

High availability The LVM also works in a shared-storage cluster in which disks holding the PVs are shared between multiple host computers, but can require an additional daemon to mediate metadata access via a form of locking.

CLVM A distributed lock manager is used to broker concurrent LVM metadata accesses. Whenever a cluster node needs to modify the LVM metadata, it must secure permission from its local clvmd, which is in constant contact with other clvmd daemons in the cluster and can communicate a desire to get a lock on a particular set of objects. HA-LVM Cluster-awareness is left to the application providing the high availability function. For the LVM's part, HA-LVM can use CLVM as a locking mechanism, or can continue to use the default file locking and reduce "collisions" by restricting access to only those LVM objects that have appropriate tags. Since this simpler solution avoids contention rather than mitigating it, no concurrent accesses are allowed, so HA-LVM is considered useful only in active-passive configurations. lvmlockd As of 2017, a stable LVM component that is designed to replace clvmd by making the locking of LVM objects transparent to the rest of LVM, without relying on a distributed lock manager. It saw massive development during 2016. The above described mechanisms only resolve the issues with LVM's access to the storage. The file system selected to be on top of such LVs must either support clustering by itself (such as GFS2 or VxFS) or it must only be mounted by a single cluster node at any time (such as in an active-passive configuration).

Volume group allocation policy LVM VGs must contain a default allocation policy for new volumes created from it. This can later be changed for each LV using the lvconvert -A command, or on the VG itself via vgchange --alloc. To minimize fragmentation, LVM will attempt the strictest policy (contiguous) first and then progress toward the most liberal policy defined for the LVM object until allocation finally succeeds. In RAID configurations, almost all policies are applied to each leg in isolation. For example, even if a LV has a policy of cling, expanding the file system will not result in LVM using a PV if it is already used by one of the other legs in the RAID setup. LVs with RAID functionality will put each leg on different PVs, making the other PVs unavailable to any other given leg. If this was the only option available, expansion of the LV would fail. In this sense, the logic behind cling will only apply to expanding each of the individual legs of the array. Available allocation policies are:

Contiguous – forces all LEs in a given LV to be adjacent and ordered. This eliminates fragmentation but severely reduces a LV expandability. Cling – forces new LEs to be allocated only on PVs already used by an LV. This can help mitigate fragmentation as well as reduce vulnerability of particular LVs should a device go down, by reducing the likelihood that other LVs also have extents on that PV. Normal – implies near-indiscriminate selection of PEs, but it will attempt to keep parallel legs (such as those of a RAID setup) from sharing a physical device. Anywhere – imposes no restrictions whatsoever. Highly risky in a RAID setup as it ignores isolation requirements, undercutting most of the benefits of RAID. For linear volumes, it can result in increased fragmentation.

Implementation

… excerpt ends here. Continue reading the full article.

Illustrations

Logical Volume Manager (Linux): Basic example of an LVM head
Basic example of an LVM head
Logical Volume Manager (Linux): Inner workings of the version 1 of LVM.  In this diagram, PE stands for a Physical Extent.
Inner workings of the version 1 of LVM. In this diagram, PE stands for a Physical Extent.

Worked examples

Example 1 — a first encounter with Logical Volume Manager (Linux)

Start with the simplest possible case. Write down what Logical Volume Manager (Linux) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Logical Volume Manager (Linux) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Logical Volume Manager (Linux) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Logical Volume Manager (Linux)

In research
Logical Volume Manager (Linux) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Logical Volume Manager (Linux) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Logical Volume Manager (Linux) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Linux file system-related software, Linux kernel features, Red Hat software, so understanding it makes those chapters shorter.
In everyday life
Look for Logical Volume Manager (Linux) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Logical Volume Manager (Linux)” →

How to study Logical Volume Manager (Linux) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Logical Volume Manager (Linux) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Logical Volume Manager (Linux) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Logical Volume Manager (Linux) in simple terms?

In Linux, Logical Volume Manager (LVM) is a device mapper framework that provides logical volume management for the Linux kernel. Most modern Linux distributions are LVM-aware to the point of being able to have their root file systems on a logical volume.

Why does Logical Volume Manager (Linux) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Logical Volume Manager (Linux)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Logical Volume Manager (Linux).

Tags

  • Linux file system-related software
  • Linux kernel features
  • Red Hat software
  • Volume manager

Keep exploring