RHCSA Practical Lab Series β Creating a Logical Volume
π Lab 20: Configuring Logical Volumes in RHEL 9
π Objective
In this lab, you will:
β Create a new logical volume using an available disk (/dev/vdb
)
β Allocate 60 extents (PE) for the logical volume
β Format the volume using vfat filesystem
β Automount the logical volume at /mnt/qa
π Step 1: Identify Available Disks and Partitions
πΉ Check the available disks and partitions:
[root@node2 ~]# lsblk
π Expected Output (Example):
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 20G 0 disk
ββvda1 252:1 0 1G 0 part /boot
ββvda2 252:2 0 19G 0 part /
vdb 252:16 0 5G 0 disk
β
Ensure vdb
is available before proceeding.
π Step 2: Create a New Partition
πΉ Use fdisk
to create a new partition:
[root@node2 ~]# fdisk /dev/vdb
π Inside the fdisk
prompt, follow these steps:
- Press
n
β Create a new partition - Press
p
β Make it a primary partition - Press
2
β Assign partition number 2 - Press
Enter
twice β Accept default start and end sectors - Specify a partition size of at least 200M (e.g.,
+1200M
) - Press
w
β Write changes and exit
β Verify the new partition:
[root@node2 ~]# lsblk
π Expected Output:
vdb 252:16 0 5G 0 disk
ββvdb1 252:17 0 2.5G 0 part
ββvdb2 252:18 0 1.2G 0 part
π Step 3: Create a Volume Group & Logical Volume
πΉ Initialize the partition for LVM usage:
[root@node2 ~]# vgcreate -s 16M qagroup /dev/vdb2
π Explanation:
vgcreate
β Creates a Volume Group namedqagroup
-s 16M
β Sets the physical extent size to 16M/dev/vdb2
β Uses the newly created partition
πΉ Create the Logical Volume (qa
) with 60 extents:
[root@node2 ~]# lvcreate -l 60 -n qa qagroup
π Explanation:
-l 60
β Allocates 60 extents to the LV-n qa
β Names the LV asqa
qagroup
β Associates it with the Volume Group
β Check Logical Volume Details:
[root@node2 ~]# lvdisplay /dev/qagroup/qa
π Expected Output:
LV Name /dev/qagroup/qa
VG Name qagroup
LV Size 960.00 MiB
π Step 4: Format the Logical Volume
πΉ Install mkfs.vfat
(if missing):
[root@node2 ~]# yum provides */mkfs.vfat
[root@node2 ~]# yum -y install dosfstools
πΉ Format the LV with vfat
filesystem:
[root@node2 ~]# mkfs.vfat /dev/qagroup/qa
β Expected Output:
mkfs.vfat 3.0.26 (2014-03-07)
π Step 5: Mount the Logical Volume
πΉ Create a mount point:
[root@node2 ~]# mkdir /mnt/qa
πΉ Mount the LV manually:
[root@node2 ~]# mount /dev/qagroup/qa /mnt/qa
πΉ Verify the mount:
[root@node2 ~]# df -h
β Expected Output:
Filesystem Size Used Avail Use% Mounted on
/dev/qagroup/qa 960M 1M 959M 1% /mnt/qa
π Step 6: Automount Logical Volume at Boot
πΉ Edit /etc/fstab
:
[root@node2 ~]# vim /etc/fstab
πΉ Append the following line:
/dev/qagroup/qa /mnt/qa vfat defaults 0 0
β
Save and exit (ESC + :wq
).
πΉ Test automount:
[root@node2 ~]# mount -a
[root@node2 ~]# df -h
β
If /mnt/qa
appears, the automount configuration is correct.
π Step 7: Verify After Reboot (Optional)
πΉ Reboot the system:
[root@node2 ~]# reboot
πΉ After reboot, check if the LV is still mounted:
[root@node2 ~]# df -h
β
If /mnt/qa
is still mounted, everything is correctly configured!
π Troubleshooting Tips
πΉ If vgcreate
fails, check if LVM tools are installed:
[root@node2 ~]# yum install -y lvm2
πΉ If mkfs.vfat
fails, ensure the package is installed:
[root@node2 ~]# yum provides */mkfs.vfat
πΉ If /mnt/qa
does not mount after reboot, check /etc/fstab
syntax:
[root@node2 ~]# cat /etc/fstab
β Ensure there are no typos or missing fields!
β Final Summary
β Created a new logical volume (qa
) using LVM
β Formatted it with vfat filesystem
β Mounted it at /mnt/qa
β Configured automount via /etc/fstab
β Verified everything after reboot
π Next Lab: Configuring System Performance Optimization with tuned
π© Subscribe for more RHCSA exam labs and hands-on tutorials! π