Create and Delete Logical Volumes

Red Hat Enterprise LinuxBeginner
Practice Now

Introduction

In this challenge, you will learn how to create and delete logical volumes on a Linux system. Logical volumes are a key component of Logical Volume Management (LVM), which provides a flexible way to manage storage on your system. By completing this challenge, you will gain practical experience in configuring local storage using LVM.

Create Logical Volumes

In this step, you will create a complete LVM setup. This involves initializing a physical disk for use by LVM, creating a volume group to pool the storage, and then carving out logical volumes from that pool.

Tasks

  • Create a new physical volume (PV) on the /dev/vdb device.
  • Create a new volume group (VG) named vg1 using the physical volume you created.
  • Create two logical volumes (LVs) named lv1 and lv2 within the vg1 volume group, each with a size of 500 MB.

Requirements

  • All operations should be performed in the /home/labex directory or its subdirectories.
  • Use the pvcreate, vgcreate, and lvcreate commands to create the physical volume, volume group, and logical volumes, respectively.
  • The names of the physical volume, volume group, and logical volumes should match the task requirements.
  • The size of each logical volume should be 500 MB.

Example

After you have successfully completed all the tasks, you can verify your work by running the sudo lvs command. The output should be similar to the following, showing your two new logical volumes, lv1 and lv2, each with a size of 500.00m within the vg1 volume group.

  LV   VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv1  vg1  -wi-a----  500.00m
  lv2  vg1  -wi-a----  500.00m
✨ Check Solution and Practice

Delete Logical Volumes

Now that you've created logical volumes, the next step is to learn how to remove them. This is a common administrative task when storage is no longer needed. You will remove the logical volumes you created in the previous step.

Tasks

  • Delete the logical volume lv1 from the vg1 volume group.
  • Delete the logical volume lv2 from the vg1 volume group.

Requirements

  • All operations should be performed in the /home/labex directory or its subdirectories.
  • Use the lvremove command to delete the logical volumes.
  • The names of the logical volumes to be deleted should match the task requirements.

Example

After deleting the logical volumes, running the sudo lvs command should produce no output, or at least not show lv1 and lv2. This confirms that the logical volumes have been successfully removed from the vg1 volume group.

✨ Check Solution and Practice

Summary

In this challenge, you learned how to create and delete logical volumes using Logical Volume Management (LVM) on a Linux system. You created a physical volume, a volume group, and two logical volumes, then deleted the two logical volumes. This hands-on experience will help you understand the process of managing storage using LVM, which is a key skill for RHCSA certification.