VMware

Brian Atkinson's Blog

Findings from the VMTN forums and the field...

Previous Next
0

I have read several blogs and articles about the possibility of file level restores for files contained within vmdks (and snapshots of vmdks) housed on NFS volumes. Most of these reads discussed, at a high level, how to make it work, and some even included commands. What I couldn't find was a decent guide to setting the whole environment up and making it work. So I built my own, and documented the steps.


Note: If you already have a working Ubuntu virtual machine that is networked and has the VMware Tools installed, or if you simply don't need the step-by-step instructions for creating one, skip straight to Step 04 below for the configuration settings.

STEP 01: CREATE THE VM
01. Using the VMware Infrastructure Client, start the New Virtual Machine Wizard.

02. Choose Custom Configuration.

03. Choose the required inventory location and datastore for the new virtual machine.

04. Choose Linux and for the version, choose Ubuntu Linux (32-bit).

05. Choose 1 virtual processor, 512 MB Memory, and 1 NIC on the appropriate network.

06. Choose the LSI Logic SCSI Adapter.

07. Create a new virtual disk, sized at 5 GB, in the appropriate location for your environment.

08. Click Next to accept the default values for the Advanced Options.

09. Click Finish.

STEP 02: INSTALL THE OS
01. Right-click the newly created virtual machine and choose Edit Settings.

02. Verify the virtual machine settings.

03. Click CD/DVD Drive 1 and choose the Ubuntu 8.04.2 installation iso or media.
Note: Remember to select the Connect at power on option in the device status area.

04. Click the OK button, and wait for the virtual machine to finish with the reconfiguration.

05. Right-click on the virtual machine and choose Open Console.

06. Press the green triangle button (or use the VM menu) to power on the virtual machine.

07. If all goes well, the Ubuntu live cd will boot. Choose a language, and then choose the Install Ubuntu option.
Note: It is always a good idea to choose the Check CD for defects before beginning.

08. At the Welcome screen, click the Forward button to continue.

09. Choose the correct time zone and click the Forward button.

10. Choose the correct keyboard layout and click the Forward button.

11. Take the default of Guided - use entire disk for the detected VMware Virtual disk and click the Forward button.

12. Fill out the name, username, password and computer name and click the Forward button.

13. At the Ready to Install screen, click the Install button.

14. Wait for the Installation complete screen, and then click the Restart now button.

15. Now press Ctrl+Alt to escape the console window, and go to the VM menu and choose Edit Settings. Select the CD/DVD Drive 1, and then un-check Connected and Connect at power on in the Device Status area. Click the OK button.

16. Press ENTER as instructed on the Ubuntu setup screen.

STEP 03: CONFIGURE THE OS - Part I
01. Login to Ubuntu, using the username and password selected during the install.

02. Choose the VM menu and select Install/Upgrade VMware Tools. Click OK at the Information Screen.
Note: If a window doesn't automatically open, double-click the VMware Tools icon on the desktop.

03. In the File Browser window, right-click the VMwareTools-X.X.X-123456.tar.gz file and choose Extract To...
At the top left, under Places, scroll down and select the directory that has the same username that you are currently logged in with - it should be the third option down. Leave all other options at the defaults, and press the Extract button.

04. On the Ubuntu desktop, on the top toolbar, use the Places menu and select Home Folder. When the File Browser window opens, verify that there is a vmware-tools-distrib directory.

05. Close all windows that are currently open in the Ubuntu virtual machine.

06. On the Ubuntu desktop, on the top toolbar, use the Applications -> Accessories menu and choose Terminal.
Enter the following commands in the terminal window:

cd vmware-tools-distrib
sudo ./vmware-install.pl

When prompted, enter your password and press Enter.
When prompted for which directory to install the binary files, press Enter.
When prompted for which directory contains the init directories, press Enter.
When prompted for which directory contains the init scripts, press Enter.
When prompted for which directory to install the daemon files, press Enter.
When prompted for which directory to install the library files, press Enter.
When informed about path creation, including parent directories, press Enter.
When prompted for which directory to install the documentation, press Enter.
When informed about path creation, including parent directories, press Enter.

The install should now be complete, but configuration still needs to happen.

When prompted about invoking the vmware-config-tools command, press Enter.
When prompted about pre-built vmmemctl modules and a C compiler, press Enter.
When prompted about the location of the C header files, press Enter.
Choose the appropriate display size by entering the corresponding number (probably 2 for 800x600) and pressing Enter
At this point, the screen will probably go black and flicker about, but the terminal window will re-appear eventually.

VMware Tools setup is now complete. Enter the following command:

exit

07. On the Ubuntu desktop, on the top toolbar, use the System menu and select Administration - Network.
On the Connections tab, select the Wired Connection and then click the Properties button.
Un-check the Enable Roaming Mode option for eth0 properties.
Under Configuration Settings - Configuration, choose the required settings for static or DHCP addressing and then click the OK button.
Select the General tab and verify the correct host name, and enter a domain name (if required).
Select the DNS tab and enter DNS servers and/or search domains (as/if required).
Click the Close button.

08. On the Ubuntu desktop, on the top toolbar, use the System menu and select Preferences - Network Proxy and configure as/if
required. If proxy server access is not required, omit this step.

09. Test network connectivity (web, ping, etc), before continuing to the next step.

