RED HAT ENTERPRISE LINUX
Volume Groups:
Assign Physical Volumes
Assign physical volumes to volume groups
CIS126RH | RHEL System Administration 1
Mesa Community College
A volume group (VG) is the central storage pool in LVM — it aggregates the physical
extents of one or more physical volumes into a unified capacity that logical volumes
draw from. Creating a volume group, naming it meaningfully, and managing its membership
over the lifecycle of a server are core RHEL administration tasks. This module covers
vgcreate, vgextend, vgreduce, and the inspection
commands vgs and vgdisplay. These skills are tested on the
RHCSA exam.
Learning Objectives
-
Create a volume group —
Use
vgcreateto pool one or more physical volumes into a named volume group, setting the physical extent size -
Inspect volume groups —
Use
vgsandvgdisplayto list volume group attributes, capacity, and member physical volumes -
Extend a volume group —
Use
vgextendto add a new physical volume to an existing volume group to increase its total capacity -
Reduce and remove a volume group —
Use
vgreduceto remove a PV from a VG andvgremoveto decommission an entire volume group
What is a Volume Group?
A volume group is a named storage pool that aggregates the physical extents of one or more physical volumes into a single addressable capacity.
- A VG has a unique name chosen by the administrator
- All PEs from all member PVs contribute to the VG's total capacity
- The physical extent size (default 4 MiB) is set at VG creation and applies to all member PVs
- Logical volumes are carved from the VG's pool of free extents
- A VG can span multiple physical disks — extents are not tied to one disk
- The device mapper provides VG access at
/dev/VGNAME/
Choose descriptive VG names that indicate purpose: datavg,
appvg, rhel (the default VG on a RHEL installation).
Names may contain letters, digits, hyphens, underscores, and dots.
Hyphens in VG names are doubled when they appear in device paths.
Creating a Volume Group: vgcreate
vgcreate creates a new volume group and assigns one or more
physical volumes to it in a single command.
# Create a VG named "datavg" from a single PV
$ sudo vgcreate datavg /dev/sdb1
Volume group "datavg" successfully created
# Create a VG from multiple PVs at once
$ sudo vgcreate datavg /dev/sdb1 /dev/sdc1
Volume group "datavg" successfully created
# Create with a custom physical extent size (default is 4 MiB)
$ sudo vgcreate -s 8m datavg /dev/sdb1
# -s 8m sets PE size to 8 MiB
# Verify the VG was created
$ sudo vgs
VG #PV #LV #SN Attr VSize VFree
datavg 1 0 0 wz--n- <10.00g <10.00g
rhel 1 2 0 wz--n- <19.00g 0
The core exam task: sudo vgcreate VGNAME /dev/PV. The PV must already
exist (created with pvcreate). Verify immediately with sudo vgs.
Inspecting Volume Groups: vgs
vgs provides a concise one-line-per-VG summary — the standard
command to check VG capacity and status at a glance.
# Summary listing of all volume groups
$ sudo vgs
VG #PV #LV #SN Attr VSize VFree
datavg 2 3 0 wz--n- <20.00g 4.00g
rhel 1 2 0 wz--n- <19.00g 0
# Show a specific VG only
$ sudo vgs datavg
# Add the PV count and PE size columns
$ sudo vgs -o +vg_extent_size,pv_count
| Column | Meaning |
|---|---|
#PV | Number of physical volumes in the VG |
#LV | Number of logical volumes in the VG |
#SN | Number of snapshots |
Attr | VG attributes: w=writeable, z=resizable, n=normal allocation |
VSize | Total VG capacity (sum of all PV sizes) |
VFree | Free space available for new logical volumes |
Detailed VG Inspection: vgdisplay
vgdisplay shows the complete details of a volume group —
the verbose counterpart to vgs.
$ sudo vgdisplay datavg
--- Volume group ---
VG Name datavg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size <20.00 GiB
PE Size 4.00 MiB
Total PE 5118
Alloc PE / Size 4096 / <16.00 GiB
Free PE / Size 1022 / <4.00 GiB
VG UUID xYz789-AB01-cd23-EF45-gh67-IJ89-kl01MN
The Free PE / Size line shows how many extents and how much space
remain. When this reaches zero, the VG needs a new PV added with
vgextend.
Listing VG Members
Several approaches show which physical volumes belong to a given volume group.
# pvs shows the VG each PV belongs to
$ 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/sdc1 datavg lvm2 a-- <10.00g <2.00g
# Both /dev/sdb1 and /dev/sdc1 are in datavg
# vgdisplay shows PV count and VG UUID
$ sudo vgdisplay datavg | grep "Cur PV\|PV Name"
# pvdisplay shows which VG a specific PV is in
$ sudo pvdisplay /dev/sdb1 | grep "VG Name"
VG Name datavg
# vgscan discovers all VGs and their PVs
$ sudo vgscan
Found volume group "datavg" using metadata type lvm2
Found volume group "rhel" using metadata type lvm2
Extending a Volume Group: vgextend
vgextend adds one or more physical volumes to an existing volume group,
immediately increasing its total capacity. No downtime is required.
# Current VG is nearly full
$ sudo vgs datavg
VG #PV #LV #SN Attr VSize VFree
datavg 1 2 0 wz--n- <10.00g 500.00m
# Step 1: Prepare the new disk and create a PV
$ sudo parted --script /dev/sdc mklabel gpt mkpart primary 1MiB 100%
$ sudo partprobe /dev/sdc
$ sudo pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created.
# Step 2: Add the PV to the existing VG
$ sudo vgextend datavg /dev/sdc1
Volume group "datavg" successfully extended
# Confirm the VG now has more free space
$ sudo vgs datavg
VG #PV #LV #SN Attr VSize VFree
datavg 2 2 0 wz--n- <20.00g <10.50g
Reducing a Volume Group: vgreduce
vgreduce removes a physical volume from a volume group.
The PV must have no allocated extents before it can be removed.
# Check the PV's allocated extents first
$ sudo pvs /dev/sdc1
PV VG Fmt Attr PSize PFree
/dev/sdc1 datavg lvm2 a-- <10.00g <10.00g
# PFree = PSize — no extents are allocated on this PV
# Remove the PV from the VG
$ sudo vgreduce datavg /dev/sdc1
Removed "/dev/sdc1" from volume group "datavg"
# If the PV has allocated extents, move data off first
$ sudo pvmove /dev/sdc1 # move data to other PVs in the VG
$ sudo vgreduce datavg /dev/sdc1 # then remove
# Confirm the PV is no longer in the VG
$ 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/sdc1 lvm2 --- <10.00g <10.00g ← no VG
Renaming a Volume Group: vgrename
A volume group can be renamed without affecting its logical volumes or data, though the device paths for logical volumes will change.
# Rename a VG — logical volumes must not be in use
$ sudo vgrename datavg storagevg
Volume group "datavg" successfully renamed to "storagevg"
# After renaming, device paths change:
# /dev/datavg/data becomes /dev/storagevg/data
# Update /etc/fstab if the old name was used in mount entries
$ sudo vim /etc/fstab
# Change /dev/datavg/data to /dev/storagevg/data
# Or use /dev/mapper/storagevg-data (device mapper name)
# Update initramfs if the system VG is renamed
$ sudo dracut -f
$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Any /etc/fstab entries, mount unit files, or application configuration
files that reference the old VG name by path must be updated. On the exam, only
rename a VG when explicitly asked to do so.
Removing a Volume Group: vgremove
vgremove decommissions an entire volume group.
All logical volumes must be removed first.
# Attempt to remove a VG that still has LVs — fails
$ sudo vgremove datavg
Logical volume datavg/data is still active.
Do you really want to remove volume group "datavg" containing 1 logical volumes? [y/n]: n
# Step 1: Unmount filesystems and deactivate LVs
$ sudo umount /data
$ sudo lvremove datavg/data
Logical volume "data" successfully removed
# Step 2: Remove the VG
$ sudo vgremove datavg
Volume group "datavg" successfully removed
# Step 3: Uninitialise the PVs if they will be reused
$ sudo pvremove /dev/sdb1 /dev/sdc1
Removing a VG with active logical volumes prompts for confirmation, but once confirmed, all data on all logical volumes in the VG is permanently lost. Ensure all data is backed up and all filesystems are unmounted before proceeding.
VG Activation and Deactivation
A volume group can be deactivated (making all its LVs inaccessible) and reactivated. This is used before maintenance operations like pvmove.
# Check VG activation status
$ sudo vgs -o vg_name,vg_attr
VG Attr
datavg wz--n- ← active
rhel wz--n- ← active
# Deactivate a VG (makes all LVs inaccessible)
$ sudo vgchange -an datavg
0 logical volume(s) in volume group "datavg" now active
# Activate a VG
$ sudo vgchange -ay datavg
2 logical volume(s) in volume group "datavg" now active
# Activate all VGs (typically done at boot)
$ sudo vgchange -ay
After importing a VG from another system (using vgimport), run
sudo vgchange -ay VGNAME to activate it and make its logical volumes
available. This is the standard procedure after moving disks between servers.
Migrating a VG Between Systems
LVM supports moving an entire volume group from one system to another by exporting, physically moving the disks, and importing.
# On the source system — prepare and export
$ sudo umount /data # unmount all LVs
$ sudo vgchange -an datavg # deactivate
$ sudo vgexport datavg # mark as exported
Volume group "datavg" successfully exported
# Move the disks to the destination system
# On the destination system — import and activate
$ sudo pvscan # discover the new disks
$ sudo vgimport datavg # import the VG
Volume group "datavg" successfully imported
$ sudo vgchange -ay datavg # activate
$ sudo mount /dev/datavg/data /data # mount filesystems
Volume Group Commands Quick Reference
| Task | Command |
|---|---|
| Create a VG from one PV | sudo vgcreate VGNAME /dev/sdb1 |
| Create a VG from multiple PVs | sudo vgcreate VGNAME /dev/sdb1 /dev/sdc1 |
| Create with custom PE size | sudo vgcreate -s 8m VGNAME /dev/sdb1 |
| List all VGs (summary) | sudo vgs |
| Detailed VG information | sudo vgdisplay VGNAME |
| Scan for all VGs | sudo vgscan |
| Add a PV to an existing VG | sudo vgextend VGNAME /dev/sdc1 |
| Remove a PV from a VG | sudo vgreduce VGNAME /dev/sdc1 |
| Move data off a PV before vgreduce | sudo pvmove /dev/sdc1 |
| Remove an entire VG | sudo vgremove VGNAME |
| Rename a VG | sudo vgrename OLDNAME NEWNAME |
| Activate a VG | sudo vgchange -ay VGNAME |
| Deactivate a VG | sudo vgchange -an VGNAME |
Complete LVM Setup Workflow
The full sequence from raw disk to usable filesystem, connecting all three modules.
-
Partition the disk
sudo parted --script /dev/sdb mklabel gpt mkpart primary 1MiB 100%
sudo partprobe /dev/sdb -
Create the physical volume
sudo pvcreate /dev/sdb1 -
Create the volume group
sudo vgcreate datavg /dev/sdb1 -
Create a logical volume
sudo lvcreate -L 8G -n data datavg -
Create a filesystem
sudo mkfs.xfs /dev/datavg/data -
Mount and add to fstab
sudo mkdir /data && sudo mount /dev/datavg/data /data
Common Mistakes
| Mistake | What goes wrong | Correct approach |
|---|---|---|
| Running vgcreate without first running pvcreate | vgcreate fails: "No physical volume label read from /dev/sdb1" | Always run pvcreate /dev/sdb1 before vgcreate |
| Using the same VG name as an existing VG | vgcreate fails: "A volume group called datavg already exists" | Run vgs first to see existing VG names; choose a unique name |
| Running vgreduce without pvmove when the PV has allocated extents | vgreduce fails: "Physical volume /dev/sdc1 still in use" | Run pvmove /dev/sdc1 first to move data to other PVs |
| Removing a VG without first removing its logical volumes | vgremove prompts for confirmation — accepting destroys all LV data | Run lvremove for each LV and unmount filesystems before vgremove |
| Forgetting to update fstab after vgrename | System fails to mount LVs at boot because paths reference the old VG name | Update fstab and regenerate initramfs after renaming a VG |
| Creating a VG without enough free PEs to create useful LVs | lvcreate fails because the VG has insufficient space for the requested size | Verify VFree with vgs before creating logical volumes |
Knowledge Check
Answer these before moving to the next slide.
- Write the command to create a volume group named
appvgusing the physical volumes/dev/sdb1and/dev/sdc1. - After creating
appvg, write the command to confirm its total size and free space. - The VG
appvgis running low on space. A new PV has been created on/dev/sdd1. Write the command to add it toappvg. - What does the
VFreecolumn invgsoutput represent, and why is it important? - You need to remove
/dev/sdc1fromappvg. It has 3 GB of allocated extents. Write the commands in the correct order. - What must be done before running
vgremove appvgto safely decommission the volume group?
Knowledge Check — Answers
sudo vgcreate appvg /dev/sdb1 /dev/sdc1
Both PVs must have been initialised with pvcreate before this command.sudo vgs appvg— the output shows VSize (total capacity) and VFree (unallocated space). Alternatively,sudo vgdisplay appvgfor full details.sudo vgextend appvg /dev/sdd1— the PV must already exist (created with pvcreate). The VG capacity increases immediately after this command.VFreeis the amount of unallocated space in the volume group — the space available for creating new logical volumes or extending existing ones. When VFree reaches 0, no new LVs can be created and no existing LV can be extended without first adding a new PV to the VG withvgextend.-
sudo pvmove /dev/sdc1— move all 3 GB of allocated data to other PVs in appvgsudo vgreduce appvg /dev/sdc1— remove /dev/sdc1 from appvg- Optionally:
sudo pvremove /dev/sdc1— uninitialise the PV if no longer needed
- Before vgremove: unmount all filesystems on the VG's logical volumes, then remove
all logical volumes with
sudo lvremove appvg/LVNAMEfor each LV in the VG. Only after all LVs are removed can vgremove complete successfully without prompting for data destruction confirmation.
Key Takeaways
-
Create a volume group with
vgcreate VGNAME PV.... PVs must be initialised with pvcreate first. The VG gets a name and the PE size (default 4 MiB) is set at creation. Verify immediately withvgsorvgdisplay. -
Use
vgsfor a summary;vgdisplayfor full detail.VFreeis the key capacity planning figure — it shows how much space remains for new or extended logical volumes. When VFree = 0, runvgextend. -
Extend with
vgextend VGNAME PV— no downtime required. The new PV's extents join the pool immediately. This is the standard way to expand storage on a live server. Prepare the PV with pvcreate first. - Reduce safely: pvmove → vgreduce; remove safely: lvremove → vgremove. A PV with allocated extents cannot be removed — pvmove first. A VG with active LVs cannot be safely removed — lvremove each LV first. Skipping either step risks data loss.
Graded Lab
- Using the PVs created in the previous lab (
/dev/sdb1), create a volume group namedlabvg. Verify withsudo vgsandsudo vgdisplay labvg. - Record the PE Size, Total PE, and VFree from the vgdisplay output. Calculate: how many 4 GiB logical volumes could be created in this VG?
- Prepare a second PV on
/dev/sdb2(create the partition with parted, run partprobe, then pvcreate). Extendlabvgto include this PV withsudo vgextend labvg /dev/sdb2. - Run
sudo vgs labvgto confirm the VG now shows two PVs and increased capacity. Runsudo pvsto confirm both PVs showlabvgin the VG column. - Remove
/dev/sdb2fromlabvg: confirm it has no allocated extents withpvs, then runsudo vgreduce labvg /dev/sdb2. Verify withpvsthat /dev/sdb2 shows an empty VG column. - Run
sudo vgscanto see the system-wide VG summary. Note thatlabvgappears and shows its member PV count.
"Assign physical volumes to volume groups."
The exam task: vgcreate VGNAME /dev/PV then verify with
vgs. Extending with vgextend is equally common.