Subscribe to the feed

Physical volumes (PV) are the base "block" that you need in order to manipulate a disk using Logical Volume Manager (LVM).

Now, let’s not rush ahead. What exactly is a physical volume? What in the world is LVM?

In short, LVM is a type of storage virtualization that allows operators far more flexibility in storage management than standard partitioning. A physical volume is any physical storage device, such as a Hard Disk Drive (HDD), Solid State Drive (SSD), or partition, that has been initialized as a physical volume with LVM. Without properly initialized physical volumes, you cannot create Volume Groups or logical volumes.

So let's get started! First, there are a few considerations.

Don't try to pinpoint the exact amount of space you need down to the nearest byte. The reason for this is that LVM places labels on the physical volumes' UUID, as well as metadata storage. While this doesn't take up very much space, understand that if you initialize a 1Gb PV, you do not have 1Gb of usable space.

Also, although LVM allows you to create physical volumes using multiple partitions, it is recommended that you use a single partition for a PV. This is for a couple of reasons—single partitions are easier to track for sysadmins, and you will experience better Striping performance. For more info on this, see Red Hat Documentation.

Initializing physical volumes

So, now that we have considered our options, let’s look at the actual initialization process. It is always good practice to see what physical volumes you already have configured on your system. To do this, use the pvs command. You should get something similar to this:

[root@rhel ~]# pvs
  PV         VG   Fmt  Attr PSize   PFree
  /dev/sda2  rhel lvm2 a--  <29.00g    0 

Here we can see that my VM only has a single physical volume /dev/sda2 that is 29.00Gb. Let's create two additional PVs at 1Gb to demonstrate the process:

[root@rhel ~]# pvcreate /dev/sdb /dev/sdc
    Physical volume "/dev/sdb" successfully created.
    Physical volume "/dev/sdc" successfully created.

You can verify the creation worked using the pvdisplay command:

[root@rhel ~] # pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               rhel
  PV Size               <29.00 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              7423
  Free PE               0
  Allocated PE          7423
  PV UUID               q9VFt3-YR0m-XATY-BADn-Vbnb-PVl5-9wIAhd
   
  "/dev/sdb" is a new physical volume of "1.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb
  VG Name               
  PV Size               1.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               3MHooU-799T-xe8q-24Jk-MMdc-pkhF-Tnqpbg
   
  "/dev/sdc" is a new physical volume of "1.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdc
  VG Name               
  PV Size               1.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               ydegao-MGb8-X5Mc-VuLp-JnFH-vmx9-rYa9wQ>

However, I find that in most use cases, the pvs command is much more reader-friendly:

[root@rhel ~]# pvs
  PV         VG   Fmt  Attr PSize   PFree
  /dev/sda2  rhel lvm2 a--  <29.00g    0 
  /dev/sdb        lvm2 ---    1.00g 1.00g
  /dev/sdc        lvm2 ---    1.00g 1.00g>

Wrap up and troubleshooting

If you were able to follow those steps successfully, congratulations on initializing a physical volume! If not, be sure that your new drives or partitions are formatted but NOT mounted prior to using the pvcreate command. Otherwise, you will see the following error:

[root@rhel ~]# pvcreate /dev/sdb /dev/sdc
  Can't open /dev/sdb exclusively.  Mounted filesystem?
  Can't open /dev/sdc exclusively.  Mounted filesystem?

I hope that this quick look at physical drive creation was helpful. Next, I recommend that you try creating a volume group using vgcreate. More on that in a future article!

[ Free online course: Red Hat Enterprise Linux technical overview. ]


About the author

Tyler is the Sr. Community Manager at Enable Sysadmin, a submarine veteran, and an all-round tech enthusiast! He was first introduced to Red Hat in 2012 by way of a Red Hat Enterprise Linux-based combat system inside the USS Georgia Missile Control Center. Now that he has surfaced, he lives with his wife and son near Raleigh, where he worked as a data storage engineer before finding his way to the Red Hat team. He has written numerous technical documents, from military procedures to knowledgebase articles and even some training curricula. In his free time, he blends a passion for hiking, climbing, and bushcraft with video games and computer building. He is loves to read and enjoy a scotch or bourbon. Find him on Twitter or on LinkedIn.

Read full bio
UI_Icon-Red_Hat-Close-A-Black-RGB

Browse by channel

automation icon

Automation

The latest on IT automation for tech, teams, and environments

AI icon

Artificial intelligence

Updates on the platforms that free customers to run AI workloads anywhere

open hybrid cloud icon

Open hybrid cloud

Explore how we build a more flexible future with hybrid cloud

security icon

Security

The latest on how we reduce risks across environments and technologies

edge icon

Edge computing

Updates on the platforms that simplify operations at the edge

Infrastructure icon

Infrastructure

The latest on the world’s leading enterprise Linux platform

application development icon

Applications

Inside our solutions to the toughest application challenges

Original series icon

Original shows

Entertaining stories from the makers and leaders in enterprise tech