LearnRHCSA (EX200)Local Storage

Physical Volumes and Volume Groups

pvcreate - a hands-on Linux lab on a real virtual machine.

Build the bottom two layers of LVM. Stamp a partition into a physical volume with pvcreate and inspect it with pvs and pvdisplay; then pool PVs into a volume group with vgcreate (name first, then the PVs) and read it with vgs and vgdisplay, where the PE Size and free-extent count live. The exam move: set a specific physical extent size at creation with vgcreate -s 16M, because the extent size is locked once the group exists. Serves EX200 local-storage task 10: create and configure volume groups.

You built a filesystem on /dev/vdb1 last month, sized it to fill the whole partition, and moved on. Today the application on it is out of room. You go to make it bigger and hit a wall: a plain partition is fixed. Its edges are burned into the disk. To grow it you would have to delete it, repartition around whatever sits after it, and rebuild the filesystem from a backup. On a running server, that is a maintenance window and a held breath.

There is a layer that removes that wall. It sits between the raw disk and the filesystem, and it lets storage grow, shrink, and span multiple disks while the machine stays up. It is called LVM, the Logical Volume Manager, and the exam tests every floor of it. This lesson builds the bottom two floors: the physical volume and the volume group. That is EX200 local-storage task 10, create and configure a volume group, sometimes with a specific extent size.

The black boxes below are a practice terminal: a safe sandbox that checks the one command each step teaches. The outputs shown are from a real RHEL 10 machine (AlmaLinux 10.2) with two spare disks, run as root. Sizes like PSize, extent counts, and UUIDs are live values, so yours will read differently. What stays true everywhere is the SHAPE of each command and each column, and that is the lesson.

LVM stacks three layers between a disk and a mounted filesystem. Read it bottom to top:

disk or partition  ->  Physical Volume (PV)  ->  Volume Group (VG)  ->  Logical Volume (LV)  ->  filesystem

A physical volume is a disk or partition you have stamped for LVM use. Think of it as a single brick. A volume group is one or more PVs pooled together into one reservoir of storage. Think of it as the pile of bricks. A logical volume is a slice you carve out of that pool and put a filesystem on. Think of it as the wall you build from the pile. This lesson covers the brick and the pile: pvcreate and vgcreate. The wall, the LV, is the next lesson.

The whole point of the volume group is that it is a pool measured in small equal chunks called physical extents. When you later carve a logical volume, LVM just hands it some extents from the pool. Need more room? Hand it more extents, even ones that live on a second disk you added to the group. Nothing on disk has to be fixed edge-to-edge the way a partition does. That is why LVM storage grows on a live server while a plain partition cannot.

The extent is the unit LVM allocates in. The default extent size is 4 MiB, and the exam occasionally asks for a different one (task 10 sometimes says 'physical extent size 16 MiB'). You set it once, when you create the volume group, and it cannot change afterward. Hold that thought; it becomes the -s flag two steps from now.

The first floor is one command. You already have a partition, /dev/vdb1, of type Linux LVM. pvcreate writes an LVM label and a metadata area onto it, turning a plain partition into a physical volume LVM will recognize.

Run the stamp, then inspect the result with pvs, the one-line-per-PV summary. Before you look, predict what you expect: a row for /dev/vdb1 with a size near 2 GiB and, because it is not in any group yet, an empty VG column.

pvcreate /dev/vdb1

prompt: [root@servera ~]# answer: pvcreate /dev/vdb1 output: Physical volume "/dev/vdb1" successfully created. hint: The command that stamps a partition as an LVM physical volume is pvcreate, followed by the device: pvcreate /dev/vdb1

The partition is now a physical volume: LVM has written its label and reserved a metadata area at the start of the device. Nothing you can see in a filesystem changed, because there is no filesystem here yet. What changed is that LVM will now accept /dev/vdb1 into a volume group. This is the brick, ready for the pile.

pvs prints one line per physical volume with the columns that matter: which device, which VG it belongs to, the format, attributes, its size, and how much is free. It is the fast check you run to confirm a pvcreate landed and to see whether a PV is already claimed by a group.

pvs

prompt: [root@servera ~]# answer: pvs output: PV VG Fmt Attr PSize PFree /dev/vda3 rhel lvm2 a-- <14.00g 0 /dev/vdb1 lvm2 --- 2.00g 2.00g hint: The one-line-per-PV summary is a single word: pvs

Two physical volumes. /dev/vda3 is the system disk, already in the rhel group with 0 free, that is where root and swap live. Your new /dev/vdb1 sits below it: the VG column is empty because you have not put it in a group yet, and PSize and PFree both read 2.00g, meaning the whole PV is free. That empty VG column is the signal that this brick is waiting to be picked up. Next you pick it up.

The exact PSize and PFree figures, and the <14.00g on the system disk, belong to the machine this was captured on. Yours will differ with your disk sizes. What is stable is the FORM: a PV with an empty VG column is unassigned, and one with a group name is claimed.

The second floor pools one or more PVs into a volume group. vgcreate takes a name you choose, then the PVs to put in it. Here you make a group called vgdata from the single PV you just stamped.

vgcreate vgdata /dev/vdb1

prompt: [root@servera ~]# answer: vgcreate vgdata /dev/vdb1 output: Volume group "vgdata" successfully created hint: The command is vgcreate, then the NAME you choose, then the PV: vgcreate vgdata /dev/vdb1

