RED HAT ENTERPRISE LINUX
LVM Physical Volumes:
Create and Remove
Create and remove physical volumes
CIS126RH | RHEL System Administration 1
Mesa Community College
Logical Volume Management (LVM) is the standard storage abstraction layer on RHEL. Before logical volumes and filesystems can be created, raw storage — a partition or whole disk — must be initialised as an LVM physical volume (PV). Physical volumes are the foundation of the LVM hierarchy, and knowing how to create, inspect, and remove them is the first required skill in the LVM toolkit. This module is tested on the RHCSA exam.
Learning Objectives
- Explain the LVM architecture — Describe the three-layer LVM hierarchy: physical volumes, volume groups, and logical volumes, and the role each layer plays
-
Prepare a partition for use as a physical volume —
Create a partition with the correct type code and use
pvcreateto initialise it as an LVM physical volume -
Inspect physical volumes —
Use
pvs,pvdisplay, andpvscanto list and examine physical volume details -
Remove physical volumes safely —
Use
pvremoveto uninitialise a physical volume and understand the prerequisites for safe removal
The LVM Three-Layer Architecture
LVM adds a flexible abstraction layer between raw storage and filesystems. The three layers build on each other from bottom to top.
-
Physical Volume (PV) — a partition or whole disk initialised
for LVM use. Divided internally into fixed-size physical extents (PEs).
Commands:
pvcreate,pvs,pvremove -
Volume Group (VG) — one or more PVs pooled together into a
single storage pool. The VG is the unit of administration.
Commands:
vgcreate,vgs,vgremove -
Logical Volume (LV) — a flexible "virtual partition" carved from
VG space. Filesystems are placed on LVs, not on partitions directly.
Commands:
lvcreate,lvs,lvremove
LVM logical volumes can be resized, moved between physical disks, snapshotted, and mirrored — all without the fixed-size constraints of traditional partitions. Almost every RHEL system uses LVM for its root and data filesystems.
LVM Concepts: Physical Extents
A physical volume is divided into fixed-size blocks called physical extents (PEs). Extents are the atoms of LVM storage.
- Default PE size is 4 MiB — set when the volume group is created
- Every LVM allocation happens in whole PE increments
- A 10 GiB PV with 4 MiB PEs contains 2560 physical extents
- Free PEs in a VG can be allocated to logical volumes
- When a PV is added to a VG, its PEs join the VG's free extent pool
# pvdisplay shows PE size and count for a physical volume
$ sudo pvdisplay /dev/sdb1
--- Physical volume ---
PV Name /dev/sdb1
VG Name datavg
PV Size 10.00 GiB
Allocatable yes
PE Size 4.00 MiB
Total PE 2559
Free PE 1024
Allocated PE 1535
PV UUID abc123...
Preparing Storage for LVM
A physical volume can be created on a partition or directly on a whole disk. Using a partition is the standard practice on most systems.
Option A — Use a partition (recommended)
# Create a partition with the LVM type code (8e00 in gdisk)
$ sudo parted --script /dev/sdb \
mklabel gpt \
mkpart primary 1MiB 100%
$ sudo partprobe /dev/sdb
# Then initialise the partition as a PV
$ sudo pvcreate /dev/sdb1
Option B — Use the whole disk (no partition table)
# Initialise the entire disk directly — no partitioning needed
$ sudo pvcreate /dev/sdb
# LVM writes its metadata at the beginning of the disk
Using a partition with the LVM type code (8e00 in gdisk or
Linux LVM in parted) lets other tools recognise the disk's intended
use. The partition also provides alignment and allows the disk to coexist with
other non-LVM partitions.
Creating a Physical Volume: pvcreate
pvcreate writes LVM metadata to the beginning of a partition or disk,
marking it as an LVM physical volume ready to join a volume group.
# Initialise a single partition as a physical volume
$ sudo pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
# Initialise multiple partitions at once
$ sudo pvcreate /dev/sdb1 /dev/sdc1
Physical volume "/dev/sdb1" successfully created.
Physical volume "/dev/sdc1" successfully created.
# Initialise a whole disk as a physical volume
$ sudo pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
# Verify the PV was created
$ sudo pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 rhel lvm2 a-- <17.00g 0
/dev/sdb1 lvm2 --- <10.00g <10.00g
pvcreate writes a small LVM label at the beginning of the device.
It does not create a filesystem or destroy existing data beyond the first few sectors.
The device is now reserved for LVM use.
Listing Physical Volumes: pvs
pvs (physical volume summary) provides a concise one-line-per-PV
listing — the standard first command to check PV status.
# Summary listing of all physical volumes
$ sudo pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 rhel lvm2 a-- <19.00g 0
/dev/sdb1 lvm2 --- <10.00g <10.00g
/dev/sdb2 datavg lvm2 a-- 5.00g 2.00g
# Show additional columns
$ sudo pvs -o +pv_used,pv_free,pv_pe_count,pv_pe_alloc_count
# List all available output fields
$ sudo pvs -o help
| Column | Meaning |
|---|---|
PV | Physical volume device path |
VG | Volume group the PV belongs to (empty = not in a VG) |
Fmt | LVM metadata format (lvm2 is current) |
Attr | Status flags: a=allocatable, -=not in VG |
PSize | Total size of the physical volume |
PFree | Free (unallocated) space on the PV |
Detailed PV Inspection: pvdisplay
pvdisplay shows complete details for one or all physical volumes —
the verbose counterpart to pvs.
# Show details for a specific PV
$ sudo pvdisplay /dev/sdb1
--- Physical volume ---
PV Name /dev/sdb1
VG Name datavg
PV Size 10.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 2559
Free PE 512
Allocated PE 2047
PV UUID Abc123-DE45-fg67-HI89-jk01-LM23-NO45pq
# Show all physical volumes
$ sudo pvdisplay
# Short format — one line summary per PV
$ sudo pvdisplay --short
"/dev/sdb1" is a member of volume group "datavg"
"/dev/sdb2" is NOT a member of any volume group
The Free PE count is the key capacity planning figure. Multiply Free PE by PE Size to get the available free space. When Free PE = 0, the PV is full and no more logical volumes can be allocated from it.
pvscan: Discovering Physical Volumes
pvscan scans all block devices for LVM physical volume metadata
and reports what it finds — useful for confirming LVM sees a new PV.
# Scan all devices for LVM physical volumes
$ sudo pvscan
PV /dev/sda2 VG rhel lvm2 [<19.00 GiB / 0 free]
PV /dev/sdb1 VG datavg lvm2 [10.00 GiB / 2.00 GiB free]
PV /dev/sdb2 lvm2 [5.00 GiB]
Total: 3 [<34.00 GiB] / in use: 2 [<29.00 GiB] / in no VG: 1 [5.00 GiB]
# Scan and cache LVM data (useful after hot-plug)
$ sudo pvscan --cache
# Check if a specific device is a PV
$ sudo pvck /dev/sdb1
Checking physical volume (metadata area #0) of /dev/sdb1.
The total line at the bottom of pvscan output summarises: total PV count and size, PVs in use (assigned to a VG), and PVs not yet in any VG. PVs "in no VG" are initialised but not yet added to a volume group.
What pvcreate Writes
Understanding what pvcreate writes to the disk helps explain
why a PV can be uninitialised with pvremove.
pvcreatewrites a small LVM label in one of the first four sectors of the device- The label contains: a magic signature, the PV UUID, the device size, and a pointer to the metadata area
- The metadata area stores the full LVM configuration including VG membership, LV definitions, and PE allocations
- LVM metadata is stored in a circular text file format — human-readable with
pvck --dump - Removing a PV with
pvremovewipes the label and metadata, leaving the underlying data intact
If run on a partition or disk that contains a filesystem, pvcreate will
overwrite the filesystem header. The data remains on disk but the filesystem is no
longer accessible. Always confirm the target device before running pvcreate.
Removing a Physical Volume: pvremove
pvremove uninitialises a physical volume by wiping its LVM label
and metadata. The device is then no longer recognised as an LVM PV.
# Remove a physical volume that is NOT in any volume group
$ sudo pvremove /dev/sdb2
Labels on physical volume "/dev/sdb2" successfully wiped.
# Confirm it is gone from pvs output
$ sudo pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 rhel lvm2 a-- <19.00g 0
/dev/sdb1 datavg lvm2 a-- <10.00g <2.00g
# /dev/sdb2 no longer appears
# Attempting to remove a PV that is in a VG fails
$ sudo pvremove /dev/sdb1
PV /dev/sdb1 is used by VG datavg so please remove using vgreduce first.
A PV can only be removed if it is not a member of any volume group.
If the PV is in a VG, first move its data with pvmove, then remove it
from the VG with vgreduce, then run pvremove.
Safe PV Removal Sequence
Removing a PV from an active volume group requires moving its data first to preserve the logical volumes that use it.
-
Confirm the PV has used extents
sudo pvs /dev/sdb1— check Allocated PE is non-zero -
Move all data off the PV
sudo pvmove /dev/sdb1— relocates all LEs to other PVs in the VG -
Remove the PV from the volume group
sudo vgreduce datavg /dev/sdb1 -
Uninitialise the PV
sudo pvremove /dev/sdb1 -
Verify the PV is gone
sudo pvs— confirm /dev/sdb1 no longer appears
pvmove moves data from one PV to other PVs in the same VG. The other
PVs must have enough free extents to absorb the moved data. If the VG has no free
space on other PVs, add another PV to the VG before running pvmove.
Extending a VG by Adding a Physical Volume
One of the most common LVM tasks is adding a new PV to an existing volume group to expand its capacity. This is a non-disruptive online operation.
# Current state — VG is nearly full
$ sudo vgs
VG #PV #LV #SN Attr VSize VFree
datavg 1 2 0 wz--n- <10.00g 500.00m
# Step 1: Prepare the new disk/partition
$ sudo parted --script /dev/sdc mklabel gpt mkpart primary 1MiB 100%
$ sudo partprobe /dev/sdc
# Step 2: Initialise as a PV
$ sudo pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created.
# Step 3: Add to the existing volume group
$ sudo vgextend datavg /dev/sdc1
Volume group "datavg" successfully extended
# Confirm the VG now has more free space
$ sudo vgs
VG #PV #LV #SN Attr VSize VFree
datavg 2 2 0 wz--n- <20.00g <10.50g
Physical Volume Commands Quick Reference
| Task | Command |
|---|---|
| Initialise a partition or disk as a PV | sudo pvcreate /dev/sdb1 |
| Initialise multiple devices at once | sudo pvcreate /dev/sdb1 /dev/sdc1 |
| List all PVs (summary) | sudo pvs |
| Detailed PV information | sudo pvdisplay /dev/sdb1 |
| Scan for all PVs on the system | sudo pvscan |
| Check PV metadata integrity | sudo pvck /dev/sdb1 |
| Remove a PV not in any VG | sudo pvremove /dev/sdb1 |
| Move data off a PV (before removal) | sudo pvmove /dev/sdb1 |
| Remove PV from VG (after pvmove) | sudo vgreduce VGNAME /dev/sdb1 |
| Add PV to an existing VG | sudo vgextend VGNAME /dev/sdb1 |
| List all block devices including PVs | lsblk |
| Show PV with custom columns | sudo pvs -o pv_name,pv_size,pv_free,pv_used |
LVM Command Family Overview
LVM commands follow a consistent naming pattern:
pv* for physical volumes, vg* for volume groups,
lv* for logical volumes.
| Layer | Create | List (summary) | List (detail) | Remove |
|---|---|---|---|---|
| Physical Volume | pvcreate |
pvs |
pvdisplay |
pvremove |
| Volume Group | vgcreate |
vgs |
vgdisplay |
vgremove |
| Logical Volume | lvcreate |
lvs |
lvdisplay |
lvremove |
Once you know pvs / pvdisplay for PVs, you automatically
know vgs / vgdisplay for VGs and lvs /
lvdisplay for LVs. The pattern extends to all LVM verbs.
Common Mistakes
| Mistake | What goes wrong | Correct approach |
|---|---|---|
Running pvcreate on the wrong device (e.g. /dev/sda instead of /dev/sdb) |
The system disk's filesystem is overwritten — system becomes unbootable | Run lsblk first and confirm the device before pvcreate |
| Running pvremove on a PV that is in a VG | pvremove rejects the operation with an error message | Run pvmove then vgreduce first to move data and remove from VG |
| Skipping pvmove before vgreduce | Logical volumes using the removed PV become incomplete — data loss | Always pvmove data off a PV before removing it from the VG |
| Forgetting partprobe after creating a partition for LVM | pvcreate fails: "Device /dev/sdb1 not found" or similar | Run sudo partprobe /dev/sdb before pvcreate |
| Using pvcreate on an already-mounted filesystem | Filesystem corruption — LVM metadata overwrites filesystem superblock | Only run pvcreate on unmounted, unformatted partitions |
| Expecting pvremove to free disk space visible to the OS | pvremove only wipes the LVM label — the partition still exists | After pvremove, delete the partition with parted or gdisk to reclaim space |
Knowledge Check
Answer these before moving to the next slide.
- What are the three layers of LVM, from bottom to top? What is each layer's purpose?
- Write the command to initialise
/dev/sdb1as an LVM physical volume. - After running pvcreate, write the command to confirm the PV was created and show its size and free space.
- The output of
pvsshows a PV with an empty VG column andPFreeequal toPSize. What does this indicate? - You need to remove
/dev/sdb1from the volume groupdatavgand uninitialise it. It currently has 2 GB of allocated extents. Write the commands in the correct order. - What is a physical extent, and why does its size matter?
Knowledge Check — Answers
- Physical Volume (PV) — raw storage (partition or disk) initialised for LVM. Volume Group (VG) — a pool of one or more PVs; the unit of storage administration. Logical Volume (LV) — a flexible virtual partition carved from VG space; filesystems are placed on LVs.
sudo pvcreate /dev/sdb1sudo pvs— the output should show/dev/sdb1with an empty VG column, its PSize, and PFree equal to PSize (no extents allocated yet). Alternatively,sudo pvdisplay /dev/sdb1for full details.- The PV has been initialised with
pvcreatebut has not yet been added to any volume group. All of its space is available — none of its physical extents have been allocated to logical volumes. -
sudo pvmove /dev/sdb1— move all data off /dev/sdb1 to other PVs in datavgsudo vgreduce datavg /dev/sdb1— remove /dev/sdb1 from the volume groupsudo pvremove /dev/sdb1— wipe the LVM metadata from /dev/sdb1
- A physical extent (PE) is the smallest unit of storage that LVM allocates. It is typically 4 MiB and is set when the volume group is created. The PE size matters because: all LVM allocations must be in whole PE increments — the minimum logical volume size is one PE; capacity calculations depend on the PE size; and once set for a VG, it cannot be changed without recreating the VG.
Key Takeaways
- LVM has three layers: PV → VG → LV. Physical volumes are the raw storage foundation. Volume groups pool PVs into a single capacity pool. Logical volumes are flexible virtual partitions carved from the pool. Filesystems go on logical volumes.
-
Create a physical volume with
pvcreate /dev/DEVICE. The device must be a partition or whole disk, unmounted, and the kernel must know it exists (runpartprobeafter partitioning). Verify withpvsorpvdisplay. -
Inspect with
pvs(summary) andpvdisplay(detail). An empty VG column means the PV is not in any volume group. Free PE × PE size = available space. Usepvscanto discover all PVs. -
Remove safely: pvmove → vgreduce → pvremove.
A PV in a VG cannot be directly removed. Move data off with
pvmove, remove from the VG withvgreduce, then uninitialise withpvremove. Skipping pvmove causes data loss.
Graded Lab
- Run
lsblkto identify an unpartitioned disk in your lab VM. Create a GPT partition table and a single partition using all available space withparted --script. Runpartprobeand confirm withlsblk. - Run
sudo pvcreate /dev/sdb1to initialise the partition as a physical volume. Confirm success withsudo pvs. - Run
sudo pvdisplay /dev/sdb1and record: PV Size, PE Size, Total PE, Free PE. Calculate the available space in MiB (Free PE × PE Size). - Run
sudo pvscanto see the system-wide PV summary. Note that the new PV is shown as "in no VG." - Create a second partition on the same disk (
/dev/sdb2) using 2 GiB. Initialise it as a PV. Runsudo pvsto confirm both/dev/sdb1and/dev/sdb2appear. - Remove the second PV: run
sudo pvremove /dev/sdb2. Confirm it is gone withsudo pvs. Delete partition 2 from the disk with parted and runpartprobe.
"Create and remove physical volumes."
The exam task is: partition a disk, run pvcreate, verify with
pvs. The remove sequence on a PV in a VG requires pvmove +
vgreduce + pvremove.