| |

LFCS 84 ๐Ÿง LVM โ€” Volume Groups

โฑ๏ธ Estimated read: 12 min | |

A Volume Group is the pool in the middle of the LVM stack. It sits between the Physical Volumes that provide raw capacity and the Logical Volumes that consume it. The VG aggregates the capacity of its member PVs into a single address space, and the administrator allocates LVs from that address space without knowing which physical device the extents come from. The VG is also where the extent size is decided, the metadata is managed, and the group’s identity is established.

This chapter covers the Volume Group layer: creating, inspecting, extending, reducing, and modifying a VG. It assumes the conceptual model from LFCS 82โ€”PV, VG, LV, and PEโ€”and the Physical Volume operations from LFCS 83. It focuses on the commands and the failure modes that the LFCS exam tests: how to extend a VG with a new disk, how to safely remove a PV from a VG, and how to recover a VG that has lost a member.


Key point: The Volume Group is the unit of allocation, not the unit of storage. It does not move data. It records which Physical Volumes belong to the pool and how many Physical Extents are free. The data lives on the PVs, and the VG’s metadata is the map that connects them.


Why the Volume Group layer exists

The aggregation boundary. A Physical Volume is a single device. A Logical Volume may need to span multiple devices, or the administrator may want to add capacity without recreating the LVs. The VG is the aggregation layer: it pools the PVs, so the LVs are allocated from the pool rather than from a specific device . This is the layer that decouples the logical block device from the physical device’s boundaries.

The extent size decision. The Physical Extent size is set when the VG is created and cannot be changed afterward. The default is 4 MiB, and it is a trade-off: smaller extents allow finer allocation granularity but require more metadata; larger extents reduce metadata overhead but waste space on small LVs . The VG is the container for this decision, which is why the vgcreate command takes the -s option.

The metadata management. The VG’s configurationโ€”which PVs it contains, which LVs it has, and how the LEs map to PEsโ€”is stored as metadata on each PV. The VG is the unit that the metadata describes, and the metadata copies on the PVs are the redundancy mechanism for recovering from a corrupted disk . The vgcfgbackup and vgcfgrestore commands operate on the VG’s metadata, not on the data.

The identity. The VG has a name and a UUID. The name is what the administrator uses in commands and what appears in the LV device path (/dev/vg_name/lv_name). The UUID is what LVM uses internally to identify the VG even if the name is changed. Both are established at creation and are the VG’s identity in the system.


a. Creating and inspecting a Volume Group

vgcreate takes a VG name and one or more PVs. The PVs must already be initialized with pvcreate. The command assigns the PVs to the new VG and writes the VG metadata to each PV. The -s option sets the Physical Extent size, and the -v flag adds verbose output.

# Create a Volume Group named vg_data from two PVs.
# The default PE size is 4 MiB.
sudo vgcreate vg_data /dev/sdc /dev/sdd

# Create a VG with a 16 MiB PE size.
sudo vgcreate -s 16M vg_big /dev/sde

vgs provides a compact report of all VGs. The columns show the VG name, the number of PVs, the number of LVs, the number of snapshots, the attributes, the total size, and the free space .

# Compact report of all Volume Groups.
sudo vgs

# Example output:
#   VG      #PV #LV #SN Attr   VSize   VFree
#   vg_data   2   1   0 wz--n-  19.99g  9.99g

vgdisplay provides the detailed view. It shows the VG’s UUID, size, PE size, total and free PE count, and the list of member PVs. The -s flag produces a short format similar to vgs .

# Detailed attributes of a specific Volume Group.
sudo vgdisplay vg_data

vgscan scans all block devices for LVM metadata and rebuilds the VG configuration cache. It is the recovery tool for a system that has lost its LVM configuration, such as after a disk is moved from another machine .

# Scan for Volume Groups and rebuild the cache.
sudo vgscan

b. Extending and reducing a Volume Group

vgextend adds a PV to an existing VG. The PV must be initialized with pvcreate and must not already belong to another VG. The VG’s size grows by the size of the new PV, and the new extents become available for allocation.

# Add /dev/sde to the vg_data Volume Group.
sudo vgextend vg_data /dev/sde

# Verify the new size.
sudo vgs vg_data

