Tag Archives: volume group

LVM commands tutorial: Part 2: Volume group (vgremove, vgsync)

Series of the tutorial to learn LVM commands. In this part, learn how to remove volume group from the system and how to sync stale PE within VG (vgremove, vgsync)

This is the fourth and the last post of part two which is related to volume group in our LVM commands tutorial. Rest of the parts and posts can be found in below links :

We have seen 10 commands of volume group activities until now under part two. Now we will cover the remaining two commands in this post.

Command: vgremove

vgremove commands used to remove the volume group from the system. But this is destroying command since it requires removal of all LV, PV in VG. It is always recommended to use vgexport instead of vgremove. Since vgexport also removes VG information from the system but keeps it untouched on PV so that the same PV can be imported to new VG on the new/same system using vgimport.

Safe removal of VG can be done with the below steps :

  1. Backup all user data in that VG
  2. Get information about all LV and PV in that VG using vgdisplay -v command
  3. Make sure no LV is in use using fuser -cu /mount_point command
    # fuser -cu /data /data:   223412c(user1) 
  4. Unmount mount points of related LV
    # umount /data 
  5. Remove all LVs with lvremove /dev/vg01/lvol-name command
    # lvremove /dev/vg01/lvol1 The logical volume "/dev/vg01/lvol1" is not empty; do you really want to delete the logical volume (y/n) : y Logical volume "/dev/vg01/lvol1" has been successfully removed. Volume Group configuration for /dev/vg03 has been saved in /etc/lvmconf/vg01.conf 
  6. Remove all PVs in VG except anyone with vgreduce /dev/vg01 /dev/disk/diskX command
    #vgreduce /dev/vg01 /dev/disk/disk4 Volume group "/dev/vg01" has been successfully reduced. Volume Group configuration for /dev/vg01 has been saved in /etc/lvmconf/vg01.conf 
  7. Finally, use vgremove command to remove VG from system
    # vgremove /dev/vg01 Volume group "/dev/vg01" has been successfully removed  
  8. Remove related group files from system using rm /dev/vg01 command

Command: vgsync

This command used to sync stale LE of LV mirrors in current VG. This used in mirroring only. One can observe the output of vgdisplay -v and confirm if there are any stale LE in current VG. If you found stale LE then you can synchronize them using this command.

# vgsync /dev/vg01
Resynchronized logical volume "/dev/vg01/lvol01".
Resynchronized logical volume "/dev/vg01/lvol02".
Resynchronized volume group "/dev/vg01".

There are no special options required for this command.

This concludes part two (Volume group) of our LVM tutorials.

Basics of LVM legends

Get acquainted with LVM (Logical Volume Manager) terms. Learn what is physical volume, logical volume, physical extent, volume group, and logical extent.

LVM (logical volume manager) legends

PV is a Physical Volume

Any single disk / LUN on the system is identified as PV. It can be raw or formatted with a file system. Raw PV is referred to as /dev/rdsk/c0t0d1 (legacy) or /dev/rdisk/disk1 (agile) whereas formatted one is referred to as  /dev/dsk/c0t0d1 (legacy) or /dev/disk/disk1 (agile). Check PV name in below output as a formatted device.

# vgdisplay -v vg00

--- Volume groups ---
VG Name                     /dev/vg00
VG Write Access             read/write
VG Status                   available
Max LV                      255
Cur LV                      13
Open LV                     13
Max PV                      16
Cur PV                      1
Act PV                      1
Max PE per PV               4355
VGDA                        2
PE Size (Mbytes)            32
Total PE                    4345
Alloc PE                    4303
Free PE                     42
Total PVG                   0
Total Spare PVs             0
Total Spare PVs in use      0

   --- Logical volumes ---
   LV Name                     /dev/vg00/lvol1
   LV Status                   available/syncd
   LV Size (Mbytes)            1024
   Current LE                  32
   Allocated PE                32
   Used PV                     1

   --- Physical volumes ---
   PV Name                     /dev/dsk/c3t0d0s2
   PV Status                   available
   Total PE                    4345
   Free PE                     42
   Autoswitch                  On
   Proactive Polling           On
Physical volume naming conventions :

/dev/rdsk/cxtxdx – Legacy character device file
/dev/rdsk/cxtxdxs2 – Legacy character device file, partition 2
/dev/dsk/cxtxdx – The legacy block device file
/dev/dsk/cxtxdxs2 – Legacy block device file, partition 2
/dev/rdisk/diskx – The persistent character device file
/dev/rdisk/diskx_p2 – Persistent character device file, partition 2
/dev/disk/diskx – The persistent block device file
/dev/disk/diskx_p2 – Persistent block device file, partition 2

PE is Physical Extent

Its smallest chunk of PV can be used as a block under the file system. PV is consists of the number of PEs. We always use PV names while using LVM commands. In the above example, PE size is set to 32MB & a total of 4345 PEs are available on disk.

Read our LVM tutorials: LVM cheat sheet.

VG is Volume Group

One or more PV come together to form a Volume Group. This grouping enables to slice down combined
storage capacity of disks to our choice of small volumes. In the above example, vg00 is volume group made up of single PV & it’s sliced down to 8 LV (only one shown in above example)

LV is the Logical Volume

Its a slice of volume group using some capacity of PV to form a smaller volume. Its basically used as a mount point /swap like drives (C:, D:) in Windows. We can see one LV in above example and its details.
LE is Logical Extent.
Same as PE, LE is the smallest chunk of LV.

Below tables gives you an idea about some numbers related to them:

LVs per VG range: 1-255, default: 255
PVs per VG range: 1-255, default: 16
PEs per VG   range : 1-66535 default : 1016

with the above table, as max PE size is 64MB and 66,535 PEs max per VG, one can create a max of 64×66353=4TB of the file system.