Courseiva
EX200Chapter 10 of 20Objective 3.1

Managing Storage with LVM and Partitions

If you don't understand how to flexibly manage storage, you will eventually lose data when a partition fills up and the system crashes. This chapter shows you how to use LVM to treat storage like a pool of water, not a fixed block of ice. For EX200, you must know how to create, resize, and remove logical volumes because the exam will ask you to double a volume's size without rebooting.

12 min read
Advanced
Updated Jul 23, 2026
Reviewed by Johnson Ajibi· Senior Network & Security Engineer · MSc IT Security

A simple way to picture Managing Storage with LVM and Partitions

The Building Renovation Analogy

Your apartment building has 2 floors, each with 6 rooms. You need to create 4 new offices without knocking down walls.

This is exactly like physical hard drives (the building's floors) with fixed room sizes (partitions). But the building manager gives you a magic wall (LVM) that lets you rearrange rooms without demolition.

First, you build a "volume group" (a pool of rooms from both floors). From this pool, you create "logical volumes" (your new offices) that can be any size, even spanning across floors. When one office needs more space, you grab an empty bedroom from the pool and add it to the office without anyone moving out.

Without LVM, if you needed more space, you'd have to rip out a wall (repartition the disk), lose everything stored there, and start over. With LVM, you just shout "Hey, John, move your stuff from room 12 into the pool" (extend the logical volume) and your office grows instantly.

The magic wall (LVM) sits between your actual physical floors (disks) and the rooms you use (logical volumes). It translates every request: "Office 3 needs 2 more desks" becomes "Take 2 desks from the 3rd floor pool."

How It Actually Works

Let us start with the basics. A hard drive (like a 500GB SSD) is a physical disk. On that disk, you create partitions. A partition is a contiguous section of the disk. For decades, partitions were fixed: you create a 50GB partition for the operating system, a 200GB partition for data, etc. If you ran out of space in the data partition, you had to repartition the whole disk, which meant backing everything up, deleting the partition, creating a new bigger one, and restoring the data. This is painful.

LVM stands for Logical Volume Manager. It is a software layer that decouples the physical storage from the logical storage. Think of it this way: instead of cutting a pizza (the disk) into slices (partitions) that cannot be unsliced, LVM lets you pour ingredients (physical blocks) into a big bowl (volume group) and then ladle out portions (logical volumes) that can be changed anytime.

Here are the three key LVM components you need to remember for EX200:

Physical Volume (PV): A hard drive, or a partition on a hard drive, that LVM recognises. You initialise it with the command pvcreate. Example: /dev/sdb becomes a PV.

Volume Group (VG): A pool of storage created by combining one or more PVs. You create it with vgcreate. Example: vg_data is a volume group made from two 500GB disks, giving 1TB of pool space.

Logical Volume (LV): A virtual partition that you carve out from the VG. You create it with lvcreate. Example: lv_home is a 200GB logical volume mounted at /home. You can extend it later without touching the underlying physical disks.

Why does LVM exist? It solves three big problems:

1.

Flexibility: You can grow or shrink an LV while the system is running. No downtime.

2.

Snapshot capability: You can take a snapshot of an LV at an instant, which is a point-in-time copy used for backups.

3.

Spanning: An LV can be larger than a single physical disk because it spans across multiple PVs.

The old way (without LVM) is called MBR partitions or GPT partitions. MBR stands for Master Boot Record, an old standard limited to 2TB disks and four primary partitions. GPT stands for GUID Partition Table, a newer standard that supports disks larger than 2TB and up to 128 partitions. Even GPT partitions are fixed in size once created.

Here is how you set up LVM step-by-step:

First, you prepare the disk. If it is a new disk (say /dev/sdc), you can create a partition covering the whole disk using fdisk or gdisk. Or you can use the whole disk as a PV without partitioning (called "whole-disk PV"). EX200 often tests the whole-disk PV approach because it is simpler.

Second, create the PV: pvcreate /dev/sdc. This adds LVM metadata to the disk headers.

Third, create the VG: vgcreate vg_name /dev/sdc. You can add more PVs later with vgextend.

Fourth, create the LV: lvcreate -L 10G -n lv_name vg_name. The -L flag sets the size, -n sets the name.

Fifth, format the LV with a filesystem: mkfs.ext4 /dev/vg_name/lv_name.

Sixth, mount it: mount /dev/vg_name/lv_name /mount_point.

To make the mount permanent, add an entry to /etc/fstab.

When you need more space, you extend the LV with lvextend -L +5G /dev/vg_name/lv_name. Then you resize the filesystem with resize2fs (for ext4) or xfs_growfs (for XFS). Without LVM, you would have to move data, delete the partition, recreate it, and restore. This is why IT professionals love LVM.

Deleting is the reverse: unmount, delete LV with lvremove, remove VG with vgremove, and remove PV with pvremove.

EX200 will also test thin provisioning, where you can create an LV that appears larger than the available physical space but only consumes space as data is written. This is like a hotel that has 50 rooms but sells 100 room reservations, betting not everyone shows up.

Finally, a key detail: the logical volume device path is /dev/vg_name/lv_name. The exam uses this path constantly.

Now you know what LVM replaces: it replaces rigid, painful partition resizing with flexible, online storage management. Memorise the three tiers: PV -> VG -> LV. That is the exam's favourite structure.

The flow from physical disk to mounted logical volume, showing how multiple disks can be pooled into a volume group.

Walk-Through

1

Prepare the Disk

Use `fdisk` or `gdisk` to create a partition with type 8e (Linux LVM) on the new disk. Or use the whole disk directly (skip partition creation). This step ensures LVM recognises the device.

2

Create the Physical Volume

Run `pvcreate /dev/sdb1` (or `/dev/sdb` if whole-disk). This writes LVM metadata to the device headers. Use `pvs` to verify.

3

Create the Volume Group

Run `vgcreate vg_data /dev/sdb1`. This creates a pool named `vg_data` containing the PV. Use `vgs` to check. You can add more PVs later with `vgextend`.

4

Create the Logical Volume

Run `lvcreate -L 500M -n lv_home vg_data`. This creates a 500MB LV named `lv_home`. Use `lvs` to confirm. The LV path is `/dev/vg_data/lv_home`.

5

Format and Mount the Logical Volume

Run `mkfs.ext4 /dev/vg_data/lv_home` to create a filesystem. Then `mount /dev/vg_data/lv_home /mnt/data`. Finally, add an entry to `/etc/fstab` so it mounts on boot.

What This Looks Like on the Job

Imagine you work as a junior sysadmin for a company called "DataFlow Ltd". They have two 1TB physical disks in a server running a database. The database is growing at 20GB per month. Six months ago, you carved out a 200GB partition for the database logs. Last week, the logs filled up and the database crashed. The on-call engineer had to restore from a backup, losing four hours of transactions. The boss is furious.

You decide to implement LVM to prevent this happening again. Here is exactly what you do:

First, you back up the existing data. Always. Then you repartition both disks so each has one big partition using LVM flag (type 8e in fdisk). You create a volume group called vg_database. You add both disks: vgextend vg_database /dev/sda1 and vgextend vg_database /dev/sdb1. Now your pool is 2TB.

Second, you create two logical volumes: lv_data of 1.2TB for the actual database files, and lv_logs of 400GB for the logs. You format each with mkfs.xfs because the developers prefer XFS. You mount them to /var/lib/mysql and /var/log/mysql respectively.

Third, you add entries to /etc/fstab so they mount automatically on reboot. You test by rebooting the server.

Six months later, the logs are growing faster than expected. They are at 380GB out of 400GB. You decide to extend lv_logs by 200GB. You run:

lvextend -L +200G /dev/vg_database/lv_logs xfs_growfs /mount/logs

No reboot, no downtime, no backup restore. The database keeps running. The boss is happy.

In another scenario, a development team needs a temporary 50GB volume for testing. You create a thin pool and a thin logical volume: lvcreate -T vg_database/thin_pool -L 100G then lvcreate -V 50G -n lv_test -T vg_database/thin_pool. The volume only uses as much disk as the test data actually occupies. When the testing finishes, you delete the thin LV and the thin pool. The space returns to the volume group.

Real IT professionals also use LVM for: - Snapshots: Before patching a production system, take a snapshot of the root volume. If the patch breaks something, roll back in seconds. - Migration: Move data between disks without downtime. Add a new PV, move data from old PV with pvmove, remove old PV. - Disaster recovery: Back up the LVM metadata with vgcfgbackup. If disaster strikes, restore metadata instantly.

The bottom line: LVM turns storage from a fixed resource into a flexible, on-demand pool. For a junior sysadmin on EX200, knowing how to create, extend, and remove LVM volumes is the difference between passing and failing the lab.

How EX200 Actually Tests This

EX200 tests LVM heavily. Expect multiple tasks in the performance-based section where you must configure LVM from scratch. The exam expects you to demonstrate practical skills, not just theory. Here are the exact concepts they love:

Creating LVM stack: You will be given a blank disk (e.g., /dev/vdb). You must create a PV on it, then a VG with a specific name (e.g., vg_exam), then an LV of a specific size (e.g., 500MB) with a specific name (e.g., lv_exam), format it with ext4 or XFS, and mount it at a given mount point (e.g., /mnt/data). They will check df -h and /etc/fstab.

Extending an LV: This is the most common exam trap. They will ask you to extend an existing LV by, say, 200MB. Beginners often forget to resize the filesystem after lvextend. For ext4, you need resize2fs. For XFS, xfs_growfs. If you only do lvextend and skip resize2fs, the LV will show the larger size in lvs but df -h will show the old size. The exam will mark you wrong.

Traps related to PE size: Physical Extents (PEs) are the smallest chunks of storage in LVM, usually 4MB by default. When you create a VG, you can set a different PE size with -s. Exam questions sometimes give you weird sizes (e.g., "500MB LV with PE size 16MB") and you have to calculate that it actually allocates 512MB (32 PEs). They want you to understand that LV size is rounded up to the next PE boundary.

Thin provisioning: The exam may ask you to create a thin pool and a thinly-provisioned logical volume. Remember the syntax: lvcreate -T vg_name/thin_pool -L size then lvcreate -V size -n lv_name vg_name/thin_pool. They love that you understand thin LV shows as larger than the pool.

Removing LVM: You must unmount, remove LV (lvremove), then VG (vgremove), then PV (pvremove). If you try to remove an LV that is still mounted, the command fails. They deliberately leave mounts in place to see if you remember to unmount first.

Display commands: You must know: - pvs: shows PV summary - pvdisplay: detailed PV info - vgs: VG summary - vgdisplay: detailed VG info - lvs: LV summary - lvdisplay: detailed LV info - df -h: check mounted filesystem sizes

Snapshot questions: They may ask you to take a snapshot of an LV, mount it, and verify it contains the same data. Snapshot size is tricky: if you create a snapshot of a 1GB LV, you need at least as much free space in the VG as the anticipated changes. If the snapshot overwrites, it becomes invalid.

Order of operations: The exam requires you to complete steps in the exact order: PV first, then VG, then LV, then filesystem, then mount. Any deviation (e.g., trying to create LV before VG) yields an error. They test whether you know the dependency chain.

Common trap: Deleting a VG that still contains LVs. You must remove all LVs first. The exam presents a scenario where you have to "remove all LVM configuration" and newbies try vgremove straight away and fail.

Key Takeaways

LVM separates physical storage from logical storage, allowing online resizing without data loss.

The three-tier stack is: Physical Volume (PV) -> Volume Group (VG) -> Logical Volume (LV).

After extending an LV, you must also resize the filesystem using resize2fs (ext4) or xfs_growfs (XFS).

A snapshot is a point-in-time copy that consumes space equal to the changes made to the original LV.

Thin provisioning creates an LV that appears larger than the available physical space, but risks out-of-space errors.

Deleting LVM requires unmounting, then removing LV, then VG, then PV in that exact order.

Always mount LVs in /etc/fstab using either the device path (/dev/vg_name/lv_name) or UUID for persistence.

Easy to Mix Up

These come up on the exam all the time. Here's how to tell them apart.

Physical Volume (PV)

A physical disk or partition initialised by LVM.

Cannot be resized once created (you can extend the PV if underlying disk grows).

Created with 'pvcreate' command.

Logical Volume (LV)

A virtual block device carved from a volume group.

Can be extended or reduced online (depending on filesystem).

Created with 'lvcreate' command.

ext4 Filesystem

Can be resized both up and down (shrinking supported).

Resize command: 'resize2fs'.

Older, widely compatible.

XFS Filesystem

Can only be resized up (cannot shrink).

Resize command: 'xfs_growfs'.

Better for large files and parallel operations.

Thick Provisioning

Allocates physical space immediately when LV is created.

LV size matches physical space used.

No risk of out-of-space surprise from over-allocation.

Thin Provisioning

Allocates physical space only as data is written.

LV appears larger than actual physical usage.

Risk of the pool running out of space if over-allocated.

Snapshot LV

A point-in-time copy of another LV.

Consumes space equal to changes made to the original.

Used for backups or rollback scenarios.

Normal LV

A standard block device for data storage.

Consumes the full allocated space immediately (unless thin).

Used for general data storage.

Watch Out for These

Mistake

Logical volumes are the same as partitions.

Correct

Logical volumes are flexible virtual partitions; real partitions are fixed in size once created.

Beginners hear 'volume' and think it is a partition, but LVM volumes can be resized online, while partitions require repartitioning.

Mistake

After extending an LV, the filesystem automatically grows.

Correct

You must manually resize the filesystem using resize2fs (ext4) or xfs_growfs (XFS) after extending the LV.

LVM operates at the block level, independent of filesystems. The filesystem doesn't know the LV got bigger.

Mistake

You can create a volume group on a disk without first making it a physical volume.

Correct

A disk must be initialised as a physical volume (pvcreate) before adding it to a volume group.

LVM needs metadata headers on the disk to track which blocks belong to which VG; pvcreate writes that metadata.

Mistake

Thin provisioning means you never have to worry about running out of physical space.

Correct

Thin provisioning allows over-allocation, but if the pool fills up, the filesystem becomes read-only or corrupt.

Beginners think 'thin' means 'unlimited', but it is a gamble that not all space will be used simultaneously.

Mistake

You cannot shrink an XFS filesystem on an LV.

Correct

XFS cannot be shrunk. ext4 can be shrunk (with care). This is a key exam distinction.

The exam often asks you to shrink an LV; if it's XFS, it's impossible; you must recreate or use ext4.

Do You Actually Know This?

Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.

Frequently Asked Questions

What is the difference between a physical partition and a logical volume?

A physical partition is a fixed-size slice of a hard drive. A logical volume (from LVM) is a flexible block device that can be resized online without downtime.

How do I extend an LVM logical volume?

First extend the LV with `lvextend -L +5G /dev/vg_name/lv_name`, then resize the filesystem with `resize2fs` (ext4) or `xfs_growfs` (XFS).

Can I shrink an LVM volume?

Yes, but only if the filesystem supports shrinking (ext4) and you unmount it first. XFS cannot be shrunk.

What is a snapshot in LVM?

A snapshot is a point-in-time copy of a logical volume. It allows you to revert changes or create backups without downtime.

What happens if I delete a volume group without removing its logical volumes first?

The command fails. You must remove all LVs with `lvremove` before you can delete the VG with `vgremove`.

How do I check the size of a logical volume?

Use `lvs` for a summary or `lvdisplay /dev/vg_name/lv_name` for detailed info. Also `df -h` shows the filesystem size.

Keep going

You've finished Managing Storage with LVM and Partitions. Continue through the EX200 study guide to build a complete picture of the exam.

Done with this chapter?