Blog » Linux » How to Use LVM in Linux: The Storage Management Tool Every Admin Needs
› how-to-use-lvm-in-linux Linux server with hard drives illustrating LVM storage management layers

How to Use LVM in Linux: The Storage Management Tool Every Admin Needs

Table of Contents

If you’ve ever run out of disk space on a Linux server and wished you could just stretch your partition without reformatting, you need to learn how to use LVM in Linux. Logical Volume Manager turns rigid, fixed-size partitions into flexible storage pools that grow and shrink on command. Once you start using it, you’ll wonder how you ever managed without it.

I still remember the exact moment LVM clicked for me. I was running a Proxmox homelab on a single 500GB drive. One afternoon, my containers started failing because /var was full. With traditional partitions, I’d be looking at hours of downtime and probably a full reinstall. Instead, I popped in a spare drive, added it to my volume group, and extended the logical volume in about 90 seconds. No downtime. No data loss.

This guide walks you through the entire LVM workflow. Whether you’re coming from traditional disk partitioning or setting up your first server, you’ll have practical LVM skills by the end.

What Is LVM and Why Should You Use It?

LVM stands for Logical Volume Manager. It’s a storage abstraction layer between your physical disks and filesystems. Instead of carving a disk into fixed partitions, LVM pools storage from one or more disks into a flexible container you can slice however you want.

  • Dynamic resizing: Grow or shrink volumes without unmounting
  • Span multiple disks: Combine several drives into one logical pool
  • Snapshots: Create point-in-time copies for backups or testing
  • No downtime: Resize storage while applications keep running
  • Hot-swap capable: Migrate data between disks with pvmove

LVM isn’t always necessary. For a simple desktop with one drive, traditional partitioning works fine. LVM shines on servers, homelabs, and any system where storage needs change over time.

RackNerd Mobile Leaderboard Banner

Get a VPS from as low as $11/year! WOW!

Understanding LVM Architecture: The Three-Layer Stack

LVM uses a three-layer model. Once you understand these layers, everything else falls into place.

Physical Volumes (PVs): Your Raw Storage

A Physical Volume is any block device (whole disk or partition) initialized for LVM use. You take a raw disk like /dev/sdb and stamp it as “available for LVM.”

Volume Groups (VGs): Pooling Storage Together

A Volume Group combines one or more PVs into a single storage pool. Got a 100GB drive and a 200GB drive? Combine them into one 300GB volume group. VGs divide storage into small chunks called Physical Extents (PEs), typically 4MB each.

Logical Volumes (LVs): Your Usable Partitions

Logical Volumes are carved from a VG and are what you actually format and mount. The key difference from partitions: you can resize them on the fly.

Quick Mental Model

Physical Volumes = bricks → Volume Groups = the wall → Logical Volumes = rooms carved from the wall. Add more bricks to make the wall bigger, then expand the rooms.

Prerequisites: What You Need Before Starting

  • Root or sudo access on your system
  • The lvm2 package: sudo apt install lvm2 or sudo dnf install lvm2
  • An available disk or partition without data you need

⚠ Important Limitation

Your /boot partition cannot live on LVM. Most bootloaders can’t read LVM volumes during early boot. Keep /boot on a standard partition.

Step 1: Creating Physical Volumes with pvcreate

Identifying Available Disks

Run lsblk to see your block devices and find disks without mount points. In this example, /dev/sdb is our target.

Initializing Physical Volumes

sudo pvcreate /dev/sdb

Verifying PV Creation

sudo pvs
sudo pvdisplay /dev/sdb

You should see your new PV listed with its size. If you get a “Device not found” error, double-check the path with lsblk.

Step 2: Creating Volume Groups with vgcreate

Creating Your First Volume Group

sudo vgcreate vg_data /dev/sdb

Adding Multiple PVs to a VG

# At creation time
sudo vgcreate vg_data /dev/sdb /dev/sdc

# Or add to existing VG later
sudo vgextend vg_data /dev/sdd

Checking VG Status

sudo vgs
sudo vgdisplay vg_data

Use the df command alongside vgs for the full storage picture.

Step 3: Creating Logical Volumes with lvcreate

Creating LVs with Specific Sizes

sudo lvcreate -L 50G -n lv_home vg_data

Using All Available Space

sudo lvcreate -l 100%FREE -n lv_storage vg_data

I’d recommend leaving 10-15% free in your VG for snapshots and future flexibility. You’ll thank yourself later.

Creating Multiple Logical Volumes

sudo lvcreate -L 30G -n lv_databases vg_data
sudo lvcreate -L 100G -n lv_media vg_data
sudo lvcreate -L 20G -n lv_logs vg_data

Verify with sudo lvs or sudo lvdisplay.

Step 4: Formatting and Mounting Your Logical Volumes

# ext4 (supports grow and shrink)
sudo mkfs.ext4 /dev/vg_data/lv_home

# XFS (high performance, but can only grow)
sudo mkfs.xfs /dev/vg_data/lv_databases

Mount it:

sudo mkdir -p /mnt/home_data
sudo mount /dev/vg_data/lv_home /mnt/home_data

For a deeper walkthrough, see my guide on mounting disks in Linux. For persistence across reboots, add to /etc/fstab:

/dev/vg_data/lv_home  /mnt/home_data  ext4  defaults  0  2

After mounting, set proper ownership with the chown command and review Linux file permissions. For automounting with systemd, check my systemctl guide.

Extending Logical Volumes: Adding More Space

This is where LVM truly earns its keep.

Extending from Existing VG Space

sudo lvextend -L +20G /dev/vg_data/lv_home

