As a customer I ran into a few scenarios where I needed to restore directories or files from a restored LVM-based RHEL 6 VMDK. You cannot simply attach the restored VMDK, mount the filesystem, and copy the directories or files due to the way LVM utilizes UUIDs for logical volumes. In order to restore directories or files from a LVM-based RHEL 6 VMDK, please perform the following steps:
- Restore the VMDK either using the backup product of choice
- Attach the restored VMDK to the target VM
- Login to the VM as the root user
- Rescan the virtual SCSI bus to see the newly added disk
echo "- - -" > /sys/class/scsi_host/host0/scan
- Import the restored LVM volume group without trashing the existing one using vgimportclone
vgimportclone -n <VolGroupName>_clone /dev/<Disk Partition name ie. sdc1>
- Verify you can now see the logical volumes on the restored VMDK
lvdisplay
- Make the logical volume(s) available
lvchange -ay /dev/<VolGroupName>_clone/<LogicalVolumeName>
- Mount the restored logical volume to a temporary mount point
mount /dev/<VolGroupName>_clone/<LogicalVolumeNumber> /mnt
- Copy the target directories/files using whatever *nix tool that you prefer
- Unmount the restored logical volume
unmount /mnt
- Removed the restored volume group and physical volume
vgremove <VolGroupName>_clone
- Unattach the restored VMDK from the VM
- Delete the restored VMDK as it is no longer needed
For more details please refer to the “SMVI Single File Recovery with Linux” NetApp Communities blog post.