The volume group vgdata exists, and /dev/vdb1 now belongs to it. If you re-ran pvs, that empty VG column would read vgdata. The order of the arguments is the thing to burn in: name first, then the PVs. vgcreate /dev/vdb1 vgdata would try to create a group literally named /dev/vdb1, which fails. To pool several disks at once you just list them all: vgcreate vgdata /dev/vdb1 /dev/vdc1.

Two tools inspect a volume group, and they mirror pvs and pvdisplay. vgs is the one-line summary. vgdisplay is the full report, and it is where you read the two numbers the exam cares about: the PE Size (the extent size you would set with -s) and the free extent count (how many chunks are left to carve LVs from).

Run the summary first:

vgs

prompt: [root@servera ~]# answer: vgs output: VG #PV #LV #SN Attr VSize VFree rhel 1 2 0 wz--n- <14.00g 0 vgdata 1 0 0 wz--n- <2.00g <2.00g hint: The one-line-per-VG summary mirrors pvs; it is a single word: vgs

Your vgdata row reads its story across the columns: #PV 1 (built from one physical volume), #LV 0 (no logical volumes carved yet), and VSize/VFree both <2.00g because the whole pool is still free. The rhel group above it has #LV 2, root and swap, and 0 free. vgs is the glance you take to confirm a group exists and see at once how full it is.

vgs gives you sizes in gigabytes, but LVM allocates in extents, and vgdisplay is where you see them. Run it against vgdata and read down to the PE fields.

vgdisplay vgdata

prompt: [root@servera ~]# answer: vgdisplay vgdata output: VG Name vgdata VG Size <2.00 GiB PE Size 4.00 MiB Total PE 511 Free PE / Size 511 / <2.00 GiB hint: The detailed per-VG report is vgdisplay, then the group name: vgdisplay vgdata

There are the two exam numbers. PE Size 4.00 MiB is the extent size, and 4 MiB is the LVM default because you did not ask for anything else. Total PE 511 and Free PE 511 mean the pool holds 511 extents and every one is free, because no logical volume has taken any yet. When you carve an LV next lesson, Free PE drops by however many extents the LV claims. That extent count is the pool's true currency; gigabytes are just the extents multiplied by the PE size.

Your Total PE and Free PE will not be 511; they depend on your PV's exact size divided by the PE size. PE Size 4.00 MiB is the stable one as long as you took the default. If a task tells you to use a different extent size, that number changes to what you set, and the extent count changes with it.

Scaffolding off. No command is printed this time. You have every piece you need.

Task 10 sometimes pins the extent size: 'create a volume group named archivevg on /dev/vdc1 with a physical extent size of 16 MiB'. You already know vgcreate, its argument order (name, then PV), and that the extent size is set at creation time. The one new piece is the flag: the switch that sets the extent size on vgcreate is -s, and it takes a size like 16M. Assume /dev/vdc1 is already a PV. Write the single line that builds archivevg with a 16 MiB extent size.

prompt: [root@servera ~]# answer: vgcreate -s 16M archivevg /dev/vdc1 output: Volume group "archivevg" successfully created hint: Start with vgcreate, add the -s flag with 16M to set the extent size, then the name archivevg, then the PV /dev/vdc1.

The -s 16M set the physical extent size to 16 MiB, and the rest is the same vgcreate shape: name, then PV. Had you run vgdisplay archivevg afterward, the PE Size line would read 16.00 MiB instead of 4.00 MiB, and Total PE would be about a quarter of the 4 MiB count, because each extent is four times larger. Remember two things for the exam: -s goes before the group name, and the extent size is locked once the group exists. Get it right at creation or you delete the group and start over.

You earned this cheat sheet. Every row is a form you just ran or built:

The one thing to burn in for task 10: the extent size is set once, at vgcreate time, with -s, and never again. If the task names a PE size, use -s <size>; if it does not, the default 4 MiB is correct. And the argument order never changes: group name first, then the physical volumes.

vgcreate will often initialize a raw device for you if you skip pvcreate, but the exam may check that the PV exists explicitly, so run pvcreate first as a habit. To ADD a PV to a group that already exists, reach for vgextend, not vgcreate; vgcreate is only for making a brand new group.

The physical extent size cannot be changed after the volume group is created. If a task specifies a PE size and you forget the -s flag, the fix is not an edit; it is vgremove the group and vgcreate it again with -s. Read the task for a PE size BEFORE you type vgcreate.

The practice terminal has shown you the bottom two floors of LVM: pvcreate to stamp a partition into a physical volume, pvs to confirm it and spot the empty VG column, vgcreate to pool PVs into a group with the name-first argument order, vgs for the quick group summary, vgdisplay to read the PE size and free-extent count, and the -s flag that pins the extent size at creation. Every one of those you typed yourself.

The local-storage module mission is where you run these against a real RHEL 10 machine. A full VM boots for you with two spare disks, /dev/vdb and /dev/vdc, and empty space waiting for an LVM stack. The mission hands you objectives that use exactly what you practiced here: initialize a partition as a PV, build a volume group, and set a specific physical extent size when the task asks for one. One difference from this lesson: the mission shows no commands. You read the objective, recall pvcreate or vgcreate -s, and type it. That recall is what makes it stick on exam day.

Finish the other local-storage lessons, then go build a volume group on a real machine and carve your first logical volume from the pool.

Practice Physical Volumes and Volume Groups in a real Linux terminal at The Linux Camp. Progress is verified automatically as you type commands on the machine.