Kahibaro
Discord Login Register

LVM concepts

Why Use LVM?

Logical Volume Manager (LVM) sits between your physical storage (disks/partitions) and the filesystems you create. Instead of rigidly mapping “this partition = this filesystem”, LVM lets you:

LVM is about abstraction and flexibility in storage management.

Core LVM Building Blocks

LVM has three main layers. Understanding these conceptually is the key:

  1. Physical Volumes (PVs)
  2. Volume Groups (VGs)
  3. Logical Volumes (LVs)

Think: PVs → VGs → LVs → Filesystems

Physical Volumes (PV)

A PV is a block device prepared for use by LVM.

Typical PV examples:

Conceptually:

Key idea: A PV is the raw storage supplied to LVM.

Volume Groups (VG)

A VG is a pool of storage created by combining one or more PVs.

Conceptually:

Example layout:

Add/remove PVs to grow/shrink the VG:

Key idea: A VG is a shared storage pool from which you carve out LVs.

Logical Volumes (LV)

An LV is what you use as if it were a partition.

You:

Conceptually:

Key idea: An LV is a flexible “virtual partition”.

Extents: The Fundamental Unit

LVM manages space in fixed-size chunks called extents:

Conceptually:

If a VG has $N$ PEs and each PE is size $S$, then total VG size is:
$$\text{VG size} = N \times S$$

Extents allow:

You usually don’t need to change extent size unless you work with very large volumes.

How LVM Maps Storage

Conceptual mappings:

  1. Physical disk/partition → PV
    • LVM metadata + PEs carved from raw space.
  2. PVs (one or more) → VG
    • All PEs from member PVs are combined into one pool.
  3. VG → LV
    • LVs are defined as sequences of LEs
    • LEs are mapped internally to PEs on specific PVs.

A simplified example:

The LV data may be spread over both disks; the filesystem doesn’t care—LVM handles it.

Allocation Modes: Linear vs Striped

LVM can arrange PEs for an LV in different patterns.

Linear Volumes

Linear LV:

Pros:

Cons:

Use when you want capacity and flexibility more than performance.

Striped Volumes

Striped LV (similar idea to RAID 0):

Conceptual effect:

Pros:

Cons:

Use when you want performance and accept higher risk or when redundancy is handled elsewhere (e.g. on top of RAID).

Common Use Patterns with LVM

Flexible Layouts for System Partitions

Typical use:

Advantages:

Storage Pools for Data

For data servers (files, databases, VMs):

Benefits:

Resizing with LVM: Conceptual View

Resizing involves:

  1. Resizing the LV itself
    • LVM changes the number of LEs assigned to that LV (add/remove extents).
  2. Resizing the filesystem inside the LV
    • Filesystem tools grow or shrink the filesystem to match new LV size.

Conceptually:

Main idea: LVM handles the block layer; filesystem tools handle the data layer.

Snapshots: Point-in-Time Copies

An LVM snapshot is a logical volume that represents the state of another LV at a specific moment.

Conceptually:

Use cases:

Important concept: snapshots need space for changes; they are not free in capacity or performance.

Data Movement and Disk Replacement

One powerful LVM concept is online data relocation.

Moving Data Between PVs

With LVM, logical data is not tied permanently to specific sectors or disks:

Use cases:

Main idea: LVM decouples logical layout from physical location.

LVM and RAID Concepts

LVM integrates with RAID-like concepts (LVM RAID types), but the key concept is:

Conceptual advantage:

Details of RAID levels themselves belong in the RAID-focused chapter; here, you just need to know that LVM can embed RAID-like behavior into LVs.

LVM Architecture Summary

Concept recap:

Mental model:

Views: 21

Comments

Please login to add a comment.

Don't have an account? Register now!