Tag Archives: how to remove 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.