Hey man,
I've needed to mount 2 cloned vg's on the same machine, one of them is the running vg (Production) and the other one is a cloned (or snapshot) version on the production VG.
Here is what you need to do to accomplish this task
1. MAKE SURE that no one is running LVM command while you'r doing this steps !
2. Create a temporary lvm dir (lets name it lvmtemp)
now copy the lvm.conf file from /etc/lvm to /lvmtemp
Code:
cp /etc/lvm/lvm.conf /lvmtemp
Export the variable LVM_SYSTEM_DIR to point to the temporary dir
Code:
export LVM_SYSTEM_DIR=/lvmtemp/
* This step is needed if you somehow reboot your system while editing your lvm.conf file and your system won't boot up
3.Change filter in your temporary /lvmtemp/lvm.conf file to only see the cloned LUN and your boot LUN
Code:
filter = [ "a|/dev/mapper/CLONE|","a|/dev/mapper/BOOT|","r/.*/" ]
4. Run pvscan command (you should see only the cloned LUN and the boot LUN)
5.Change the UUID's of the cloned PV & VG and rename to avoid duplicates and avoid clashes with the application LUN
Code:
pvchange --uuid /dev/mapper/CLONE --config 'global{activation=0}'
vgchange --uuid vgAPP --config 'global{activation=0}'
vgrename vgAPP vgAPP-clone --config 'global{activation=0}'
* The key here is the switch --config 'global{activation=0}' this deactivates device-mapper interaction and thus the commands only change the LVM metadata and not the devices on the system (otherwise the system will think you are changing the VG used for the production application)
6.Remove temporary LVM system directory and lvm.conf
Quote:
unset LVM_SYSTEM_DIR
rm -rf /lvmtemp
|
7. Run pvscan , vgscan & lvscan and see both physical volumes, volume groups and logical volumes now appear without any error messages about duplicate PV/VG UUID's
8.Activate the clone's VG
Code:
vgchange -ay vgAPP-clone
9. Recreate the LVM /dev/ nodes:
There is a minor bug in the vgchange command, even though we specified --config 'global{activation=0}' there was still minor interaction in /dev/vgAPP, renaming it to /dev/vgAPP-clone.
Without affecting any production application/volume group you can recreate these device node entries in /dev/:
10.You should now be able to mount your /dev/vgAPP-clone volume groups, file systems and recover data as required