5. Configure Local Storage
πRed Hat Certified System Administrator (RHCSA β EX200)
In Linux, when you work with storage, Logical Volume Management (LVM) lets you manage disk storage more flexibly. There are three key layers:
- Physical Volume (PV) β A real storage device or partition.
- Volume Group (VG) β A pool of storage made by combining one or more PVs.
- Logical Volume (LV) β The storage you actually use, carved out from VGs.
In this section, we focus on how to assign physical volumes to volume groups.
Step 1: Understand the components
- Physical Volume (PV)
- A PV is a disk or partition you prepare for LVM.
- You βinitializeβ a disk as a PV using the
pvcreatecommand. - Example: sudo pvcreate /dev/sdb
sudo pvcreate /dev/sdc
- Volume Group (VG)
- A VG is a collection of PVs. Think of it as a storage pool.
- You create a VG using the
vgcreatecommand and assign PVs to it.
Step 2: Create a Volume Group (VG) with PVs
When you assign PVs to a VG, you combine the storage space of multiple disks. This makes management easier and more flexible.
Command syntax:
sudo vgcreate <VG_NAME> <PV1> <PV2> ...
Example:
You have two PVs /dev/sdb and /dev/sdc. You want to create a VG called data_vg.
sudo vgcreate data_vg /dev/sdb /dev/sdc
data_vgis the volume group name./dev/sdband/dev/sdcare the PVs being added.- After this, the VG will show total space as the sum of the PVs.
Check the result:
sudo vgdisplay data_vg
This shows:
- Total physical volumes in the VG
- Total space available
- Free space
Step 3: Add more PVs to an existing VG
Sometimes, you need more storage. You can assign additional PVs to an existing VG using vgextend.
Command syntax:
sudo vgextend <VG_NAME> <NEW_PV>
Example:
sudo vgextend data_vg /dev/sdd
/dev/sddis a new physical volume added to thedata_vgvolume group.- The total storage in the VG now increases.
Check updated VG:
sudo vgdisplay data_vg
Youβll see the new total space.
Step 4: Removing PVs from a VG (Optional but Exam Relevant)
If a PV is no longer needed in a VG, you can remove it using vgreduce.
Example:
sudo vgreduce data_vg /dev/sdc
- This removes
/dev/sdcfromdata_vg. - Important: The PV must not contain data in logical volumes; otherwise, the system will prevent removal.
Check:
sudo vgdisplay data_vg
Step 5: Key Exam Notes
- Commands to remember:
pvcreateβ Initialize a physical volume.vgcreateβ Create a volume group with PVs.vgextendβ Add PVs to an existing VG.vgreduceβ Remove PVs from a VG.vgdisplayβ Show details of the volume group.
- VG concept:
- A VG combines multiple PVs into a single storage pool.
- Storage from a VG can later be divided into Logical Volumes (LVs) for actual use.
- Why itβs important for the exam:
- The exam may ask you to create a VG with specific PVs, or add/remove PVs from a VG.
- You should understand how PVs combine into VGs and how to check space.
Step 6: Visual Representation (Simplified)
PV: /dev/sdb ----\
PV: /dev/sdc -----> VG: data_vg ---> Logical Volumes (LVs)
PV: /dev/sdd ----/
- PVs are the raw storage.
- VG pools them.
- LVs are slices you actually use.
Step 7: Quick Example Scenario
- You have 3 new disks:
/dev/sdb,/dev/sdc,/dev/sdd. - Exam task: Create a VG called
project_vgusing/dev/sdband/dev/sdc. Then add/dev/sddto the VG.
Commands:
sudo pvcreate /dev/sdb /dev/sdc /dev/sdd
sudo vgcreate project_vg /dev/sdb /dev/sdc
sudo vgextend project_vg /dev/sdd
sudo vgdisplay project_vg
β Thatβs everything you need for assigning PVs to VGs for the exam. The key is to know the commands and their purpose, and understand that VGs are pools of PVs.
