0Pricing
Linux Server Deployment & SSH Mastery · Lesson

Logical Volume Management (LVM)

Move past fixed partitions with LVM: pool physical disks, carve flexible logical volumes, and resize storage on the fly so your server can grow without downtime or repartitioning.

Logical Volume Management (LVM) is a free Linux Server Deployment & SSH Mastery lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Linux Server Deployment & SSH Mastery learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

The Limits of Fixed Partitions

Traditional partitions have a hard problem: their size is fixed at creation. If a partition fills up, resizing it is risky and often requires downtime.

LVM (Logical Volume Management) solves this by adding a flexible layer between your disks and your file systems, letting you resize and combine storage easily.

The Three LVM Layers

LVM has three concepts that stack on top of each other:

  • Physical Volume (PV) — a disk or partition handed to LVM
  • Volume Group (VG) — a pool combining one or more PVs
  • Logical Volume (LV) — a flexible 'partition' carved from a VG

You format and mount the LV like a normal partition.

Creating Physical Volumes

The first step is to mark disks as PVs with pvcreate. This writes LVM metadata onto them.

pvs lists your physical volumes.

sudo pvcreate /dev/sdb /dev/sdc
sudo pvs

Creating a Volume Group

Next, pool the PVs into a VG with vgcreate, giving it a name. The VG's capacity is the sum of its PVs.

vgs shows volume groups and their free space.

sudo vgcreate data_vg /dev/sdb /dev/sdc
sudo vgs

Creating Logical Volumes

Now carve a logical volume from the group with lvcreate. Specify a size with -L (or use -l 100%FREE to take all remaining space) and a name with -n.

sudo lvcreate -L 20G -n web_lv data_vg
sudo lvs

Formatting and Mounting an LV

An LV behaves like any block device. Its path is /dev/<vg>/<lv>. Format it, then mount it where you need the storage.

sudo mkfs.ext4 /dev/data_vg/web_lv
sudo mkdir -p /srv/web
sudo mount /dev/data_vg/web_lv /srv/web

Growing a Logical Volume

This is LVM's headline feature. If a VG has free space, extend an LV with lvextend and grow the file system at the same time using -r — all while it stays mounted.

sudo lvextend -L +10G -r /dev/data_vg/web_lv

Adding More Disk to the Pool

Out of free space in the VG? Add a new disk: make it a PV, then extend the VG with vgextend. The new capacity becomes available to all LVs in the group.

sudo pvcreate /dev/sdd
sudo vgextend data_vg /dev/sdd
sudo vgs

Snapshots

LVM can take point-in-time snapshots of an LV — great for safe backups. A snapshot starts tiny and only stores changed blocks.

Back up from the snapshot, then remove it when done.

sudo lvcreate -L 2G -s -n web_snap /dev/data_vg/web_lv
# ...take backup from the snapshot...
sudo lvremove /dev/data_vg/web_snap

Making Mounts Persistent

As with any file system, add the LV to /etc/fstab so it mounts at boot. Using the device-mapper path or its UUID both work.

/dev/data_vg/web_lv  /srv/web  ext4  defaults  0  2

Best Practices

Run LVM smoothly:

  • Leave some free space in the VG for snapshots and growth
  • Always use lvextend -r so the file system grows too
  • Name VGs and LVs descriptively (e.g. data_vg/web_lv)
  • Snapshot before risky upgrades

Quick Check

Test your LVM understanding.

Recap

You can now manage flexible storage with LVM:

  • pvcreatevgcreatelvcreate to build the stack
  • lvextend -r to grow volumes live
  • vgextend to add disks to the pool
  • Snapshots for safe backups

LVM removes the rigidity of fixed partitions, letting server storage grow on demand.

Frequently asked questions

Is the “Logical Volume Management (LVM)” lesson free?

Yes — the full text of “Logical Volume Management (LVM)” is free to read here on the web, and the Linux Server Deployment & SSH Mastery course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Linux Server Deployment & SSH Mastery course, upgrade to CoddyKit PRO.

What will I learn in “Logical Volume Management (LVM)”?

Move past fixed partitions with LVM: pool physical disks, carve flexible logical volumes, and resize storage on the fly so your server can grow without downtime or repartitioning. You practise Linux Server Deployment & SSH Mastery with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Linux Server Deployment & SSH Mastery?

No prior experience is required. Linux Server Deployment & SSH Mastery on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Logical Volume Management (LVM)” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Linux Server Deployment & SSH Mastery lesson?

Yes. Every Linux Server Deployment & SSH Mastery lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Disk Partitioning and Formatting
  2. Mounting File Systems
  3. Monitoring Disk Usage
  4. Logical Volume Management (LVM)
← Back to Linux Server Deployment & SSH Mastery