How do I import and use a hardware snapshot of an LVM volume group?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 9
  • LVM2
  • SAN-based VG snapshots/clones

Issue

  • Part of a disaster recovery process requires systems to have multiple copies (snapshots) of production data presented to hosts at one time. How do I properly change the UUIDs of the associated volume group (VG) and physical volume (PV) of snapshot or cloned VGs so that they can be mounted all at the same time?

Resolution

  • LVM2 in RHEL5 now includes the vgimportclone script to properly modify UUIDs to enable cloned volume groups to be mounted and used on systems that are also mounting the original volume group. Usage of vgimportclone follows this syntax:
vgimportclone [-n|--basevgname VolumeGroupName] [-i|--import] PhysicalVolume [PhysicalVolume...]
  • For example, suppose VG named test_vg contains two PVs (/dev/loop0 and /dev/loop1) and suppose /dev/loop2 and /dev/loop3 are respective cloned PVs of the original PVs /dev/loop0 and /dev/loop1.  To rename the VG associated with /dev/loop2 and /dev/loop3 from test_vg to test_vg_snap (and change associated VG and PV UUIDs):
vgimportclone --basevgname test_vg_snap /dev/loop2 /dev/loop3
  • For Red Hat Enterprise Linux 9, systems that use the use_devicesfile feature include --importdevices parameter when running vgimportclone.
vgimportclone --basevgname test_vg_snap  --importdevices /dev/loop2 /dev/loop3

Diagnostic Steps

  • There is no need to modify the lvm filter when running this command to filter out the original PVs. The tool manages its own filter modifications internally when required.

  • If the PV is not visible with the configured filter set at the time it is run it will fail with the below error.

# vgimportclone -n tvg0-clone /dev/loop1
Fatal: /dev/loop1 is not a PV., error: 5
SBR
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.