vgreduce removes a PV from a VG. The PV must have no allocated extents, which means the LVs that used it must be moved first with pvmove. The command fails if the PV still has extents, and it fails if the removal would leave the VG without enough PVs to hold the existing LVs.

# Move the extents off /dev/sdc.
sudo pvmove /dev/sdc

# Remove /dev/sdc from the VG.
sudo vgreduce vg_data /dev/sdc

The --removemissing option is the recovery path for a VG that has lost a PV. If a disk fails and is removed from the system, the VG’s metadata still records it as a member. vgreduce --removemissing vg_name removes the missing PV from the metadata and, if possible, recovers the LVs that did not have extents on the missing disk. This is a data-loss scenario if the missing PV had extents that were not mirrored, but it is the only way to bring the VG back to a consistent state.

# Remove a missing PV from the VG metadata.
sudo vgreduce --removemissing vg_data

c. Modifying and recovering a Volume Group

vgchange changes the attributes of a VG. The -a y option activates the VG’s LVs, which is necessary after a boot or after a VG is imported. The -a n option deactivates them. The -x n option disables allocation of new extents on the VG, which is useful when the VG is being prepared for removal or when the underlying storage is failing.

# Activate all LVs in the VG.
sudo vgchange -a y vg_data

# Deactivate all LVs in the VG.
sudo vgchange -a n vg_data

# Disable new allocations on the VG.
sudo vgchange -x n vg_data

vgrename changes the VG’s name. The LVs’ device paths change accordingly, and any fstab or application configuration that references the old path must be updated. The VG’s UUID does not change, so the internal identity is preserved.

# Rename the VG. The LVs become /dev/vg_new/lv_name.
sudo vgrename vg_data vg_new

vgcfgbackup and vgcfgrestore are the metadata backup and restore tools. The backup writes the VG’s configuration to a text file in /etc/lvm/backup/. The restore reads the file and rewrites the metadata on the PVs. The restore is the recovery path for a VG whose metadata has been corrupted .

# Back up the VG metadata.
sudo vgcfgbackup vg_data

# Restore the VG metadata from the backup.
sudo vgcfgrestore vg_data

vgsplit and vgmerge move PVs between VGs. The split creates a new VG from a subset of the PVs, and the merge combines two VGs. These are less common in the LFCS exam, but they are the commands for reorganizing the VG structure without recreating the LVs.


Complete Example Session

# ============================================
# PART 1: THE STARTING STATE
# ============================================
# The PVs are initialized and ready to be pooled.

sudo pvs

# ============================================
# PART 2: CREATE THE VG
# ============================================
# Pool the PVs into a single address space.

sudo vgcreate vg_data /dev/sdc /dev/sdd

# ============================================
# PART 3: VERIFY WITH vgs
# ============================================
# The VG is listed with its size and free space.

sudo vgs

# ============================================
# PART 4: VERIFY WITH vgdisplay
# ============================================
# Detailed attributes: UUID, PE size, PV list.

sudo vgdisplay vg_data

# ============================================
# PART 5: CREATE AN LV
# ============================================
# The LV consumes extents from the VG pool.

sudo lvcreate -n lv_app -L 5G vg_data

# ============================================
# PART 6: EXTEND THE VG
# ============================================
# Add a new PV to the VG.

sudo pvcreate /dev/sde
sudo vgextend vg_data /dev/sde
sudo vgs vg_data

# ============================================
# PART 7: REDUCE THE VG
# ============================================
# Move extents off the PV, then remove it.

sudo pvmove /dev/sdc
sudo vgreduce vg_data /dev/sdc

# ============================================
# PART 8: THE MISSING PV CASE
# ============================================
# If a PV is removed from the system without pvmove,
# the VG metadata still records it.

# sudo vgreduce --removemissing vg_data
# This removes the missing PV from the metadata.

# ============================================
# PART 9: THE METADATA BACKUP
# ============================================
# Back up the VG configuration.

sudo vgcfgbackup vg_data
ls /etc/lvm/backup/

# ============================================
# PART 10: THE FULL PICTURE
# ============================================
# vgcreate pools the PVs.
# vgextend adds capacity.
# vgreduce removes a PV (after pvmove).
# vgchange activates or deactivates.
# vgcfgbackup and vgcfgrestore manage metadata.

echo "VG workflow complete."

