Mounting VMDK disk image

Without Me It Just Aweso picture Without Me It Just Aweso · Mar 11, 2014 · Viewed 73.1k times · Source

I have a single vmware disk image file with vmdk extension

I am trying to mount this and explore all of the partitions (including hidden ones).

I've tried to follow several guides, such as : http://forums.opensuse.org/showthread.php/469942-mounting-virtual-box-machine-images-host

I'm able to mount the image using vdfuse

vdfuse -w -f windows.vmdk /mnt/

After this I can see one partition and an entire disk exposed

# ll /mnt/
total 41942016
-r-------- 1 te users 21474836480 Feb 28 14:16 EntireDisk
-r-------- 1 te users  1569718272 Feb 28 14:16 Partition1

Continuing with the guide I try to mount either EntireDisk or Partition1 using

mount -o loop,ro /mnt/Partition1 mnt2/

But that gives me the error 'mount: you must specify a filesystem type'

In trying to find the correct type I tried

dd if=/mnt/EntireDisk | file -
which outputs a ton of information but of note is:
/dev/stdin: x86 boot sector; partition 1: ....... FATs ....

So i tired to mount as a vfat but that gave me

mount: wrong fs type, bad option, bad superblock ...etc

What am I doing wrong?

Answer

Thomas picture Thomas · May 12, 2015

For newer Linux systems, you can use guestmount to mount the third partition within a VMDK image:

guestmount -a xyz.vmdk -m /dev/sda3 --ro /mnt/vmdk

Alternatively, to autodetect and mount an image (less reliable), you can try:

guestmount -a xyz.vmdk -i --ro /mnt/vmdk

Do note that the flag --ro simply mounts the image as read-only; to mount the image as read-write, just replace it with the flag --rw.

Installation

guestmount is contained in following packages per distro:

  • Ubuntu: libguestfs-tools
  • OpenSuse: guestfs-tools
  • CentOS / Fedora: libguestfs-tools-c

Troubleshooting

error: could not create appliance through libvirt

$ guestmount -a file.vmdk -i --ro /mnt/guest
libguestfs: error: could not create appliance through libvirt.

Try running qemu directly without libvirt using this environment variable:
export LIBGUESTFS_BACKEND=direct

Original error from libvirt: Cannot access backing file '/path/to/file.vmdk' of storage file '/tmp/libguestfssF6WKX/overlay1.qcow2' (as uid:107, gid:107): Permission denied [code=38 int1=13]

Solution: use LIBGUESTFS_BACKEND=direct, as suggested:

LIBGUESTFS_BACKEND=direct guestmount -a file.vmdk -i --ro /mnt/guest

fusermount: user has no write access to mountpoint

LIBGUESTFS_BACKEND=direct guestmount -a file.vmdk -i --ro /mnt/guest/
fusermount: user has no write access to mountpoint /mnt/guest
libguestfs: error: fuse_mount failed: /mnt/guest/, see error messages above

Solution: use sudo, or change file permissions on the mountpoint