Create and Remove Physical Volumes

LinuxLinuxBeginner
Practice Now

Introduction

In this challenge, you will learn how to create and remove physical volumes (PVs) on a Linux system. Physical volumes are the basic building blocks of Logical Volume Management (LVM), which allows you to manage storage more flexibly. By completing this challenge, you will gain practical experience in managing physical volumes, a key skill for the RHCSA exam.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"]) linux/BasicSystemCommandsGroup -.-> linux/echo("`Text Display`") subgraph Lab Skills linux/echo -.-> lab-389448{{"`Create and Remove Physical Volumes`"}} end

Create Physical Volumes

Tasks

  • Create two new 100 MB logical volumes on the system.
  • Initialize the logical volumes as physical volumes.

Requirements

  • The two logical volumes should be created in the /dev/ directory.
  • The physical volumes should be named pv1 and pv2.
  • All operations should be performed as the labex user.

Example

After completing this step, you should be able to see the two physical volumes using the pvdisplay command:

[labex@host ~]$ pvdisplay
  --- Physical volume ---
  PV Name               /dev/pv1
  VG Name
  PV Size               100.00 MiB
  Allocatable           yes (but no volume group)
  PE Size               4.00 MiB
  Total PE              25
  Free PE               25
  Allocated PE          0
  PV UUID               Nt7Rnf-Eo2L-Uxnw-Yz3X-Ej7P-Gu2V-Vy3Xc2

  --- Physical volume ---
  PV Name               /dev/pv2
  VG Name
  PV Size               100.00 MiB
  Allocatable           yes (but no volume group)
  PE Size               4.00 MiB
  Total PE              25
  Free PE               25
  Allocated PE          0
  PV UUID               Nt7Rnf-Eo2L-Uxnw-Yz3X-Ej7P-Gu2V-Vy3Xc3

Remove Physical Volumes

Tasks

  • Remove the physical volumes created in the previous step.

Requirements

  • The physical volumes to be removed are /dev/pv1 and /dev/pv2.
  • All operations should be performed as the labex user.

Example

After completing this step, the pvdisplay command should not show any physical volumes.

Summary

In this challenge, you learned how to create and remove physical volumes, which are the basic building blocks of Logical Volume Management (LVM) on a Linux system. You practiced creating logical volumes, initializing them as physical volumes, and then removing the physical volumes. This hands-on experience will help you better understand and manage storage on Linux systems, a key skill for the RHCSA exam.

If you need to set up the initial environment for this challenge, you can use the following setup.sh script:

#!/bin/bash

## Create two 100 MB logical volumes
sudo lvcreate -L 100M -n pv1 /dev/mapper/ubi9-root
sudo lvcreate -L 100M -n pv2 /dev/mapper/ubi9-root

Other Linux Tutorials you may like