The ten parts walk through the full lifecycle: create, inspect, use, extend, reduce, handle the missing case, and back up the metadata. The sequence is the same regardless of whether the VG is used for a database, a virtual machine store, or a container host.


Quick Reference

VG Commands

CommandPurpose
vgcreateCreate a VG from PVs
vgsCompact report of all VGs
vgdisplayDetailed attributes
vgscanScan for VGs, rebuild cache
vgextendAdd a PV to a VG
vgreduceRemove a PV from a VG
vgchangeModify VG attributes
vgrenameRename a VG
vgcfgbackupBack up VG metadata
vgcfgrestoreRestore VG metadata

Creation Options

OptionEffect
-s SIZESet PE size
-vVerbose output
-n NAMESet VG name (rarely used)

vgs Output

ColumnMeaning
VGVolume Group name
#PVNumber of Physical Volumes
#LVNumber of Logical Volumes
#SNNumber of snapshots
VSizeTotal size
VFreeFree space

Recovery Commands

SituationCommand
Disk failed, PV missingvgreduce --removemissing
Metadata corruptedvgcfgrestore
Cache lost after disk movevgscan
VG needs activationvgchange -a y

Best Practices

โœ… Do This:

# Create the VG from initialized PVs.
sudo vgcreate vg_data /dev/sdc /dev/sdd                          // โœ…

# Verify with vgs and vgdisplay.
sudo vgs vg_data                                                  // โœ…

# Extend with a new PV.
sudo vgextend vg_data /dev/sde                                    // โœ…

# Move extents before removing a PV.
sudo pvmove /dev/sdc                                              // โœ…

# Back up metadata before changes.
sudo vgcfgbackup vg_data                                          // โœ…

โŒ Don’t Do This:

# Don't vgreduce a PV that still has extents.
sudo vgreduce vg_data /dev/sdc  # fails                           // โŒ

# Don't vgcreate without initializing the PVs.
sudo vgcreate vg_data /dev/sdc  # needs pvcreate first            // โŒ

# Don't change the PE size after creation.
# The PE size is fixed at VG creation.                            // โŒ

Common Pitfalls

PitfallWhy It HappensFix
vgcreate failsPV not initializedpvcreate first
vgextend failsPV belongs to another VGvgreduce from the other VG first
vgreduce failsPV still has extentspvmove first
VG missing after disk moveCache not updatedvgscan
Metadata corruptedDisk failure or power lossvgcfgrestore from backup
Cannot activate VGVG not activated after bootvgchange -a y

Real-World Examples

1. Create VG

sudo vgcreate vg_data /dev/sdc /dev/sdd

2. Compact Report

sudo vgs

3. Detailed Report

sudo vgdisplay vg_data

4. Extend VG

sudo vgextend vg_data /dev/sde

5. Reduce VG

sudo vgreduce vg_data /dev/sdc

6. Activate VG

sudo vgchange -a y vg_data

7. Rename VG

sudo vgrename vg_data vg_new

8. Backup Metadata

sudo vgcfgbackup vg_data

9. Restore Metadata

sudo vgcfgrestore vg_data

10. Remove Missing PV

sudo vgreduce --removemissing vg_data

Visual

The VG in the LVM Stack

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  LOGICAL VOLUMES                                        โ”‚
โ”‚  lv_app, lv_data, lv_home                               โ”‚
โ”‚         โ”‚                                               โ”‚
โ”‚         โ–ผ                                               โ”‚
โ”‚  VOLUME GROUP vg_data                                   โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚  Pool of Physical Extents                         โ”‚  โ”‚
โ”‚  โ”‚  (allocated to LVs on demand)                     โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚         โ”‚                                               โ”‚
โ”‚         โ–ผ                                               โ”‚
โ”‚  PHYSICAL VOLUMES                                       โ”‚
โ”‚  /dev/sdc, /dev/sdd, /dev/sde                           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

