RHCSA Practical Lab Series – Creating a Logical Volume

Expertise in Cloud, Networking & DevOps
Photo by Paul Frenzel / Unsplash

πŸ” 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:

  1. Press n β†’ Create a new partition
  2. Press p β†’ Make it a primary partition
  3. Press 2 β†’ Assign partition number 2
  4. Press Enter twice β†’ Accept default start and end sectors
  5. Specify a partition size of at least 200M (e.g., +1200M)
  6. 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 named qagroup
  • -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 as qa
  • 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! πŸš€


Read more