Mounting VMDK disk image

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

Leave a Comment

tech