vgextend and vgreduce

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  BEFORE                                                 โ”‚
โ”‚  vg_data: 20 GB (2 PVs), 5 GB allocated, 15 GB free     โ”‚
โ”‚                                                         โ”‚
โ”‚  vgextend vg_data /dev/sde                              โ”‚
โ”‚         โ”‚                                               โ”‚
โ”‚         โ–ผ                                               โ”‚
โ”‚  AFTER                                                  โ”‚
โ”‚  vg_data: 30 GB (3 PVs), 5 GB allocated, 25 GB free     โ”‚
โ”‚                                                         โ”‚
โ”‚  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  โ”‚
โ”‚                                                         โ”‚
โ”‚  vgreduce requires pvmove first.                        โ”‚
โ”‚  pvmove /dev/sdc โ†’ extents moved                        โ”‚
โ”‚  vgreduce vg_data /dev/sdc โ†’ PV removed                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The Missing PV Recovery

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  NORMAL STATE                                           โ”‚
โ”‚  vg_data contains: /dev/sdc, /dev/sdd                   โ”‚
โ”‚                                                         โ”‚
โ”‚  DISK FAILURE                                           โ”‚
โ”‚  /dev/sdc is removed from the system                    โ”‚
โ”‚         โ”‚                                               โ”‚
โ”‚         โ–ผ                                               โ”‚
โ”‚  VG METADATA still records /dev/sdc as a member         โ”‚
โ”‚  LVM commands report the VG as incomplete               โ”‚
โ”‚         โ”‚                                               โ”‚
โ”‚         โ–ผ  vgreduce --removemissing vg_data             โ”‚
โ”‚  METADATA UPDATED                                       โ”‚
โ”‚  /dev/sdc removed from the VG record                    โ”‚
โ”‚  LVs that had extents on sdc are lost (data loss)       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The Metadata Backup

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  /etc/lvm/backup/vg_data                                โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚  vg_data {                                        โ”‚  โ”‚
โ”‚  โ”‚      id = "..."                                   โ”‚  โ”‚
โ”‚  โ”‚      seqno = 5                                    โ”‚  โ”‚
โ”‚  โ”‚      physical_volumes {                           โ”‚  โ”‚
โ”‚  โ”‚          /dev/sdc { ... }                         โ”‚  โ”‚
โ”‚  โ”‚          /dev/sdd { ... }                         โ”‚  โ”‚
โ”‚  โ”‚      }                                            โ”‚  โ”‚
โ”‚  โ”‚      logical_volumes {                            โ”‚  โ”‚
โ”‚  โ”‚          lv_app { ... }                           โ”‚  โ”‚
โ”‚  โ”‚      }                                            โ”‚  โ”‚
โ”‚  โ”‚  }                                                โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                                                         โ”‚
โ”‚  vgcfgrestore reads this file and rewrites the metadata โ”‚
โ”‚  on the PVs.                                            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Summary

ItemValue
PurposePool of Physical Volumes
Createvgcreate vg_name /dev/sdX ...
Compact reportvgs
Detailed reportvgdisplay
Scan and cachevgscan
Add a PVvgextend vg_name /dev/sdX
Remove a PVvgreduce vg_name /dev/sdX
Activatevgchange -a y vg_name
Renamevgrename old new
Backup metadatavgcfgbackup vg_name
Restore metadatavgcfgrestore vg_name

Key takeaways:

  • The VG is the aggregation layer. It pools the PVs and allocates the LVs from the pool. The administrator manages the VG, not the individual PVs, for capacity decisions .
  • The PE size is set at VG creation. It cannot be changed afterward. The -s option on vgcreate is the only place to choose it .
  • vgextend adds capacity; vgreduce removes a PV. The latter requires the PV to be empty, which means pvmove first .
  • vgreduce --removemissing is the failure recovery path. When a PV is lost, the metadata still records it. The --removemissing flag removes it from the record and, if possible, recovers the LVs that did not depend on it .
  • vgcfgbackup and vgcfgrestore are the metadata tools. The backup is a text file in /etc/lvm/backup/. The restore rewrites the metadata on the PVs, which is the recovery path for a corrupted VG .
  • vgscan rebuilds the cache. When a VG is not recognized after a disk is moved, vgscan finds the metadata and updates the LVM cache.

Remember: The Volume Group is the layer where the administrator’s decisions about capacity live. The PVs are the raw devices, and the LVs are the block devices that the filesystems use, but the VG is the pool that connects them. The vgcreate command establishes the pool, the extent size, and the identity. The vgextend and vgreduce commands adjust the pool’s membership. The vgchange and vgcfgbackup commands manage the pool’s state and its metadata. The commands are simple; the discipline is the orderโ€”pvmove before vgreduce, backup before changes, and --removemissing only when the alternative is a system that will not start.


Was this helpful?


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!