Tag Archives: how to take volume group backup

LVM commands tutorial : Part 2 : Volume group (vgcfgbackup, vgcfgrestore, vgchange)

Series of the tutorial to learn LVM commands. In this part, how to backup/restore VG configuration and to change VG state (vgcfgbackup, vgcfgrestore, vgchange)

This is the third post of part 2 in our LVM commands tutorial. In this post, we are going to see how to backup and restore volume group configurations and how to change volume group states i.e. how to activate/de-activate volume group. Other parts of this LVM tutorial can be found on below links :

Volume group configurations play a vital role in moving PV, VG, data across systems. Let’s start with the configuration backup command.

Command: vgcfgbackup

As the command reads, it takes volume group configuration backup into a disk file residing under /etc/lvmconf directory in the file /etc/lvmconf/vg_name.conf. It reads the LVM header details from the system area of the disk and copies it to file. This file helps you to restore configuration on newly added disk in place of the old disk which may have got corrupted or failed.

It is recommended to have this backup taken after every LVM level change. By default all LVM commands altering LVM details are designed to take this backup automatically hence manually running command is not necessary.

To take manual configuration backup use command as below :

# vgcfgbackup /dev/vg01
Volume Group configuration for /dev/vg01 has been saved in /etc/lvmconf/vg01.conf

This needs to run for every volume group available on the system. This command has a couple of options :

  • -f file Save backup in the file specified rather than the default location
  • -u Only updates extra PV which are added to VG after the last backup. Only new PVs required to be online on the system. If -u not used all PV under VG should be online while running the command.

Command: vgcfgrestore

This command restores the VG configuration taken using the above command. Command mainly needs 2 argument volume group name of which configuration needs to be restored and a PV name on which configuration needs to be restored. There are two things which need to keep in mind.

If PV on which we are restoring the backup is part of the mirror copy, then it should be deactivated first. Then restore back up and reactivate it. Command sequence will be :

# pvchange -a n /dev/disk/disk5
Physical volume "/dev/disk/disk5" has been successfully changed.

# vgcfgrestore -n /dev/vg01 /dev/rdisk/disk5
Volume Group configuration has been restored to /dev/rdisk/disk5

# pvchange -a y /dev/disk/disk5
Physical volume "/dev/disk/disk5" has been successfully changed.

If PV is not a part of the mirror then you should deactivate the volume group first then restore the backup and then activate the volume group again. Command sequence will be :

# vgchange -a n /dev/vg01
Volume group "/dev/vg01" has been successfully changed.

# vgcfgrestore -n /dev/vg01 /dev/rdisk/disk5
Volume Group configuration has been restored to /dev/rdisk/disk5

# vgchange -a y /dev/vg01
Volume group "/dev/vg01" has been successfully changed.

This command has several options which can be used with it :

  • -l List configuration only
  • -F Forcefully restore
  • -f file  Restore the configuration from a specified file, not from default backup location
  • -v Verbose mode
  • -R Forcefully restore even if there is a mismatch between PV in the kernel and in config.
  • -o old_path Restore config saved for old PV (path supplied) to new PV mentioned in the command.

Command: vgchange

This command used to make the volume groups active or inactive. The activated volume group simply means it’s available for use. There are different modes of volume groups in which they can be activated. They can be listed as below :

  1. Normal availability mode
  2. Cluster aware mode
  3. Shareable mode
  4. Quoram requirement mode

vgchange command can be used with specified options and their values to activate or deactivate the volume group. For example to normally activate it should be supplied with the argument -a and its value y. See below output to activate and then deactivate volume group

# vgchange -a y vg01
Volume group “/dev/vg014” has been successfully changed.

# vgchange -a n vg01
Volume group “/dev/vg014” has been successfully changed.

Above stated modes can be activated/deactivated using the below options :

  • -a y/n Normal availability mode
  • -c y/n Cluster aware mode
  • -S y/n Shareable mode
  • -q y/n Quoram requirement mode
  • -p Only activate if all related PVs are online
  • -s Disable stale PE sync
  • -x Cross activate the shareable volume group

This concludes the third post of part two related to the volume group. In the next and last post of part two, we are covering how to remove the volume group from the system and how to sync stale PE within the volume group.