Adding New Physical Volumes to Expand

sudo pvcreate /dev/sdd
sudo vgextend vg_data /dev/sdd
sudo lvextend -L +100G /dev/vg_data/lv_home

If you need to diagnose what’s eating space first, check out troubleshooting disk space issues. The du command is invaluable for pinpointing large directories.

Resizing the Filesystem

Extending the LV doesn’t automatically grow the filesystem:

# For ext4:
sudo resize2fs /dev/vg_data/lv_home

# For XFS:
sudo xfs_growfs /mnt/home_data

# Or do both at once with -r:
sudo lvextend -r -L +20G /dev/vg_data/lv_home

That -r flag is my favorite LVM shortcut. One command instead of two.

I once had a production database server hit 95% capacity at 2 AM. The monitoring alert woke me up, and I extended the volume in under two minutes over SSH from my phone. No service restart, no downtime. Try doing that with traditional partitions.

Reducing Logical Volumes: Shrinking Storage (Proceed with Caution)

🛑 Critical Warning

XFS cannot be shrunk. Only ext3/ext4 supports live shrinking. Always back up before reducing.

For ext4, shrink the filesystem first, then reduce the LV:

sudo umount /mnt/home_data
sudo e2fsck -f /dev/vg_data/lv_home
sudo resize2fs /dev/vg_data/lv_home 30G
sudo lvreduce -L 30G /dev/vg_data/lv_home
sudo mount /dev/vg_data/lv_home /mnt/home_data

The order matters. Shrinking the LV before the filesystem corrupts data. Make sure you have solid automatic backup strategies in place first.

LVM Snapshots: Point-in-Time Backups

Snapshots freeze a logical volume’s state at a specific moment:

sudo lvcreate -s -L 10G -n lv_home_snap /dev/vg_data/lv_home

The 10GB is the change buffer storing differences from the original. Snapshots are copy-on-write, so they’re fast to create and space-efficient.

  • Pre-upgrade backups: Snapshot before updates, roll back if something breaks
  • Database backups: Snapshot the DB volume, mount read-only, run backup
  • Testing changes: Try something risky, revert instantly if it fails

Remove when done:

sudo lvremove /dev/vg_data/lv_home_snap

Combine snapshots with rsync for data migration to copy contents to remote storage.

Common LVM Commands Cheat Sheet

Task Command
List PVs pvs / pvdisplay
List VGs vgs / vgdisplay
List LVs lvs / lvdisplay
Create PV pvcreate /dev/sdX
Create VG vgcreate vg_name /dev/sdX
Create LV lvcreate -L 50G -n lv_name vg_name
Extend LV lvextend -r -L +20G /dev/vg/lv
Reduce LV lvreduce -L 30G /dev/vg/lv
Snapshot lvcreate -s -L 10G -n snap /dev/vg/lv
Remove LV lvremove /dev/vg/lv
Move data pvmove /dev/sdX /dev/sdY

Notice the pattern: pv, vg, and lv prefixes combined with create, display, extend, reduce, remove, and scan. Learn one family, and you know them all.

Troubleshooting Common LVM Issues

Volume Group Not Found

sudo vgscan
sudo vgchange -ay

This scans for volume groups and activates them.

Cannot Extend LV Even with Free VG Space

sudo pvs -o+pv_used,pv_free

Free extents might be spread across PVs in a way that doesn’t meet allocation requirements. Try specifying which PV to allocate from.

Cannot Unmount for Reduction

sudo lsof +D /mnt/home_data

Check my guide on managing processes to handle blocking processes. The find command helps locate large files keeping handles open.

Snapshot Running Out of Space

sudo lvs -o lv_name,data_percent,snap_percent

If a snapshot hits 100%, it becomes invalid. For regular checking disk usage, set up a cron job to monitor utilization.

LVM Best Practices for System Administrators

“LVM offers more flexibility compared to direct physical storage usage, and the hardware storage configuration is hidden from the software so you can resize and move it without stopping applications or unmounting file systems, which can reduce operational costs.” — Red Hat Enterprise Linux Documentation

After years of managing LVM on everything from homelabs to production servers, here’s what I’ve learned:

  • Leave 10-15% free in your VG for snapshots and unexpected growth
  • Use descriptive names: vg_data, lv_databases beat vg0, lv1 at 2 AM
  • Document your layout: Run pvs && vgs && lvs and save the output
  • Monitor regularly: Use Bash scripting to alert on VG free space
  • Always back up before reduction operations
  • Don’t span LVs across non-redundant disks without RAID underneath

For deeper reference, the Arch Linux LVM Wiki is outstanding. And DigitalOcean’s LVM concepts guide provides a solid conceptual foundation.

Start Using LVM Today

Learning how to use LVM in Linux is a skill that pays dividends the moment you need it. The flexibility to resize storage live, take instant snapshots, and pool multiple disks makes it essential for any Linux admin.

My recommendation: set up a test VM, attach a couple of virtual disks, and walk through every command here. Break things on purpose. Fill a volume to 100% and practice extending it. The muscle memory you build now will save you when production issues hit at the worst time.

If you’re building on this foundation, start with my disk partitioning guide for the traditional approach, or dive into automatic backup strategies to pair with your new LVM snapshot skills.

author avatar
Alexa Velinxs
I'm Alexa Velinxs, a cryptocurrency trading expert passionate about demystifying digital assets for both beginners and seasoned investors. Through my writing, I share actionable strategies, market insights, and practical tips to help you navigate the crypto landscape with confidence. Let's explore the future of finance together.
Related Posts