LVM Configuration : Physical Volume (PV) Operations/Utilities

The first step in implementing LVM is to create physical volumes. In addition to creating physical volumes, commands exist to display the attributes of physical volumes, remove physical volumes, and perform other functions on physical volumes.

Creating Physical Volumes

Use the pvcreate command to create physical volumes. The syntax is:

# pvcreate [options] device

You can initialize multiple disks or partitions for use by LVM in the same command. For example, the following command initializes two disks (you can also use disk partitions here). The –v option makes the output more verbose:

# pvcreate -v /dev/sdb /dev/sdc
    Wiping internal VG cache
    Wiping cache of LVM-capable devices
    Wiping signatures on new PV /dev/sdb.
    Wiping signatures on new PV /dev/sdc.
    Set up physical volume for "/dev/sdb" with 41943040 available sectors.
    Zeroing start of device /dev/sdb.
    Writing physical volume data to disk "/dev/sdb".
  Physical volume "/dev/sdb" successfully created.
    Set up physical volume for "/dev/sdc" with 41943040 available sectors.
    Zeroing start of device /dev/sdc.
    Writing physical volume data to disk "/dev/sdc".
  Physical volume "/dev/sdc" successfully created.

Displaying Physical Volumes

Use the pvdisplay command to display attributes of physical volumes.

v# pvdisplay
  ...
  --- NEW Physical volume ---
  PV Name               /dev/sdb
  VG Name               
  PV Size               20.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               cqd7sN-0cSk-NGT5-cd9c-1Efk-vbKS-v1Bkha

In addition to pvdisplay, two other commands list information about physical volumes. The pvs command reports information about physical volumes in a more condensed form. The pvscan command scans all disks for physical volumes. Example:

# pvs
  PV         VG Fmt  Attr PSize  PFree 
  /dev/sda2  cl lvm2 a--  19.00g     0 
  /dev/sdb      lvm2 ---  20.00g 20.00g
  /dev/sdc      lvm2 ---  20.00g 20.00g
# pvscan
  PV /dev/sda2   VG cl              lvm2 [19.00 GiB / 0    free]
  PV /dev/sdc                       lvm2 [20.00 GiB]
  PV /dev/sdb                       lvm2 [20.00 GiB]
  Total: 3 [59.00 GiB] / in use: 1 [19.00 GiB] / in no VG: 2 [40.00 GiB]

Removing Physical Volumes

Use the pvremove command to remove a physical volume, for example:

# pvremove /dev/sdc
  Labels on physical volume "/dev/sdc" successfully wiped.
# pvdisplay /dev/sdc
  Failed to find physical volume "/dev/sdc".

Additional PV Commands

The following are other commands that are associated with the manipulation of physical volumes:

  • pvchange: Change the attributes of physical volumes.
  • pvresize: Resize physical volumes.
  • pvck: Check the consistency of physical volumes.
  • pvmove: Move extents from one physical volume to another.
Related Post