Mount a VMware virtual disk (.vmdk) file on a Linux box
5 March, 2021 by
Mount a VMware virtual disk (.vmdk) file on a Linux box
Administrator

 

$ sudo mount vmware-server-flat.vmdk /tmp/test/ -o ro,loop=/dev/loop1,offset=32768 -t ntfs

Mount a VMware virtual disk (.vmdk) file on a Linux box

Assumes XP/2000/2003. For Server 2008+ try offset=105,906,176 You can find this number in the System Information utility under Partition Starting Offset. UEFI based boxes you want partition 2 since the first is just the boot files (and FAT). This works with (storage side) snapshots which is handy for single file restores on NFS mounted VMware systems

$ kpartx -av <image-flat.vmdk>; mount -o /dev/mapper/loop0p1 /mnt/vmdk

This does not require you to know the partition offset, kpartx will find all partitions in the image and create loopback devices for them automatically. This works for all types of images (dd of hard drives, img, etc) not just vmkd. You can also activate LVM volumes in the image by running

vgchange -a yand then you can mount the LV inside the image.

To unmount the image, umount the partition/LV, deactivate the VG for the image

vgchange -a n <volume_group>then run

kpartx -dv <image-flad.vmdk>to remove the partition mappings.

 

 

http://www.commandlinefu.com/commands/view/12554/mount-a-vmware-virtual-disk-.vmdk-file-on-a-linux-box