11.3 Assign Physical Volumes to Volume Groups
Key Takeaways
- Create a volume group with vgcreate VGNAME PV [PV...]; add capacity later with vgextend; remove a PV from a VG with vgreduce.
- Inspect with vgs and vgdisplay: VSize/VFree (or size/free) show capacity available for new logical volumes.
- A VG pools one or more PVs into a single allocation space; PE (physical extent) size is set at vgcreate time (default often 4 MiB).
- Never vgreduce away a PV that still holds extents without pvmove or freeing LVs; exam layouts usually make reduce straightforward when asked.
- VG metadata is persistent on its PVs; after reboot, VGs activate with the LVM stack—verify with vgs that names and free space match the task.
11.3 Assign Physical Volumes to Volume Groups
Quick Answer: Build a pool with
vgcreate myvg /dev/sdb1. Grow it withvgextend myvg /dev/sdc1. Shrink membership withvgreduce myvg /dev/sdc1. Checkvgs/vgdisplayfor size and free space. The VG name you choose becomes part of later LV paths like/dev/myvg/dataand/dev/mapper/myvg-data.
Official skill focus
EX200 Configure local storage includes assigning physical volumes to volume groups. In plain language: take one or more PVs and combine them into a named pool of extents from which you create logical volumes.
Typical tasks:
- “Create a volume group named
researchusing/dev/sdb1.” - “Add
/dev/sdc1to volume groupresearch.” - “Remove
/dev/sdd1fromresearch.”
Create a volume group: vgcreate
sudo vgcreate research /dev/sdb1
sudo vgcreate research /dev/sdb1 /dev/sdc1 # multi-PV from the start
sudo vgcreate -s 16M research /dev/sdb1 # custom PE size (advanced; default usually OK)
Rules of thumb:
- VG name must be unique on the system (
rhelorrlmay already exist for root). - Arguments after the name are PVs (devices already
pvcreate’d). - Do not use a PV that already belongs to another VG.
Verify:
sudo vgs
sudo vgdisplay research
sudo pvs
# /dev/sdb1 should now show VG research
Reading vgs
VG #PV #LV #SN Attr VSize VFree
research 1 0 0 wz--n- 20.00g 20.00g
rhel 1 2 0 wz--n- <39.00g <3.00g
| Field | Meaning |
|---|---|
| VG | Volume group name |
| #PV / #LV | Counts of physical and logical volumes |
| VSize | Total VG capacity |
| VFree | Free space for new or extended LVs |
If the task only creates a VG, #LV may be 0 and VFree ≈ VSize. That is success.
Extend a volume group: vgextend
When you need more pool capacity:
sudo pvcreate /dev/sdc1 # if not already a PV
sudo vgextend research /dev/sdc1
sudo vgs research
sudo pvs
vgextend is the day-2 operation matching “add this disk to the existing VG.” It does not automatically grow filesystems; it only adds free extents to the VG. Growing an LV/filesystem is a separate skill (often lvextend + xfs_growfs in a later objective).
Reduce a volume group: vgreduce
sudo vgreduce research /dev/sdc1
Preconditions:
- No allocated extents remaining on that PV (or LVM cannot release it).
- If allocations exist, move them:
sudo pvmove /dev/sdc1(needs free space on other PVs in the VG), thenvgreduce.
sudo pvs -o+pv_used,pv_free
sudo pvmove /dev/sdc1
sudo vgreduce research /dev/sdc1
sudo pvremove /dev/sdc1 # only if task also wants PV removed
Empty VG removal (if task says delete the VG entirely—adjacent skill):
sudo lvremove ... # remove LVs first
sudo vgremove research
Focus this section on assign/extend/reduce membership; full teardown order is good hygiene for labs.
Physical extents (PE) — enough theory for the exam
A VG chops PV space into physical extents (default commonly 4 MiB). Logical volumes are allocated in whole extents. Practical implications:
- Requested LV sizes round to extent boundaries.
vgsfree space is what you can still allocate.- Custom
-satvgcreateis rarely required unless a task specifies extent size.
sudo vgdisplay research | egrep 'PE Size|Total PE|Free PE|VG Size'
Naming and device paths
| Object | Example |
|---|---|
| VG name | research |
| Later LV | research/data |
| Kernel DM node | /dev/mapper/research-data |
| Convenience symlink | /dev/research/data |
Hyphens in VG or LV names are doubled in mapper paths (LVM escaping). Prefer simple names (data, vgdata, research) on the exam to avoid confusion.
Do not confuse:
/dev/sdb1— PVresearch— VG (not a block device you mkfs directly)/dev/mapper/research-data— LV (after lvcreate)
Non-destructive exam mindset
- List existing VGs first:
sudo vgs— avoid clashing withrhel/rlroot VG. - Only consume free PVs shown by
pvswith empty or intended VG fields. - Prefer adding a new VG for lab tasks rather than extending the system VG unless the task says so.
- Extending the root VG is allowed when asked (“add free space on
/dev/sdb1torhel”)—still double-check the name.
sudo vgs
sudo pvs
# Task: add /dev/sdb1 to existing VG rhel
sudo vgextend rhel /dev/sdb1
sudo vgs rhel
Activation awareness
Normally VGs activate at boot via systemd/LVM generators. Manual tools:
sudo vgchange -ay
sudo vgchange -ay research
sudo vgchange -an research # deactivate (no open LVs)
If vgs shows the VG but LVs are missing under /dev/mapper, check activation and lvscan. Cold exam images almost always auto-activate local VGs.
End-to-end exam scenarios
Scenario A — New VG from one PV
Task: Create VG tools on /dev/vdb1.
sudo pvs | grep vdb1
sudo vgcreate tools /dev/vdb1
sudo vgs tools
# VFree should approximately equal PV size (minus tiny metadata overhead)
Scenario B — Multi-PV VG
Task: Create backupvg using /dev/sdb1 and /dev/sdc1.
sudo pvcreate /dev/sdb1 /dev/sdc1 # if needed
sudo vgcreate backupvg /dev/sdb1 /dev/sdc1
sudo vgs backupvg
# #PV should be 2; VSize ≈ sum of PVs
Scenario C — Extend existing VG
Task: Add /dev/sdd1 to backupvg.
sudo pvcreate /dev/sdd1
sudo vgextend backupvg /dev/sdd1
sudo pvs
sudo vgs backupvg
Scenario D — Reduce PV out of VG
Task: Remove /dev/sdd1 from backupvg (assume no LVs use it, or free).
sudo vgreduce backupvg /dev/sdd1
sudo pvs # sdd1 free or only PV without VG
Verification checklist
| Check | Command |
|---|---|
| VG exists with correct name | vgs / vgdisplay NAME |
| Correct PVs inside | pvs or vgdisplay -v |
| Free space available for LVs | vgs -o+vg_free |
| Survives reboot | reboot lab → vgs again |
Sample verbose membership:
sudo vgdisplay -v research
Persistence and scoring
VG metadata is stored in LVM headers on member PVs. After vgcreate/vgextend/vgreduce, changes persist across reboot without editing /etc/fstab. Graders look for the named VG, membership, and free size—not whether you also mounted a filesystem (unless the combined task requires it).
If you create a VG but never create an LV, that is fine when the objective stops at VG assignment. Do not leave partial wrong names (Research vs research—use the exact case requested).
Common traps
vgcreatewith a partition that is not a PV — runpvcreatefirst.- Name collision with existing VG.
vgextendon a device still containing a filesystem signature but not pvcreate’d — initialize PV properly.vgreducewhile extents remain —pvmoveor delete/move LVs first.- Extending root VG by accident when a new VG was required (or the reverse).
- Thinking
vgextendgrows/automatically — it only adds free PE; LV+FS extend is separate. - Typos in VG name propagating into later
lvcreate -npaths.
Coordination with surrounding skills
- Before: GPT partitions +
pvcreate(11.1–11.2). - After:
lvcreate/lvremove(11.4), then filesystems, fstab, and non-destructive growth objectives in the next chapter. - Swap/LV on VG: still needs
lvcreatethenmkswap/swaponor filesystem tools.
Section checkpoint
You should create volume groups with vgcreate, expand them with vgextend, remove PVs with vgreduce, verify pool size and membership with vgs/vgdisplay/pvs, protect the system VG unless tasked otherwise, and understand that VG changes persist on disk for reboot. That is the EX200 standard for assigning physical volumes to volume groups.
Which command creates a volume group named research using physical volume /dev/sdb1?
What is the primary effect of vgextend appvg /dev/sdc1?
vgreduce fails because the PV still has allocated extents. What is the usual remediation path?
After vgcreate project /dev/vdb1, which check best confirms success for a task that only required the volume group?