LVM commands tutorial : Part 2 : Volume group (vgcreate, vgdisplay, vgscan)

Today we are starting with part two of LVM command tutorial series. Other series posts can be found here :

This is first post of part two which will be taking care of volume group activities. In following writeup we are going to see commands how to create volume group, how to view details of volume group and how to scan volume groups to build new /etc/lvmtab file.

Command : vgcreate

As we all know volume group i.e. VG is a collection if PV. Refer LVM legands for better understanding. VG creation is the next necessary step after PV creation to use disk space in mount points. Since in Unix everything is a file, to manage VG, kernel creates /dev/vgname/group file. This file represents VG in kernel. Let us see how to create VG from bunch of available PV. Post Mar 2008 releases of HPUX creates group file automatically with vgcreate command. But we will see here to how to make one.

First create a directory with desired name of your VG for ex. lets say testvg is our VG name. After that using mknod command create special group file. In command you need to supply major and minor numbers.

major number : 64 for version 1.0 VG and 128 for version 2.0 VG
minor number : Its hexadecimal number. 0xnn0000 for v1.0 and 0x0000 for v2.0 where nn/nnn is unique number.

Now that special file is generated go ahead to create VG

vgcreate can be run with single PV argument too. This command has several options as below :

  • -V 1.0            To decide version.
  • -s PE_size    Size of PE to be used in MB. Default is 4MB
  • -e max_PE   Max PE per PV. Default is 1016
  • -l max_lv      Max number of LV per VG. Default is 255
  • -p max_pv   Max number of PV per VG. Default is 255
  • -S vg_size    Max future size of VG. Only in v2.0.


Above options can be supplied to command with proper values but its not mandatory. If not supplied then their respective values will be taken into consideration while creating VG. Changes in parameters with these options can be seen in vgdisplay output which you can see in coming section.

Command : vgdisplay

Same as pvdisplay command, vgdisplay is used to view VG details. vgdisplay command can be run with -v option to get more detailed output. If run without -v option then it will show output like below but PV details portion wont be there.

In above output, you can see PE Size (Mbytes), Max PE per PV, Max LV, Max PV fields which can be altered with options -s, -e, -l, -p arguments in vgcreate command we seen above.  The above output is pretty self explanatory. It also shows PV details which are part of this VG.

Command : vgscan

This command used for scanning all available PVs to get information of VG and related LV’s and rebuild /etc/lvmtab file. This command used below options :

  • -a Scan all available PV paths.
  • -B Write all persistent and legacy paths to /etc/lvmtab file
  • -f vg_name Force to update entries of existing VG in /etc/lvmtab with updated info if any
  • -k Avoid probing disks. Build file from kernel known structure.
  • -N Populate file with persistent DSF names
  • -p Preview mode only. It wont update lvmtab file
  • -v verbose mode. Prints messages in console.

Normally we use vgscan -v only. After this command you can verify timestamp of /etc/lvmtab file to verify its been updated.

This concludes first 3 commands of VG. In next post we will see how to extend volume group, how to reduce volume group and how to export/import volume group.



Any thoughts?