Contents

Accessing a virtual hard disk outside of Workstation

The easiest way to read or write files on a hard disk of a virtual machine is to start VMware Workstation, boot the virtual machine, then use a floppy disk drive or the network file system protocols (NFS, Windows File Sharing, etc.) to exchange data via your physical machine.

Sometimes, the amount of data you want to transfer is too large for a floppy, you don't have the appropriate driver to run the network inside the virtual machine, or you cannot run a virtual machine because your license has expired. For these reasons, you need a way to access the hard disk of the virtual machine directly from the host operating system, without having to run Workstation.

When the hard disk of the virtual machine is a raw device or a raw disk (see Installing an Operating System onto a Raw Partition from a Virtual Machine or Configuring Dual/Multiboot Systems to Run With Workstation), the problem is already solved: you can access the partition the same way you would access any other partition by first mounting it to a directory, then browsing the directory.

But when the hard disk of the virtual machine is a virtual disk (which is just a file when seen from your host operating system), you need the help of a program called vmware-mount.pl. This document describes how to use this program.

What is vmware-mount?

vmware-mount is a program that runs on the host operating system. It makes a virtual disk file appear as a hard disk to the operating system.

vmware-mount requires a Linux kernel version 2.1.101 or higher (including the stable 2.2.x series) because this version introduced the concept of network block devices, which is heavily used by vmware-mount. vmware-mount is available as an add-on to Workstation: for both evaluation users and licensed customers.

Installing vmware-mount

To install vmware-mount:

  1. Download the file from this URL: http://www.vmware.com/download/downloadaddons.html
  2. Open a terminal window and login as root:
    su
  3. Uncompress the installation files using this command:
    tar zxvf vmware-mount-addonXXX.tar.gz
  4. Change to the installation directory using this command:
    cd vmware-mount-addonXXX
  5. Run the installation with this command:
    ./addon-install.pl

Using vmware-mount.pl

Assuming that your virtual hard disk file is ~/vmware/vhd.vmdk, follow these steps to read its contents using vmware-mount.pl:

  1. Open a terminal window and login as root:
    su
  2. Determine the partition of the virtual hard disk to export. To do so, issue the following command to print the partition table of the virtual hard disk:
    vmware-mount.pl -p ~/vmware/vhd.vmdk

    This command returns output similar to the following:

    --------------------------------------------
    Workstation (for Linux)
    - Virtual Hard Disk Mounter
    Copyright (C) 1999 VMware, Inc.
    --------------------------------------------

    Nr Start Size Id System

    -- -------- --------- -- -------------------
    1 63 4092417 C Win95 FAT32 (LBA)

  3. Locate the partition number you want to export from the first column of the output. For example, assume you want to export partition number 1.
  4. Mount the disk partition on a directory. Assuming that you want to mount your partition on the directory /mnt/vhd, issue the following command:
    vmware-mount.pl ~/vmware/vhd.vmdk 1 /mnt/vhd

    This command results in output similar to the following:

    --------------------------------------------
    Workstation (for Linux)
    - Virtual Hard Disk Mounter
    Copyright (C) 1999 VMware, Inc.
    --------------------------------------------

    Network Block Device driver detected.
    Trying to map the partition to the /dev/nb0 Network
    Block Device.. Success.

  5. You can now browse your virtual disk partition from the /mnt/vhd directory on your host operating system.
  6. When finished browsing the virtual disk contents, hit CTRL-C in the terminal window.

Notes for Advanced Users

By using the vmware-loop binary directly, you can map the partition of a virtual hard disk to any network block device (which you can then mount). This mapping can be done in read-only mode if you use the -r command line option of vmware-loop.

Currently, a virtual hard disk cannot be accessed in read/write mode by more than one application at a time (Workstation or vmware-mount for example).

Troubleshooting

The following table describes issues and their potential resolutions.

Issue

Resolution

vmware-mount claims that the Linux kernel is too out of date.

You need to upgrade to a newer kernel. The easiest way is to upgrade your Linux distribution (installing the package corresponding to the most recent kernel). If you are able, you can also grab the latest kernel sources and compile your own kernel. Take a kernel version 2.1.101 or higher and set the CONFIG_BLK_DEV_NBD option (which you can find under Block devices > Network block device support) to "y" or "m" If you don't want to mess with kmod (the kernel module loader formerly known as kerneld), we recommend to use "y".

Once you have rebooted your new kernel, rerun background:red;vmware-mount.pl.

vmware-mount keeps saying that it cannot open my virtual hard disk because it is locked by other virtual machines. What does that mean?

vmware-mount.pl has detected that several applications (Workstation or other applications are trying to access your virtual disk at the same time. First, be sure that this is not true.

If you are certain that two processes (including processes running on a remote machine) are not trying to simultaneously access your virtual hard disk, then it is probably a stale lock that has not been cleaned up as it should have been. You can remove it safely.

If you experience further problems, please file an incident report at http://www.vmware.com/fileincident. Be sure to select the "vmware-mount" category, and to include the output of your session with your report.

Known Problems

Under severe load, your host operating system may hang (lock solid) if you are writing to a virtual disk using vmware-mount.pl. VMware is aware of the problem and is working on a solution.

To avoid this problem, either use the read-only mode or try to limit the throughput of data you write to your virtual disk.

Back to top

© 2001 VMware, Inc. All rights reserved.