User Tools

Site Tools


info:vmdk

General Info

The VMDK format is documented in vmdk_specs.pdf.

All VMDK files have some plaintext with metadata. With flat images, this is a separate file from the raw disk data; with sparse images, it's at the beginning of the VMDK file. This can tell you what type of image it is (there are a few others, but these are the main variants):

  • Workstation/non-ESX types
    • monolithicSparse
    • monolithicFlat
    • twoGbMaxExtentSparse
    • twoGbMaxExtentFlat
  • ESX
    • vmfs (flat)
    • vmfsSparse

Commands

These are installed with VMware Workstation; I'm not sure about other products.

  • vmware-vdiskmanager - convert (flat and sparse, ESX and non-ESX), defragment, resize (expand only)
  • vmware-mount - mounts partitions (not actually required for flat VMDK images, more of a convenience; see mounting section)

Flat VMDK files, which are just raw disk images (the actual data part, suffixed with -flat), can be inspected by parted: run parted <file> then type print to print the partitions (or run parted <file> print). This also appears to work if there are no partitions (just a formatted raw block device).

Mounting (Linux)

vmware-mount can be used to mount partitions in a VMDK file.

Flat VMDK files are just raw images of the disk, so they can be mounted directly; however, you have to find the first sector of the partition (if the disk has partitions). For example, see Mount Flat VMWare Disk Images Under Linux. It looks like the kpartx program can be used to automatically set up loop devices for each partition, but I couldn't get the device to mount the one time I tried it. If you can find the right offset (try fdisk -l -u <file>, multiply start by 512, or the number of bytes per sector; or parted foobar-flat.vmdk unit B print, which gives you bytes), you can skip the losetup described in the previously-mentioned article, because mount will do it for you, given the right option:

mount -o loop,offset=1048576 foobar-flat.vmdk /mnt

Images Without a Partition Table

If the disk image doesn't have a partition table (i.e. the raw block device is formatted with whatever filesystem; this is useful to be able to increase the size while the virtual machine is online), vmware-mount won't be able to mount it. However, if it's a flat image, you can just mount it directly:

mount -o loop foobar-flat.vmdk /mnt

If you have a sparse image, vmware-mount can be used with the -f option to "mount a flat representation of the disk at 'mountPoint/flat.'" Then you can mount it as if you had a flat VMDK file:

vmware-mount -f foobar.vmdk mountpoint
mount -o loop mountpoint/flat /mnt
info/vmdk.txt · Last modified: 2011-07-21 23:06 by sam