Tag Archives: how to view physical volume details

LVM commands tutorial : Part 1 : Physical Volume (pvcreate, pvdisplay)

Series of the tutorial to learn LVM commands. In this part of the tutorial, learn how to create physical volume and how to view its details (pvcreate, pvdisplay)

We are starting this tutorial series for LVM (Logical Volume Manager) which is a widely used volume manager in HPUX and some Linux flavors too. This tutorial will be split into 4 parts :

Let’s dive into the first part i.e. physical volume.

A physical volume is a raw disk presented to the operating system. It can be a local disk, LUN from remote storage, disk from local disk array, etc. All storage disks from these types are formatted as physical volumes under LVM so that those can be used in definite file systems.

Command: pvcreate

Lets start with the first command to create physical volume. Before using this command you need to confirm your new raw disk on OS. You can use ioscan -fnCdisk command or confirm by checking into /dev/rdsk (or /dev/rdisk) directory.

Note : /dev/rdsk/cXdXtX is legacy naming conventions (HPUX 1111,11.21,10.x) whereas /dec/rdisk/diskX is persistent naming convention (11.21, 11.31).

Now that you identified new disk presented to server lets say /dev/rdisk/disk3 for example, you can run pvcreate command to create physical volume out of it.

# /usr/sbin/pvcreate /dev/rdisk/disk3
Physical volume "/dev/rdisk/disk3" has been successfully created.

The command outputs success message confirming PV has been created. Note here that you should use character device file i.e. with /dev/rdisk/diskX.

If by mistake you put in wrong disk name or disk is already being used in LVM on the same server then the command will fail. If you presented disk which was used earlier on another server and now you want to use it here with data loss then -f option can be used to forcefully create PV by destroying any data present on the disk. Note here that -f option do not ask any confirmation before deleting data.

There are other options can be used with this command which are:

  • -B to make it bootable disk. Used during root disk mirroring
  • -b, -d related to bad blocks
  • -s to specify effective size. Normally everyone uses full disk so this options doesn’t matter much
  • -t driver related

Normally these options are not used when we are aiming at PV for mount point usage only. Hence we are not going drill down these options.

Command: pvdisplay

Now, PV has been created one can see its details with pvdisplay command.

# /usr/sbin/pvdisplay /dev/disk/disk3
--- Physical volumes ---
PV Name                     /dev/disk/disk3
VG Name                     
PV Status                   available
Allocatable                 yes
VGDA                        2
Cur LV                      0
PE Size (Mbytes)            32
Total PE                    1557
Free PE                     1557
Allocated PE                0
Stale PE                    0
IO Timeout (Seconds)        default
Autoswitch                  On
Proactive Polling           On

Here many fields are self-explanatory. Refer LVM legends to have a better understanding.  From this output, you can also calculate disk size. Total PE x PE size = Disk size (available to use i.e. after formatting space loss)

If you want to drill down PE details i.e. which PE is serving which LV then -v option can be used. This is helpful when the disk has bad sectors. Below is the output in which PV is part of the volume group already.

# /usr/sbin/pvdisplay -v /dev/disk/disk3
--- Physical volumes ---
PV Name                     /dev/disk/disk3
VG Name                     /dev/vg01
PV Status                   available
Allocatable                 yes
VGDA                        2
Cur LV                      1
PE Size (Mbytes)            32
Total PE                    1557
Free PE                     0
Allocated PE                1557
Stale PE                    0
IO Timeout (Seconds)        default
Autoswitch                  On
Proactive Polling           On

   --- Distribution of physical volume ---
   LV Name                 LE of LV  PE for LV
   /dev/vg01/lvol1         1557      1557

   --- Physical extents ---
   PE    Status   LV                      LE
   00000 current  /dev/vg01/lvol1         00000
   00001 current  /dev/vg01/lvol1         00001
   00002 current  /dev/vg01/lvol1         00002
   00003 current  /dev/vg01/lvol1         00003
   00004 current  /dev/vg01/lvol1         00004
   00005 current  /dev/vg01/lvol1         00005
   00006 current  /dev/vg01/lvol1         00006
   00007 current  /dev/vg01/lvol1         00007
   00008 current  /dev/vg01/lvol1         00008
   00009 current  /dev/vg01/lvol1         00009
   00010 current  /dev/vg01/lvol1         00010
   00011 current  /dev/vg01/lvol1         00011
   00012 current  /dev/vg01/lvol1         00012
----- output truncated -----

Here you can see how PV is distributed among different LV. and furthermore, it gives you table mapping of PE to LE! There are numerous options can be used with this command but normally -v is used commonly.

There are two more commands used for PV operations: pvchange, pvmove. We covered theme commands in the next post.