One of the frequently asked question when implementing VMware on NFS is how would you implement file recovery from within a VMDK backup and what tools are available to accomplish this?
Implementing array based snapshots to backup entire datastores and their contents is a simple and a well documented process, however, often times customers have the need to recover specific files from within VMDKs.
Depending on the Datastore type used (VMFS vs NFS) the process and the administrative steps required as well as the associated costs vary greatly.
With VMFS you can could treat the Virtual Machines as Physical servers and deploy backup agents inside each VM and have file level backup and restore granularity. All that at the expense of typically higher CPU and Memory consumption, multiple backup schedules and in general higher acquisition and operational costs.
Another approach would be to use a combination of Vmware's Consolidated Backup (VCB) and Backup software and do file level backups and restores.
How about NFS?
The backup process using NFS is very simple. Because we control the filesystem we know what's in there and we can recover specific files (.vmdk, .vmx) or any file that's in a VM directory.
However, what is the process to provide further granularity and be able to restore a specific file from within a VMDK backup in an NFS implementation without using backup software agents or proxies?
There are several options to accomplish this however, today I'll talk about a couple of them. Both require a CIFS share to be created onto the snapshot directory of the NFS volume (i.e /vol/vmdata/.snapshot).
In both cases you will be accessing the snapshot directory from the Virtual Machine that requires the needed file by specifying the UNC path. This process works for Windows VMs and requires VMDKs with a single partition.
Option 1
This option was recently discovered and further developed (Registry entries and Batch script) by one of the NetApp SE's (Mike Arndt) and it's very effective and free for those customers that already have a CIFS license with their NetApp arrays, which is a very large percentage. The other important factor is that Mike has made it a point-and-click process. Great job Mike!!!
As part of their VMware Disk Developer's Kit, VMware provides a vmware-mount.exe utility that allows for mounting an existing VMDK on a Windows Driver letter. We'll be using this utility as well to mount the VMDK as well as some Registry Entries and a Batch Script to further simplify the file recovery process.
Step 1: Download and install the kit from the above link
Step 2: Registry Entries
The following registry entries can be added by putting them in a file with a .reg extension and double-clicking on the file. The entries will provide you with a "VMDK Mount" and "VMDK UnMount" option when you right click in the Windows Explorer interface.
REGEDIT4 ; The following registry keys will put right click shortcuts in place for VMDKMounter.[HKEY_CLASSES_ROOT\.vmdk]
@="VMware.VirtualDisk"[HKEY_CLASSES_ROOT\.vmdk\VMware.VirtualDisk\ShellNew]
@=""[HKEY_CLASSES_ROOT\VMware.VirtualDisk\Shell\vmdkmounter]
@="VMDK Mount"[HKEY_CLASSES_ROOT\VMware.VirtualDisk\Shell\vmdkmounter\command]
@="cmd.exe /c "c:\\Program Files\\NetApp\\VMDKMounter\\vmdkmounter.bat" mount %1"[HKEY_CLASSES_ROOT\Drive\shell\vmdkmounter]
@="VMDK UnMount"[HKEY_CLASSES_ROOT\Drive\shell\vmdkmounter\command]
@="cmd.exe /c "c:\\Program Files\\NetApp\\VMDKMounter\\vmdkmounter.bat" unmount %1"
Step 3: Batch Script
The following batch script needs to be placed in C:\Program Files\NetApp\VMDKMounter in order for the previously mentioned registry entries to work properly.
Note: The Lines marked in red should be one line.
@ECHO OFF SET vmware_mount_cmd_path="C:\\Program Files\\VMware\\
VMware Virtual Disk Development Kit\\bin\\vmware-mount.exe" IF EXIST %vmware_mount_cmd_path% GOTO CONTINUE ECHO The vmware-mount utility is not installed. Exiting. GOTO EXIT0
:CONTINUE IF "%1"=="mount" GOTO GETDRIVE set drive_letter=%2 ECHO Unmounting VMDK on drive %2 ... %vmware_mount_cmd_path% %drive_letter:~0,2% /d /f GOTO EXIT0
:GETDRIVE SET /P drive_letter="Enter Drive Letter [Z:] " IF NOT "%drive_letter%"=="" GOTO CHECKDRIVE SET drive_letter=Z: :CHECKDRIVE
IF NOT EXIST %drive_letter% GOTO DOMOUNT ECHO Drive %drive_letter% appears to already be in use! Exiting. GOTO EXIT0
:DOMOUNT ECHO Mounting VMDK on drive %2 ... %vmware_mount_cmd_path% %drive_letter% %2 /m:n explorer %drive_letter%
:EXIT0 @ping 127.0.0.1 -n 5 -w 1000 > nul
File Recovery Process
Step 1: Use the UNC path to access the snapshot directory (Figure 1)
Step 2: Pick the snapshot you want and drill down and into the VM folder
Step 3: Select the *.vmdk (not the -flat.vmdk), right click the "VMDK Mount"
Step 3: Drag and Drop the file and use"VMDK UnMount" option when done.
Figure 1 Figure 2
Option 2
This option is, to a certain extent, similar with option 1. The main difference here is that you don't need VMware's Virtual Disk Developer's Kit.
Instead, what you need is to license a tool that is able to crack open a VMDK. Such tool is UFS Explorer Standard Access or WinImage. A UFS Explorer Standard Access Business license runs around $65 and you can install it on as many Windows systems as you want , as long as you own the systems. I like UFS Explorer primarily because it supports several filesystem types (supports VHD images) versus WinImage which only supports NTFS.
The way the recovery process works is as follows:
Step 1: Install UFS Explorer into the VM(s) or into a VM used for recovery purposes
Step 2: Map a Network Drive to the NetApp snapshot folder using the UNC path or even all the way into the VM folder that resides under the snapshot you want
Step 3: Point UFS Explorer into the -flat.vmdk file (not the (.vmdk file).
Step 4: Explore the VMDK and drag and drop the file you need
Done. Simple, Easy and cost effective!!!!


Nice post.
You can also do file level recoveries with a Linux host that has access to your filer's snapshots. Loopback mount the VMDK file from the snapshot on the Linux host and get the file(s) you need from the VMDK.
If you have Windows guests, you may need to build the NTFS kernel module depending on which Linux distribution you're using.
Posted by: Brandon | July 23, 2008 at 03:29 PM
Thanks Brandon,
You are correct you can do that too. In fact, I've written about it a while back on an old blog I kept:
http://storagefoo.blogspot.com/2007/09/vmware-on-nfs-backup-tricks.html
http://storagefoo.blogspot.com/2007/10/vmware-over-nfs-backup-trickscontinued.html
Posted by: Nick Triantos | July 23, 2008 at 03:40 PM
Very nice post.
This is a very good (real world) example how NFS can help you to simplify your ESX environment.
Posted by: Markus | July 24, 2008 at 01:21 PM
Same can be done with VMware DiskMount GUI from http://petruska.stardock.net/Software/VMware.html
Posted by: Seb | July 26, 2008 at 11:17 AM
Hey Nick,
I used the software, it worked good for non-LVM VMs, but it doesnt work with a VM that has linux LVM, which we do to split up the logs from the OS. I ended up after a few days figuring it out myself where you dont need that software at all...here are the steps if your VM has logical volumes.
-----------------------
create NetApp flexclone from snapshot:
-----------------------
1. vol clone create /vol/vmnfsXXXbk -s none -b parent_volume_name snapshot_name
(parent_volume_name = vmnfsXXX in our environment)
2. vol options clone_name nosnap on
3. snap sched clone_name 0 0 0
-----------------------
Run on linux VM:
-----------------------
1. mount your NFS snapshot flex clone in linux:
mount SAN_IP_ADDRESS:/vol/vmnfsXXXbk /mnt/vmnfs
2. losetup /dev/loop0 /mnt/vmnfs/SERVER_NAME/SERVER_NAME-flat.vmdk
(replace SERVER_NAME with actual VMware server path)
Example: losetup /dev/loop0 /mnt/vmnfs/WEB1/WEB1-flat.vmdk
3. kpartx -av /dev/loop0
4. vgscan
this will return something like:
Reading all physical volumes. This may take a while...
Found volume group "VolGroup00" using metadata type lvm2
5. vgchange -ay VolGroup00
This will return something like:
2 logical volume(s) in volume group "VolGroup00" now active
6. lvs
This will return something like:
LogVol00 VolGroup00 -wi-a- 5.06G
LogVol01 VolGroup00 -wi-a- 30.00G
7. mount /dev/VolGroup00/LogVol00 /mnt/vm
Thats it...
--------------------------------------
Unmount the vmdk:
--------------------------------------
1. umount /mnt/vm
2. vgchange -an VolGroup00
3. kpartx -d /dev/loop0
4. losetup -d /dev/loop0
Posted by: Steven Craig | July 28, 2008 at 02:38 PM
Great stuff Steven. Thanks for figuring this out. Very helpful.
Posted by: Nick Triantos | July 28, 2008 at 04:40 PM
I have followed the instructions to a tee and I get an error when I try to mount the .vmdk file. It tells me that "This file does not have a program associated with it for performing this action. Create an association in the Folder Options control panel."
What did I miss?
Posted by: Pat | July 30, 2008 at 09:16 AM
Pat,
I had the same issue. It seems the .reg file didn't enter the path into the registry eky.
Try going in and manually entering the paths to the executable into the registry in each location given in the script.
So, in the HKCR\Drive\Vmware.VirtualDisk\Shell\vmdkmounter\command
Double-click the (Default) key and paste the path "cmd.exe /c "c:\\Program Files\\NetApp\\VMDKMounter\\vmdkmounter.bat" mount %1" without the outside double-quotes.
Repeat with the other key.
Posted by: Thomas Joyce | August 01, 2008 at 01:10 PM
There seems to be a UFS Reader for free on
sourceforge. Haven't tested it yet.
http://mount-ntfs.sourceforge.net/
Posted by: isi | August 12, 2008 at 07:06 AM
sorry, does'nt work
Posted by: isi | August 12, 2008 at 07:24 AM