How do you mount logical volume from a duplicate PV? The duplicate PV here is a VMware VM vmdk restored from a NAS datastore snapshot, NAS datastore snapshot being the backup method for VM in our NAS cluster.
1) I use the datastore browser to copy the vmdk from [datastore].snapshot/snapshot_time_folder/vmname/diskname.vmdk to a folder in [datastore]vmname/backup
2) I attach the copied vmdk to the VM
3) After this, LVM commands inside the Guest OS reports a duplicate PV and I cannot access the VGs and LVs from the restored disk. The reason being that the PV, LV and VG has the same UUID as the original ones still mounted.
4) I use vgimportclone to rename PV, LV and VG from the restored disk
vgimportclone -n myvg /dev/sdx [/dev/sdx ...]
where myvg will be the new vg name and sdx is the restore vmdk. If myvg exists, a number suffix such myvg1 will be generated.
5) I can’t yet mount the LVs because they have to be activated
vgchange -ay myvg
6) Check the LVs status with
lvscan
7) Mount the LV
mount /dev/myvg/lv /mount_point
8) RHEL7 complains of a duplicate filesystem UUID, hence use
mount -o nouuid /dev/myvg/lv /mount_point
After restoring the data, if you are going to remove the restored vmdk from the VM, you must first deactivate the LVs, otherwise every LVM command will report they are missing and you have to manually rm the associate files.
1) Unmount all LVs from the restored disk
2) Deactivate the LVs
vgchange -an myvg
3) Remove the disk from the VM
I have used this method on both RHEL 6 and RHEL 7.