From the Linux and Unix Users Group at Virginia Teck Wiki
Jump to: navigation, search

VMware is a proprietary virtualization brand. Their popularity is probably due to their early start in the field of virtualization and cross-platform host capabilities. VirtualBox and QEMU are free software alternatives to VMware.

Converting to VDI

Follow the instructions in the VirtualBox article to convert a flat (raw) image into VirtualBox's virtual desktop image format.

Cracking Open VMDK Images with DD

The dd utility can be used to crack open a -flat.vmdk file.

Offset and Length Information

To get the offset and length of each partition, run the file command it.

$ file Red\ Hat\ Enterprise\ Linux\ 4-flat.vmdk Red Hat Enterprise Linux 4-flat.vmdk: x86 boot sector; GRand Unified Bootloader, stage1 version 0x3, boot drive 0x80, 1st sector stage2 0xac03f, GRUB version 0.94; partition 1: ID=0x83, active, starthead 1, startsector 63, 5526297 sectors; partition 2: ID=0x82, starthead 0, startsector 5526360, 530145 sectors; partition 3: ID=0x83, starthead 0, startsector 6056505, 224910 sectors, code offset 0x48

If you're dealing with Linux partitions, look for IDs of 0x83. 0x82 is Linux swap. Partition one generally begins at offset 63, but in this example, you can see a second partition at offset 6056505. The sector sizes are in multiples of 512 bytes.

Dumping the Partitions

The key components of the dd command are the skip and count settings. They are, respectively, the offset and length of the data to copy, copied from the information given by the file command.

The following will dump the root partition.

$ dd if=Red\ Hat\ Enterprise\ Linux\ 4-flat.vmdk of=~/centosroot.img skip=63 count=5526297

The other partition in this example was the /home partition. Since it was at the end of the file, the count variable was left unspecified. The partition was extracted with the following line.

$ dd if=Red\ Hat\ Enterprise\ Linux\ 4-flat.vmdk of=~/centoshome.img skip=6056505 bs=512

Mounting the Partitions

Mounting images on Linux is relatively straightforward.

# mount -o loop /home/user/centosroot.img /mnt/mymountpoint
# mount -o loop /home/user/centoshome.img /mnt/mymountpoint/home

You may need specify the filesystem type, i.e. -t ext3. Also, if you're having trouble mounting, it might be possible that you got the parameters wrong or potentially just got a bad copy. Try again to see if that's the case.