5. Configure Local Storage
📘Red Hat Certified System Administrator (RHCSA – EX200)
In Linux, when we manage storage using LVM (Logical Volume Manager), the physical volume (PV) is the starting point. A physical volume is essentially a hard disk, SSD, or partition that is prepared for use by LVM. Think of it as “raw storage space” that LVM can manage.
1. Understanding Physical Volumes
- Physical Volume (PV): A disk or partition that has been initialized to work with LVM.
- Why use PVs: LVM allows you to combine multiple disks or partitions into one flexible storage system. PVs are the first step in this process.
- Commands to manage PVs: Linux provides commands like
pvcreate,pvdisplay,pvremoveto manage them.
Key point for the exam: You must know how to create, list, and remove PVs.
2. Creating a Physical Volume
To create a physical volume, you use the command:
sudo pvcreate /dev/sdX
/dev/sdX→ ReplaceXwith the actual disk or partition name.- Example:
sudo pvcreate /dev/sdb1
This initializes /dev/sdb1 as a PV for LVM use.
Notes:
- The disk/partition must not contain any active data because
pvcreatewill overwrite the LVM metadata. - After creation, the disk is ready to be added to a Volume Group (VG).
Verify Physical Volume
After creating a PV, you can check it with:
pvdisplay
This shows details such as:
- PV Name (disk/partition)
- Volume Group (VG) it belongs to (if any)
- Size of the PV
- Free space
Or a simpler list with:
pvs
Example output of pvs:
PV VG Fmt Attr PSize PFree
/dev/sdb1 vg01 lvm2 a-- 50.00g 50.00g
This tells you that /dev/sdb1 is a PV in VG vg01 and it has 50 GB free.
3. Removing a Physical Volume
If you want to remove a PV from LVM, you need to make sure it’s not in use (not part of an active Volume Group or Logical Volume).
Steps to remove a PV:
- Check if it’s in use:
pvs
- Remove it from its Volume Group (if necessary):
vgreduce <VG_NAME> /dev/sdX
<VG_NAME>→ The Volume Group name/dev/sdX→ The PV to remove
- Remove the PV metadata:
pvremove /dev/sdX
Example:
sudo pvremove /dev/sdb1
This wipes the LVM metadata from the disk, making it a normal unallocated disk again.
4. Important Exam Notes
- Commands you must know:
- Create PV:
pvcreate /dev/sdX - List PVs:
pvdisplayorpvs - Remove PV:
pvremove /dev/sdX
- Create PV:
- Check usage before removal: Always verify that the PV is not part of any active VG or LV using
pvsorvgdisplay. - Permissions: Most PV commands require
sudobecause you are modifying disks. - Disk requirements: The disk/partition must be empty or unmounted. LVM overwrites metadata, so never create PVs on disks with important data.
5. Quick Workflow Example
- Create a PV:
sudo pvcreate /dev/sdb1
- Verify PV:
pvs
- Add PV to Volume Group (for next step in LVM setup):
sudo vgcreate vg01 /dev/sdb1
- Later, remove PV from VG:
sudo vgreduce vg01 /dev/sdb1
- Remove PV completely:
sudo pvremove /dev/sdb1
✅ Summary:
- PV = raw storage for LVM
- Use
pvcreateto make it usable by LVM - Use
pvsorpvdisplayto check PV status - Use
pvremoveto delete it after making sure it’s not in use
