Create New PV (Physical Volume)

Describes what is a PV (Physical Volume) - a single physical hard disk, or a partition of a hard disk, to be managed by the LVM (Logical Volume Manager). A tutorial example is given on how to create a new PV.

What Is PV (Physical Volume)? PV represents a single physical hard disk, or a partition of a hard disk, to be managed by the LVM (Logical Volume Manager). One or more PVs are combined to form a single VG (Volume Group).

There are a number commands provided on CentOS 8 systems for you to create and manage PVs.

1. List all PVs that are currently created on all connected physical storage media using the "pvs" command, which is also a sub-command of the "lvm" command. The output shows that I have 1 PV created on /dev/sda7, linked to "cl" VG with 0 free space.

herong$ sudo pvs
  PV         VG Fmt  Attr PSize   PFree
  /dev/sda7  cl lvm2 a--   96.65g      0

herong$ sudo lvm pvs
  PV         VG Fmt  Attr PSize   PFree
  /dev/sda7  cl lvm2 a--   96.65g      0

2. Display details of each PV using the "pvdisplay" command, which is also a sub-command of the "lvm" command. The output shows the PV is configured with 4MiB for each PE (Physical Extent).

herong$ sudo pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda7
  VG Name               cl
  PV Size               <96.66 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              24743
  Free PE               0
  Allocated PE          24743
  PV UUID               bFdGY0-JZK8-5OdS-qV3B-A7qQ-...

What Is PE (Physical Extent)? PE represents a unit of continuous storage space in a PV to be mapped to a LV (Logical Volume).

How To Create a New PV? If you have some free space on a hard disk, you can create a partition, and convert it into a PV using the "pvcreate" command as shown below.

1. Verify free space on the hard disk. The output shows a 900GB free space between partition #1 snd #2.

herong$ sudo parted /dev/sdb print free
Number  Start   End     Size    File system  Name     Flags
        17.4kB  1049kB  1031kB  Free Space
 1      1049kB  100GB   100GB   ext4         primary
        100GB   1000GB  900GB   Free Space
 2      1000GB  2000GB  1000GB               primary
        2000GB  2000GB  1122kB  Free Space

2. Create a new partition of 100GB as a primary partition and set it to use "ext4" file system. The output shows that the new partition is created as /dev/sdb3.

herong$ sudo parted /dev/sdb mkpart primary ext4 100GB 200GB
Information: You may need to update /etc/fstab.

herong$ sudo parted /dev/sdb print free
Number  Start   End     Size    File system  Name     Flags
        17.4kB  1049kB  1031kB  Free Space
 1      1049kB  100GB   100GB   ext4         primary
        100GB   100GB   595kB   Free Space
 3      100GB   200GB   100GB                primary
        200GB   1000GB  800GB   Free Space
 2      1000GB  2000GB  1000GB               primary
        2000GB  2000GB  1122kB  Free Space

3. Create a new PV with /dev/sdb3 using the "pvcreate" command, which is also a sub-command of the "lvm" command.

herong$ sudo pvcreate /dev/sdb3
  Physical volume "/dev/sdb3" successfully created.

herong$ sudo pvdisplay

  "/dev/sdb3" is a new physical volume of "93.13 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb3
  VG Name
  PV Size               93.13 GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               G0DaHC-tLo2-c7Du-DDDo-7y6A-...

Note that if you are converting an partition that has been formatted with a file system, you get a warning message saying that the file system type signature will be wiped out. Of course its data will be damaged. So only do this if you don't need the data any more.

herong# pvcreate /dev/sdc2
WARNING: ext4 signature detected on /dev/sdc2 at offset 1080.
  Wipe it? [y/n]: y
  Wiping ext4 signature on /dev/sdb2.
  Physical volume "/dev/sdb2" successfully created.

Note that you can also convert an entire new hard disk into a PV by using the hard disk device file like /dev/sdc.

See next tutorials on what is VG (Volume Group) and how to build VG with PVs.

Table of Contents

 About This Book

 Introduction to Linux Systems

 Cockpit - Web Portal for Administrator

 Process Management

 Files and Directories

 Users and Groups

 File Systems

 Block Devices and Partitions

LVM (Logical Volume Manager)

 What Is LVM (Logical Volume Manager)

Create New PV (Physical Volume)

 Add/Remove PV on VG on the Fly

 Create LV on VG on the Fly

 Extend /home LV with a New Partition

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

 Internet Networking Tools

 SSH Protocol and ssh/scp Commands

 Software Package Manager on CentOS - DNF and YUM

 vsftpd - Very Secure FTP Daemon

 Postfix - Mail Transport Agent (MTA)

 Dovecot - IMAP and POP3 Server

 Email Client Tools - Mail User Agents (MUA)

 LDAP (Lightweight Directory Access Protocol)

 Administrative Tasks

 References

 Full Version in PDF/EPUB