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

This is forth and 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 til now under part two. Now we will cover remaining two commands in this post.

Command : vgremove

vgremove commands used to remove volume group from 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 system but keeps it untouched on PV so that same PV can be imported to new VG on new/same system using vgimport.

Read : LVM legends

Safe removal of VG can be done with below steps :

    1. Backup all user data in that VG
    2. Get information of 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
    4. Unmount mount points of related LV
    5. Remove all LVs with lvremove /dev/vg01/lvol-name command
    6. Remove all PVs in VG except any one with vgreduce /dev/vg01 /dev/disk/diskX command
    7. Finally use vgremove command to remove VG from system
    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. Once can observe 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.

There are no special option requried for this command.


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

Any thoughts?