LFCS 83 š§ LVM ā Physical Volumes
A Physical Volume (PV) is the foundation of the LVM stack. It is a block deviceāa whole disk, a partition, or a software RAID deviceāthat has been initialized with LVM metadata. The initialization writes a label and a metadata area to the device, which records its identity and its membership in a Volume Group. Until pvcreate runs, the device is just a block device; after it runs, the device is a member of the LVM pool, and its space is divided into Physical Extents that the Volume Group can allocate .
This chapter covers the Physical Volume layer: the commands that create, inspect, modify, and remove a PV, and the failure modes that arise when a PV is removed without evacuating its data. It assumes the conceptual model from the previous chapterāPV, VG, LV, and PEāand focuses on the operational details that the LFCS exam tests: how to verify that a device is a PV, how to move extents off a PV before removing it, and how to repair a PV whose metadata has been corrupted.
Key point: pvremove does not move data. It only removes the LVM label. If the PV still contains allocated extents, the removal either fails or leaves the Volume Group inconsistent. The correct sequence is pvmove first, then vgreduce, then pvremove.
Why the Physical Volume layer exists
The initialization boundary. A raw disk has no LVM identity. pvcreate writes the LVM label to the second sector of the device and initializes the metadata area, which stores the PV’s UUID, size, and the list of Volume Groups it belongs to . This initialization is what allows LVM to recognize the device as a PV during a scan, and it is why pvscan and pvs can list the device even before it is added to a VG.
The extent division. When pvcreate initializes a device, it divides the device’s space into Physical Extents (PEs) of a fixed size. The PE size is determined when the Volume Group is created, not when the PV is created, but the PV’s metadata records the PE size that the VG expects . This division is what allows the VG to allocate the PV’s space in uniform chunks.
The metadata copies. By default, pvcreate stores two copies of the VG metadata on each PV: one at the front and one at the end of the device . The redundancy means that a single corrupted metadata area does not lose the VG’s configuration. The --metadatacopies option controls the number of copies, and setting it to 0 is useful for PVs that are used as mirrors or that have their metadata managed elsewhere.
The removal hazard. A PV that is a member of a VG cannot be removed while the VG contains Logical Volumes that map to its extents. The pvremove command removes the LVM label, but it does not relocate the data. If the PV still has allocated extents, the removal leaves the VG with a mapping to a device that no longer has LVM metadata, and the VG becomes inconsistent . The pvmove command is the mechanism for evacuating the extents before removal.
a. Creating and inspecting Physical Volumes
pvcreate initializes one or more block devices as PVs. The command accepts whole disks, partitions, and RAID devices. It writes the LVM label and metadata to each device, and it refuses to proceed if the device is already a PV or if it contains a filesystem signature that it cannot safely overwrite.
# Initialize two whole disks as Physical Volumes.
# The command writes the LVM label and metadata to each device.
sudo pvcreate /dev/sdc /dev/sdd
# Expected output:
# Physical volume "/dev/sdc" successfully created.
# Physical volume "/dev/sdd" successfully created.
pvs provides a compact report of all PVs on the system. The columns show the device name, the Volume Group it belongs to (if any), the format, the attributes, the physical size, and the free space .
# Compact report of all Physical Volumes.
sudo pvs
# Example output:
# PV VG Fmt Attr PSize PFree
# /dev/sda2 cs lvm2 a-- 19.00g 0
# /dev/sdc lvm2 --- 5.00g 5.00g
# /dev/sdd lvm2 --- 5.00g 5.00g
pvdisplay provides the detailed view. It shows the PV’s UUID, size, PE size, total and free PE count, and the Volume Group it belongs to. The -s flag produces a short format similar to pvs .
# Detailed attributes of a specific Physical Volume.
sudo pvdisplay /dev/sdc
# The output includes the PV UUID, PE size, and extent counts.
pvscan scans all block devices for LVM metadata and reports the PVs it finds. The -v flag adds verbose output, which is useful when a device is not being recognized as a PV .
# Scan for Physical Volumes.
sudo pvscan
b. Moving extents and removing a Physical Volume
pvmove relocates the allocated extents from one PV to other PVs in the same Volume Group. The operation runs while the Logical Volumes are in use, which means it is the mechanism for evacuating a disk without downtime . The command accepts a source PV and an optional destination PV. If no destination is given, LVM chooses any PV in the VG with sufficient free space.
# Move all extents off /dev/sdc to other PVs in the same VG.
# The LV remains available during the move.
sudo pvmove /dev/sdc
# Move extents to a specific destination PV.
sudo pvmove /dev/sdc /dev/sdd
The pvmove command is the first step in the safe removal sequence. After the move completes, the PV has no allocated extents, and it can be removed from the VG with vgreduce. Only then does pvremove have a safe target.
# Remove the PV from its Volume Group.
# This requires that the PV has no allocated extents.
sudo vgreduce vg_data /dev/sdc
# Remove the LVM label from the device.
# The device is no longer a PV.
sudo pvremove /dev/sdc
pvremove does not prompt for confirmation in scripted use, and it does not check whether the PV is still a member of a VG. If the PV is still in a VG with allocated extents, the command may fail, or it may leave the VG in a state that requires repair. The safe sequence is always pvmove, then vgreduce, then pvremove.
c. Modifying and repairing Physical Volumes
pvchange modifies the attributes of a PV. The -x n option disables the allocation of new extents on the PV, which is useful when a disk is showing signs of failure and should not receive new data. The -u option generates a new UUID for the PV .
# Disable allocation on a failing PV.
# Existing extents remain, but new extents are not placed on it.
sudo pvchange -x n /dev/sdc
pvresize resizes a PV after the underlying device has been resized. When a partition is grown with parted or a virtual disk is expanded, the PV’s metadata still records the old size. pvresize updates the PV to use the new space, and the Volume Group’s free space grows accordingly.
# Update the PV to use the new size of the underlying device.
sudo pvresize /dev/sdc
pvck checks the PV metadata for consistency. It is the diagnostic tool for a PV that pvs reports as missing or that causes LVM commands to fail. The -v flag adds verbose output.
# Check the PV metadata for consistency.
sudo pvck /dev/sdc
Complete Example Session
# ============================================
# PART 1: THE STARTING STATE
# ============================================
# List the block devices and identify the candidates.
lsblk
# ============================================
# PART 2: INITIALIZE THE PVS
# ============================================
# pvcreate writes the LVM label and metadata.
sudo pvcreate /dev/sdc /dev/sdd
# ============================================
# PART 3: VERIFY WITH pvs
# ============================================
# The PVs are listed with their size and free space.
sudo pvs
# ============================================
# PART 4: VERIFY WITH pvdisplay
# ============================================
# Detailed attributes: UUID, PE size, extents.
sudo pvdisplay /dev/sdc
# ============================================
# PART 5: CREATE A VG AND LV
# ============================================
# The PVs are added to a VG, and an LV is created.
sudo vgcreate vg_data /dev/sdc /dev/sdd
sudo lvcreate -n lv_app -L 6G vg_data
# ============================================
# PART 6: THE REMOVAL SEQUENCE
# ============================================
# The LV uses extents on both PVs.
# To remove /dev/sdc, the extents must move first.
sudo pvmove /dev/sdc
# ============================================
# PART 7: REMOVE FROM THE VG
# ============================================
# After pvmove, the PV has no allocated extents.
sudo vgreduce vg_data /dev/sdc
# ============================================
# PART 8: REMOVE THE PV LABEL
# ============================================
# The device is no longer a PV.
sudo pvremove /dev/sdc
# ============================================
# PART 9: THE FAILURE CASE
# ============================================
# Attempting pvremove without pvmove fails or
# leaves the VG inconsistent.
# sudo pvremove /dev/sdd
# The command may report that the PV is still in use.
# ============================================
# PART 10: THE FULL PICTURE
# ============================================
# pvcreate initializes.
# pvs and pvdisplay inspect.
# pvmove evacuates.
# vgreduce removes from the VG.
# pvremove removes the label.
echo "PV workflow complete."
The ten parts walk through the full lifecycle: create, inspect, use, evacuate, remove, and the failure case. The sequence is the same for any PV, regardless of whether it is a whole disk, a partition, or a RAID device.
Quick Reference
PV Commands
| Command | Purpose | Chapter |
|---|---|---|
pvcreate | Initialize a device as a PV | 83 |
pvs | Compact report of all PVs | 83 |
pvdisplay | Detailed attributes of a PV | 83 |
pvscan | Scan devices for PVs | 83 |
pvmove | Relocate extents to other PVs | 83 |
pvremove | Remove the LVM label | 83 |
pvchange | Modify PV attributes | 83 |
pvresize | Update PV size after device resize | 83 |
pvck | Check PV metadata | 83 |
Safe Removal Sequence
| Step | Command | Effect |
|---|---|---|
| 1 | pvmove /dev/sdX | Evacuates allocated extents |
| 2 | vgreduce vg_name /dev/sdX | Removes PV from the VG |
| 3 | pvremove /dev/sdX | Removes the LVM label |
PV Attributes
| Attribute | Meaning |
|---|---|
PSize | Total size of the PV |
PFree | Unallocated space |
PE Size | Size of each Physical Extent |
Total PE | Number of PEs on the PV |
Allocated PE | PEs mapped to LVs |
Failure Modes
| Symptom | Cause | Fix |
|---|---|---|
pvremove fails | PV still in a VG with extents | pvmove, then vgreduce |
pvs shows “unknown” VG | Metadata corruption or missing device | pvck, check device |
| New space not visible | Device resized but PV not updated | pvresize /dev/sdX |
Best Practices
ā Do This:
# Initialize whole disks or partitions.
sudo pvcreate /dev/sdc /dev/sdd // ā
# Verify with pvs after creation.
sudo pvs // ā
# Move extents before removing a PV.
sudo pvmove /dev/sdc // ā
# Remove from the VG before removing the label.
sudo vgreduce vg_data /dev/sdc // ā
# Disable allocation on a failing disk.
sudo pvchange -x n /dev/sdc // ā
ā Don’t Do This:
# Don't run pvremove on a PV that still has extents.
sudo pvremove /dev/sdc # data loss risk // ā
# Don't skip pvmove when evacuating a disk.
sudo vgreduce vg_data /dev/sdc # fails if extents remain // ā
# Don't use a device for both LVM and a filesystem.
# pvcreate overwrites the filesystem signature. // ā
Common Pitfalls
| Pitfall | Why It Happens | Fix |
|---|---|---|
pvremove reports “in use” | PV still has allocated extents | pvmove first |
vgreduce fails | PV has extents mapped to LVs | pvmove first |
| New disk space not usable | PV not resized after device growth | pvresize /dev/sdX |
| PV not recognized | LVM label missing or corrupted | pvck, then pvcreate if needed |
| Wrong device initialized | No lsblk check before pvcreate | Always verify the device |
Real-World Examples
1. Create a PV
sudo pvcreate /dev/sdc
2. Compact Report
sudo pvs
3. Detailed Report
sudo pvdisplay /dev/sdc
4. Scan for PVs
sudo pvscan
5. Move Extents
sudo pvmove /dev/sdc
6. Remove from VG
sudo vgreduce vg_data /dev/sdc
7. Remove the Label
sudo pvremove /dev/sdc
8. Disable Allocation
sudo pvchange -x n /dev/sdc
9. Resize the PV
sudo pvresize /dev/sdc
10. Check Metadata
sudo pvck /dev/sdc
Visual
The PV Lifecycle
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā RAW DEVICE ā
ā /dev/sdc ā
ā ā ā
ā ā¼ pvcreate ā
ā PHYSICAL VOLUME ā
ā LVM label + metadata + PEs ā
ā ā ā
ā ā¼ vgcreate ā
ā MEMBER OF A VOLUME GROUP ā
ā ā ā
ā ā¼ lvcreate ā
ā EXTENTS ALLOCATED TO AN LV ā
ā ā ā
ā ā¼ pvmove ā
ā EXTENTS EVACUATED ā
ā ā ā
ā ā¼ vgreduce + pvremove ā
ā RAW DEVICE AGAIN ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
The Safe Removal Sequence
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā pvmove /dev/sdc ā
ā ā Extents moved to other PVs in the VG ā
ā ā PV has no allocated extents ā
ā ā ā
ā ā¼ ā
ā vgreduce vg_data /dev/sdc ā
ā ā PV removed from the VG ā
ā ā VG size shrinks ā
ā ā ā
ā ā¼ ā
ā pvremove /dev/sdc ā
ā ā LVM label removed ā
ā ā Device is no longer a PV ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
pvs Output
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā PV VG Fmt Attr PSize PFree ā
ā /dev/sda2 cs lvm2 a-- 19.00g 0 ā
ā /dev/sdc lvm2 --- 5.00g 5.00g ā
ā /dev/sdd vg_data lvm2 a-- 5.00g 2.00g ā
ā ā
ā VG column: empty means not in a VG ā
ā PFree: unallocated space on the PV ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
The Metadata Copies
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā PV: /dev/sdc ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā Sector 1: LVM label ā ā
ā ā Metadata copy 1 ā ā
ā ā ... ā ā
ā ā Data extents ā ā
ā ā ... ā ā
ā ā Metadata copy 2 ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā
ā Two copies by default (--metadatacopies 2). ā
ā Redundancy protects against a single corruption. ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Summary
| Item | Value |
|---|---|
| Purpose | Initialize a block device for LVM |
| Create | pvcreate /dev/sdX |
| Compact report | pvs |
| Detailed report | pvdisplay |
| Scan | pvscan |
| Move extents | pvmove /dev/sdX |
| Remove from VG | vgreduce vg_name /dev/sdX |
| Remove label | pvremove /dev/sdX |
| Modify attributes | pvchange |
| Resize after growth | pvresize |
Key takeaways:
pvcreateis the initialization step. It writes the LVM label and metadata to the device, which allows LVM to recognize it as a PV .pvsandpvdisplayare the inspection tools.pvsis the compact report;pvdisplayshows the full attributes, including the UUID and the extent counts .pvmoveis the evacuation tool. It relocates the allocated extents to other PVs in the same VG, and it runs while the LVs are in use .- The removal sequence is
pvmove,vgreduce,pvremove. Skipping the first step leaves the VG with a mapping to a device that no longer has metadata, andpvremovemay fail or produce an inconsistent VG . pvchange -x ndisables allocation. It is the correct response to a disk that is failing but not yet ready to be removed.pvresizeupdates the PV after the device grows. A partition that is enlarged withpartedor a virtual disk that is expanded does not automatically update the PV’s size.
Remember: The Physical Volume is the first layer of LVM. It is the device that LVM has claimed, the container for the Physical Extents that the Volume Group allocates, and the target of the pvmove command that evacuates data before removal. The commands are simple, but the order matters: create, verify, move, reduce, remove. A PV that is removed without evacuating its extents is a PV that leaves the Volume Group inconsistent, and the repair is more expensive than the move would have been.
Stop using slow, ad-bloated tool sites! š¤®
š Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
ā
Finance (Mortgage, Interest, Inflation)
ā
Tech (Base64, JSON, Dev Suite, IP)
ā
Health (BMI, BMR, TDEE)
ā
Productivity (Timer, Workspace, QR)
ā”ļø Fast & Private
š No data leaves your device
š 100% Free
š Use it now: https://tools.kandz.me
š Bookmark itāyouāll need it later!