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

Series of tutorial to learn LVM commands. In this part of 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 widely used volume manager in HPUX and some Linux flavors too. This tutorial will be split into 4 parts :

Lets dive into first part i.e. physical volume.
Physical volume is raw disk presented to operating system. It can be 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 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.
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 same server then 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 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 dosnt 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.
Here many fields are self explanatory. Refer LVM legends to have 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 disk has bad sectors. Below is output in which PV is part of volume group already.
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 will cover these commands in next post.
SHARE

sangeethakumar

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment