How do I import and use a hardware snapshot of an LVM volume group?
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
clonedVGs so that they can be mounted all at the same time?
Resolution
- LVM2 in RHEL5 now includes the
vgimportclonescript 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 ofvgimportclonefollows this syntax:
vgimportclone [-n|--basevgname VolumeGroupName] [-i|--import] PhysicalVolume [PhysicalVolume...]
- For example, suppose VG named test_vg contains two PVs (
/dev/loop0and/dev/loop1) and suppose/dev/loop2and/dev/loop3are respective cloned PVs of the original PVs/dev/loop0and/dev/loop1. To rename the VG associated with/dev/loop2and/dev/loop3fromtest_vgtotest_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 theuse_devicesfilefeature include--importdevicesparameter when runningvgimportclone.
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
Product(s)
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.