Tuesday, March 6, 2012

How to make a vmdk disk that points to a dd image.

This procedure does not require any conversion, and thus, no waiting time or extra disk space.

It was tested in VirtualBox, but it's expected to work in VMWare as well. And it works both on Windows and Linux hosts.

First, check how many sectors your dd image have. It's the image size in bytes divided by 512.

$ ls imagem.dd  -l
-rw-r--r-- 1 root root 1500301910016 2012-02-17 11:36 imagem.dd
1500301910016/512 is 2930277168, so 2930277168 is what we want

Next, create a file with the following contents and save it with a '.vmdk' extension (edit the file to use your image path and size):

# Disk Descriptor File

# Extent description

#DDB - Disk Data Base
ddb.adapterType = "ide"
ddb.virtualHWVersion = "3"
In this example, we would change the line after Extend description to:
RW 2930277168 FLAT "imagem.dd" 0

You can use relative or absolute paths.

After including your new VMDK in a virtual machine, you can take a snapshot before turning it on, to keep the image file intact. If your image file is read-only, the snapshot is required in order to make the vmdk work, otherwise there will be access errors and the virtual machine will not start. Your new vmdk file, on the other hand, always has to be writable.

OBS: two common errors when trying to virtualize an otherwise not-virtual Windows are:

  • Blue Screen of Death, with error 0x7B. Caused by required disk device drivers not been loaded during boot. You can try to change how your virtual machine connects your drive (IDE PIIX4,PIIX3,ICH6,SATA). If that doesn't help, the solution may require a registry edit, with a different procedure from XP to Vista/7.
  • Black screen followed by repeating reboot. Are you sure you're not trying to virtualize a 64bit OS guest on a 32bit OS host?

1 comment: