Mounting LVM vmware disks

I’ve spent a couple of weeks trying to recover some data from an old vmware machine. I didn’t want to install vmware on my new OS, so I looked into the vmware-mount program. The documentation refers to vmware-mount.pl, but I couldn’t find that file at first. It looks like since VMWare 2.0, vmware-mount.pl and vmware-loop have been replaced by a single vmware-mount binary, which behaves slightly differently.

I initially had problems with vmware-mount from VMware-server-2.0.0-122956.i386.tar.gz. I was getting this error:

vmware-mount: error while loading shared libraries: libfuse.so.2: cannot open shared object file: No such file or directory

I saw other reports of the same error, but no solution. I was using vmware-mount from a 32bit build on a 64bit OS, so instead I tried the vmware-mount from VMware-server-2.0.1-156745.x86_64.tar.gz. Then I got an error along the lines of:

SSLLoadSharedLibrary: Failed to load library libcrypto.so.0.9.8:/usr/local/bin/libdir/lib/libcrypto.so.0.9.8/libcrypto.so.0.9.8: cannot open shared object file: No such file or directory
Core dump limit is 0 KB.
Child process 26541 failed to dump core (status 0x6).

VMware Server Error:
VMware Server unrecoverable error: (app)
SSLLoadSharedLibrary: Failed to load library libcrypto.so.0.9.8:/usr/local/bin/libdir/lib/libcrypto.so.0.9.8/libcrypto.so.0.9.8: cannot open shared object file: No such file or directory
Please request support.
To collect data to submit to VMware support, select Help > About and click “Collect Support Data”. You can also run the “vm-support” script in the Workstation folder directly.
We will respond on the basis of your support entitlement.

Press “Enter” to continue…

I read this. With a little guesswork this command seemed to do the trick:

sudo ln -s /lib /usr/lib/vmware

Now vmware-mount would list my partitions. First major breakthrough.

Mounting suspended disks

It complained that my virtual machine was in a suspended state, and so it wasn’t safe to mount the disk. I found I could bypass this problem by moving all the vmdk files into a separate directory. Then running vmware-mount in that directory. It effectively ignored all the vmware machine files, and used only the hard disk files.

mkdir vmdks
sudo mv *.vmdk vmdks/
cd vmdks

Now I could mount my /boot partition within the VM, but not the second partition because it was was an LVM container. A whole new problem to solve.

Mounting LVM volumes with vmware-mount

I stumbled on my buddy John’s post. That and this helped me figure out what was required.

My first step was to mount the disk flat, using a command like:

sudo vmware-mount -f pathToVMDK.vmdk /path/to/mount

That worked, sort of. With fdisk -l /path/to/mount I could see the two partitions. But sudo vgscan couldn’t find the lvm partition. I tried sudo losetup /dev/loop0 /path/to/mount/flat, but that didn’t work either.

I figured I needed vmware-loop to mount the partition as a loop device. I searched the VMware-server-2.0.1-156745.x86_64.tar.gz file for vmware-loop, but it was nowhere to be found. That’s when I started investigating with previous versions of VMWare. It looks like the 1.0.* releases included vmware-mount.pl and vmware-loop while the 2.0.* releases only include the new vmware-mount binary.

I downloaded VMware-server-1.0.9-156507.tar.gz. In that tar file I extracted bin/vmware-mount.pl and bin/vmware-loop. These were the files I needed. I skipped vmware-mount and went straight to vmware-loop. I was able to mount the second partition directly onto a network block device (/dev/dbd0) with:

sudo vmware-loop pathToVMDK.vmdk 2 /dev/nbd0

Now I could use the lvm commands to activate and mount my lvm. Note that vmware-loop is running the whole time, so I left it in a separate terminal. I closed it with CTRL-C at the very end of the process.

sudo vgscan
sudo vgchange -ay VolGroup00
sudo mount /dev/VolGroup00/LogVol00 /mnt/

Finally, I was able to copy the files from my virtual hard drive. I made a full backup with tar and then grabbed some other specific files and unmounted the whole thing.

sudo umount /mnt/
sudo vgchange -an VolGroup00

If you’re struggling with vmware-mount and  LVM or suspended disks, I hope this helps. Comments welcome.

8 thoughts on “Mounting LVM vmware disks”

  1. Hi Callum,
    Really this is an excellent tutorial, and it helped me with my work. In addition, I want to tell you something to complete your “Mounting LVM volumes with vmware-mount” section. I have just try to mount a lvm volume with vmware-server 2.0 and it looked impossible until I copied vmware-loop from the vmware-server 1 installation to the vmware-server 2.0 one. And it worked successfully. Only, one thing, this was performed on two similar computers (Red Hat family OS of 64 bits).
    Thanks for the tutorial
    Regards
    Miguel Angel Diaz Corchero.

  2. Thanks alot! Worked perfectly.

    I found on my box (ubuntu 12.04) I had to install nbd-client before getting the /dev/nbdX devices

  3. a lot easier is to mount the vmdk as flat file and use losetup and kpartx afterwards.

Leave a Reply

Your email address will not be published. Required fields are marked *