(Part-2) -
See here for VDDK Overview and How to Download VMware Disk Mount
See here for VMware Disk Mount (vmware-mount) - Intro and Windows Usage
In the last post, we looked at installing and using the VDDK in Windows. It was a fairly easy process and being somewhat savoy in Linux, I thought it would be the same. For the most part it was, but I did struggle a bit with some syntax and the Linux environment itself needed to be prepped a bit more.
Prerequisites
Supported/Tested Linux Operating Systems
The first thing to look at is the Virtual Disk API Programing Guide to verify what distribution and versions are supported with the VDDK Toolkit. Both 32 and 64-bit editions are supported. While not every flavor of Linux is represented, for the most part the newer editions should work. I’ve tried it with Fedora Core 8, SUSE Enterprise Linux for Desktops 11 SP1 and Ubuntu 10 and all worked fine for me, just don’t expect to get support if you are not running a tested/supported version.
FUSE
The FUSE package may be required to run the VDDK tools in Linux. FUSE (or Filesystem in USErspace) allows a non-root user to create and access their own file systems. Fuse is a loadble module that acts as a bridge between the user space and the actual kernel mount interface. The module was implemented in kernel version 2.6.14 and higher, meaning if you have this version or higher of the kernel, you already have FUSE as part of the OS.
To check if you have FUSE installed, try this command on kernel versions lover than 2.6.14:
If your kernel version is prior to v2.6.14, you will need to load the FUSE package, if it’s not already there. I won’t go into the details on the installation process of FUSE, but you can obtain and install the package from many different sources.
From SourceForge:
Or if your version of Linux supports APT:
sudo apt-get install fuse-utils
Installing the VDDK Toolset
After you have downloaded the tarball from VMware’s site, you will need to unpack it. This can also be done from the GUI, but the actual installation process will have to be run at the command line.
Once the command is run, as long as there are no errors, you’ll be dropped back to the command prompt. If you do a directory listing (ls), you will see the extracted folder, vmware-vix-disklib-distrib.
Change to that directory (cd vmware-vix-disklib-distrib). You can also use the <TAB> key once you start typing the first few letters of the directory name.
Once you are in the directory, do another listing and find the vmware-install.pl file. To make sure we can execute the installer, we’ll do a long listing (ll). On some systems, if the alias isn’t setup correctly, you may need to use the ls –l command.
We can see with the ‘x’ in all positions, this script is executable, so let’s run it. Make sure to use the ‘./’ in front of the name, otherwise the command won’t execute. You may or may not have to use sudo, depending on who you are logged in as. You aren’t logged in as root, are you???
Enter the password (if needed) and then press ‘Enter’ to display the License Agreement.
Press the Spacebar a few times (after you carefully read through the document) and then type ‘yes’ and then ‘Enter’, if you accept the terms…
You will be asked where you want to install the API Toolset, unless you feel otherwise, take the default of the ‘/usr’ directory by either typing out ‘/usr’ or just pressing the ‘Enter’ key.
If all goes well, you should see the following. Note the uninstallation script, if you need it in the future.
LD_LIBRARY_PATH
This was where I struggled. It was one of those cases of I knew this was the file I needed to edit and include a path to the shared object file for VDDK, but it was the syntax that had me confused. As always, the Internet was a huge help in giving me multiple ways of producing the same results.
In pretty much all cases, you’ll need to add the installed libraries to the search path. Otherwise, you will get a message saying VixDiskLib: Failed to load libvixDiskLibVim.so. After sorting through the various ways and options I had, I found the way easiest for me and in no time, I had vmware-diskmount working.
First, edit the ld.so.conf file located in the /etc directory using vi or any other text editor and add the following to the bottom:
/usr/lib/vmware-vix-disklib/lib32 (for 64-bit versions, just change the 32 to a 64).
Below is an example of what the /etc/ld.so.conf file looks like under SLED 11 (32-bit).
In order for the change to take effect, you’ll need to run the ldconfig command as root or sudo.
Example of connecting to an ESXi host
Now that we have the VDDK Toolset installed, let’s try running it against an ESXi host. Conceptually, the command is about the same as the Windows version:
vmware-mount /path to vmdk {partition #} /mount point
Just like in Windows, the default partition number is 1, so if you don’t specify it, the command will assume the first partition of the vmdk file.
If you took the default installation path of ‘/usr’, the vmware-mount command will be in the /usr/bin directory and in the systems search path for commands, so you won’t need to change to the directory where the command is. If you didn’t take the default path for installation, you’ll need to change to that directory or modify the search path.
One difference between the Windows and Linux versions is how you specify the password to connect to the ESX/ESXi host or vCenter Server. The password is placed in a text file and the path to it is given when the command is executed. This way it can be included in scripts without the password being seen as the command is executed. Here’s a simple way to create a text file with the password in it. First we create the file with the ‘touch’ command. Then we set the permissions on the file, your level may vary, since I’m in a test environment, 777 will wok just fine. Finally, we ‘echo’ the password to the file. We can check to make sure it was written using the cat command.
One last thing needs to be done before we can mount vmdk files. Since Linux uses mount points instead of drive letters as in Windows, we need a mount point to place the vmdk in. It’s a good practice to use the ‘/mnt’ directory so we’ll create a directory under that called vmdk.
Now that the prep work is done, we can run the actual command. One quick note worth mentioning again, more than likely, you will have to be logged in as root or use the sudo command for vmware-diskmount to work.
Just like the Windows version of the command, you will need to know the inventory and datastore path to the virtual machine. When connecting to an ESX/ESXi server, this is easy because it is always the same. For the datastore path, the quickest way to find this information is to use the vSphere Client and open the properties of the virtual machine, select the Hard disk and you'll find the datastore path listed under 'Disk File'.
The overall syntax of the command is:
vmware-mount –v ha-datacenter/vm/{virtual machine inventory path} –h {hostname} –u {username} –F {path to password file} “[{datastore name] vm name/vmdk file to mount}” {mount point}
Just like the Windows version of the command, it is a lot to digest (refer back to the Windows explanation for more details). To mount the VMware Capacity IQ VM’s Hard disk 1, we would type the following:
vmware-mount –v ha-datacenter/vm/VMware\ Capacity\ IQ –h 192.168.1.111 –u root –F /root/vddk.pwd “[ds3] VMware Capacity IQ/VMware Capacity IQ.vmdk” /mnt/vmdk
Two things to note in the above command. The first is if your VM’s inventory path has a space in it, you can either add a ‘\’ before the space or just use quotes. For example, “ha-datacenter/vm/VMware Capacity IQ” would work the same in the above command. The second point is to always remember your quotes around the datastore path as they are not optional. It seems I'm always forgetting the end quotes. You'll know this when you're dropped at a '>' prompt waiting for input. Ctrl+C will be your friend, too.
Here is the executed command and the directory listing of the mounted vmdk:
Example of connecting through a vCenter Server
Now let’s take a look at connecting through a vCenter Server. Not a whole lot different than the ESX/ESXi version of the command, but we do need to be concerned with the inventory path of the virtual machine. If we look at the VMware Capacity IQ virtual machine again, the inventory path is DC/VMware Capacity IQ.
So the command would look like this:
vmware-mount –v “DC/vm/VMware Capacity IQ” – h vcenter –u administrator –F /root/vddk.pwd “[ds3] VMware Capacity IQ/VMware Capacity IQ.vmdk” /mnt/vmdk
Common mistakes made (by me) here are not changing the user name from root to administrator and forgetting to update the password file if it is different than the ESX/ESXi password.
To add a bit more complexity, let’s try mounting a VM that isn’t right off the root structure of the Datacenter.
We will mount the win7x64-2 virtual machine in the DC/Windows 7 Desktops/Win7x64 inventory path. Remember to include the ‘/vm/’ right after the Datacenter name and it’s probably easier to use quotes around the whole thing.
The command would look like this:
vmware-mount -v "DC/vm/Windows 7 Desktops/Win7x64/win7x64-2" -h vcenter -u administrator -F /root/vddk.pwd "[ds3] win7x64-2/win7x64-21-internal.vmdk" /mnt/vmdk
Oops, don’t forget you can only mount a VM’s vmdk file if it is powered down. Also, you will not be able to power the machine back on until the vmdk file is unmounted and released back to vCenter or ESX/ESXi.
That’s better and I have mail. Yea!
Example of Mounting a VMware Workstation VMDK
Finally, let’s take a look at mounting a drive on a Linux host running VMware Workstation. First, if you have VMware Workstation on a Linux host, you already have vmware-mount installed. However, it is a limited version and only allows you to mount vmdk files locally, not through ESXi/ESX or a vCenter Server.
To run the vmware-mount tool on a local vmdk file, just tell it where the vmdk file is and where you want to mount it.
vmware-mount /home/drollins/vmware/Ubuntu/Ubuntu.vmdk /mnt/vmdk
Let see what happens when we try to upgrade to the full version of the VDDK toolkit. It is pretty much the same installation process, only you are asked if you would like to over-write /usr/bin/vmware-mount and /usr/bin/vmware-diskmanager. Take the default of yes and it will install properly.
You will still need to add the ‘/usr/lib/vmware-vix-disklib/lib32 (or64) to your ld.so.conf file and run ldconfig as root (or sudo) to complete the installation.
Listing and Unmounting Drives
The last thing we’ll take a look at is listing the mounted vmdk files and unmounting them.
To list a drive, just run the vmware-mount command with the ‘L’ option
vmware-mount -L
Lastly, I can’t stress how important it is to unmount the drive when you are done working with it. Use the “d” option and the mount point to cleanly unmounts a vmdk file.
vmware-mount –d /mnt/vmdk
Conclusion
That’s a look at the Linux version of the VMware Disk Mount Tool, vmware-mount. One thing I did learn that contradicts my original post is the ability to mount a Windows volume in Linux. I was able to do this even though the User Guide said it was not possible. It may be a case of support rather than technically feasible. It makes me wonder what a Linux vmdk mounted on a Windows host would look like. I should really give that a try.
I hoped you enjoyed this post and please post any comments or questions you have. It was fun to write and had me searching for some Linux skills I’d tucked away.
I may skip the troubleshooting post and move right on to the vmware-vdiskmanager on the Windows and Linux platforms. I think the troubleshooting piece may be a work in progress and will probably end up being a combination of diskmount and diskmanager.