VMDK is a virtual disk file from VMWare, reading without any "special" software is rather useful specially because I didn't want to install VMWare software
It's possible that this works with vhd and vhdx but I didn't test it... If someone does test it let me know
The steps are rather easy
-
Get Loopback devices
You first need to see what Loopback devices are available on your system, in my case loop30 is usually available so I use that
To view which loopback devices are in use just type
sudo fdisk -l | grep /dev/loop
on your terminal ordf -h | grep /dev/loop
-
Create a mount point
Just create a mount point, as I usually only work with one VMDK at the time I created the mount point
vmdk
so the command should besudo mkdir /mnt/vmdk
-
Create the loopback device
In my case the I have loopback devices from 0 to 21 (loop0 - loop21) so I will use
loop30
and associalte with the vmdk file. To note that it must be the diskname-flat.vdmk file where diskname is your disk name.To create the loopback device type
sudo losetup /dev/loop30 /mnt/storage/vm-flat.vmdk
where/mnt/storage/vm-flat.vmdk
is the path to your vmdk file. -
Set the offset
Instead of performing calculations just get the offset using
parted
for that follow the following steps-
sudo parted /dev/loop30
-
unit
-
B
-
print
-
quit
-
Get the offset from the output After the command
print
you should have something like thisModel: Loopback device (loopback) Disk /dev/loop30: 118111600640B Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1048576B 537919487B 536870912B fat32 boot, esp 2 537919488B 118110552063B 117572632576B ext4
In my case I want to access the second partition so I grab the start value for that partition which is
537919488
remember to remove theB
at the end of the number -
Finally create a new loopback device for that partition
sudo losetup -o 537919488 /dev/loop31 /dev/loop30
whereloop30
is the loopback device to which the VMDK is associated andloop31
is the new loopback dive to which the partition will be associated
-
-
Mount a new loopback device on the new mount point
Mount a new loopback device, I'll be using loop31
which is associated with the partition and /mnt/vmdk
as a mount point.
So to perform the mount type sudo mount /dev/loop31 /mnt/vmdk
And you can now access to your VMDK file
After usage you should perform a unmount and loopback cleanup these steps are even more easy.
sudo umount /mnt/vmdk
where/mnt/vmdk
is your mount point. Ensure that your system isn't using anything on this mount pointsudo losetup -d /dev/loop31
sudo losetup -d /dev/loop30
On the steps 2 and 3 ensure that you remove the partition loopback first and then the disk loopback. Remember to use your loopXX devices that you used during the mount process.