Skip to content

Click on each book below to review & buy on Amazon.

As an Amazon Associate, I earn from qualifying purchases.


RHCSA - Configure Local Storage: Create & Remove Physical Volumes

Physical volumes (PVs) are block devices that serve as the building blocks for creating logical volumes. These physical volumes can be individual hard drives, solid-state drives, or disk partitions. LVM allows users to combine multiple physical volumes into volume groups, and then allocate logical volumes from these groups.

Lesson Setup

To actively participate in the exercises, make sure to attach an additional empty disk to your system. While the exercises assume that the additional disk is 1G in size, feel free to use whatever disk size is available to you.

Do not use a disk with data on as following the exercises will mean that data will be deleted.

Once the disk is attached, you should be able to see it by running the lsblk command, which in this example shows as the sdb device:

After rebooting, the disk may not retain the same device name, making it essential to always run lsblk to verify that you are working with the correct disk.

$ lsblk

NAME           MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda              8:0    0   20G  0 disk 
├─sda1           8:1    0  600M  0 part /boot/efi
├─sda2           8:2    0    1G  0 part /boot
└─sda3           8:3    0   17G  0 part 
  ├─os_vg-root 253:0    0   15G  0 lvm  /
  └─os_vg-swap 253:1    0    2G  0 lvm  [SWAP]
sdb              8:16   0    1G  0 disk

You will now need to create a partition on the /dev/sdb device so that you can practice creating and removing physical volumes.

You can actually create physical volumes directly onto the disk if the whole disk is to be used for your logical volumes. However, partitioning the disk allows you to follow along with future exercises without having to keep adding more disks to the system as you will just create another partition.

Create a 100MB partition on disks /dev/sdb:

sudo parted -s /dev/sdb mklabel gpt mkpart ext4 0MB 100MB

Confirm partition exists:

lsblk /dev/sdb
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sdb      8:16   0   1G  0 disk 
└─sdb1   8:17   0  94M  0 part

Creating a Physical Volume

Creating a physical volume is performed using the pvcreate command with the disk or partition as the argument.

Creating a physical volume:

Create the physical volume using partition /dev/sdb1:

sudo pvcreate /dev/sdb1 
Physical volume "/dev/sdb1" successfully created.

You can view the newly created physical volume by using either pvs or pvdisplay:

sudo pvs
PV         VG Fmt  Attr PSize  PFree 
/dev/sdb1     lvm2 ---  94.00m 94.00m
sudo pvdisplay
"/dev/sdb1" is a new physical volume of "94.00 MiB"
--- NEW Physical volume ---
PV Name               /dev/sdb1
VG Name               
PV Size               94.00 MiB
Allocatable           NO
PE Size               0   
Total PE              0
Free PE               0
Allocated PE          0
PV UUID               xxxxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxxxx

Removing a Physical Volume

Removing a physical volume is performed using the pvremove command with the disk or partition as the argument.

The removal is possible only when the physical volume is not part of a volume group. Fortunately, for this exercise, it is not, but we will address that scenario in the upcoming lesson.

Removing a physical volume:

Identify the physical volumes on the system:

sudo pvs
PV         VG Fmt  Attr PSize  PFree 
/dev/sdb1     lvm2 ---  94.00m 94.00m

Remove the physical volume:

sudo pvremove /dev/sdb1
Labels on physical volume "/dev/sdb1" successfully wiped.

Support DTV Linux

Click on each book below to review & buy on Amazon. As an Amazon Associate, I earn from qualifying purchases.

NordVPN ®: Elevate your online privacy and security. Grab our Special Offer to safeguard your data on public Wi-Fi and secure your devices. I may earn a commission on purchases made through this link.