STEP 04: CONFIGURE THE OS - Part II
01. On the Ubuntu desktop, on the top toolbar, use the Applications -> Accessories menu and choose Terminal.
Enter the following commands:

sudo apt-get update
sudo apt-get install portmap nfs-common

When prompted if you want to continue, type y for yes and press Enter.

02. In the same terminal window, enter the following command:

gksudo gedit /etc/hosts.deny

Add the following line to the end of the file:

portmap : ALL

Press the Save button and close gedit

Now, enter the following command:

gksudo gedit /etc/hosts.allow

Add the following line to the end of the file:

portmap : 91.189.94.8

Note: Replace 91.189.94.8 with the IP address of the correct NFS server. DNS names will not work.
Press the Save button and close gedit.

03. In the same terminal window, enter the following commands:

sudo mkdir /mnt/datastore01
sudo mount 91.189.94.8:/vol/vol1 /mnt/datastore1

Note: Replace the ip address and export path (91.189.94.8:/vol/vol1) in the above example as required.

04. On the Ubuntu desktop, on the top toolbar, use the Places menu and select Computer. Now open Filesystem in the right pane.
Open the mnt directory. datastore01 should be visible here. Open datastore01 to browse the nfs volume. To view the snapshot directory, use the View menu in File Browser to select Show Hidden Files, or press Ctrl+H. Once hidden files are visible, a .snapshot directory should be available. Browsing this directory is one way to find the path to the desired snapshot.

05. In the same terminal window, enter the following commands:

sudo mkdir /mnt/vmdk
sudo mount /mnt/datastore01/.snapshot/hourly.1/test/test-flat.vmdk /mnt/vmdk -o ro,loop=/dev/loop0,offset=32768 -t ntfs

Note: Change the above path to reflect the actual path of the desired vmdk in the desired snapshot. Also note the offset value of 32768,
which may need to be changed. See the FULL DISCLOSURE, WARNINGS AND OTHER section below for more information on the offset.

06. On the Ubuntu desktop, on the top toolbar, use the Places menu and select Computer. Now open Filesystem in the right pane.
Open the mnt directory. The vmdk directory should be visible here. Open to view/browse the contents of the virtual disk. This is one method to locate files contained in the snapshot.

07. To restore files to a Windows server, on the Ubuntu desktop, on the top toolbar, use the Places menu and select Connect to Server. Use the following settings:

Service type: Windows share
Server: dns name of the Windows server
Share: share name on Windows server - c$, USERS$, DATA$, etc
User name: Active Directory or local server account with permission to the share
Domain name: Active Directory domain name or blank if local account will be used

Click Connect and then enter the correct password, for the account provided previously. Also, choose the "Remember password until you logout" option. Ignore any errors, and then look on the desktop for the Ubuntu equivalent of a mapped drive to the Windows share.

08. From here its simple copy and paste operations from the /mnt/vmdk directory to the desired location on the Windows share to accomplish the file-level restores.

FULL DISCLOSURE, WARNINGS AND OTHER:
This document details how to create a working Ubuntu virtual machine that can recover files from NFS snapshots. If the OS is built to the level detailed in this document, the Ubuntu install will not be patched, secured or otherwise hardened in any way. For these reasons, this exact implementation is not considered ready for production environments. I can make no guarantees about the use of this setup. Use it "as-is" and at your own risk! You've been warned...

The techniques described here will not work for non-NTFS vmdk files. This essentially means, Windows virtual machines only. Other options are possible, but not covered in this document. Check VMware on NFS: Backup Tricks for additional information.

On the NFS server, the NFS datastore should be exported Read-Only to the Ubuntu virtual machine.

The NFS datastore should also be mounted Read-Only on the Ubuntu virtual machine.

Any VMDK files contained in snapshots should be mounted Read-Only on the Ubuntu virtual machine.

When mounting VMDK files that have NTFS partitions on them, you must specify the offset as part of the mount command. If you do not happen to know the partition offset of the virtual machine's disk you are working with, there is an easy way to find it. On the virtual machine in question, run msinfo32. Navigate to Components -> Storage -> Disks and then find the Partition Starting offset value. Use this value in the mount command offset option.

There is a helpful script for mounting and unmounting iso images, that is available at:
http://www.debianadmin.com/mount-and-unmount-iso-images-without-burning-them.html
that can be easily modified to mount the vmdk files from the snapshots, but will most likely need to be modified (or expanded into multiple versions) to deal with offset differences. Maybe that will be a future blog entry...

The NFS datastore can be added to fstab on the Ubuntu virtual machine, so that it is always available at boot.
To achieve this, add the following line to /etc/fstab on the Ubuntu virtual machine:
91.189.94.8:/vol/vol1 /mnt/datastore1 nfs ro,hard,intr 0 0

REFERENCES AND FURTHER READING:
VMware on NFS: Backup Tricks
http://storagefoo.blogspot.com/2007/09/vmware-on-nfs-backup-tricks.html

Guest Operating System Installation Guide
http://www.vmware.com/pdf/GuestOS_guide.pdf

ISO Mounting Scripts
http://www.debianadmin.com/mount-and-unmount-iso-images-without-burning-them.html



Add a comment Leave a comment on this blog post.

There are no comments on this post

Click to view vmroyale's profile Member since: Jun 15, 2007

Findings from the VMTN forums and the field...

View vmroyale's profile

Communities