Creating a Hard Disk Image (2)


This method uses firadisk, Windows Disk Management console and the command-line tool DevCon - download the self extracting archive and unpack the contents to C:\Devcon\ - two versions are included, use C:\Devcon\i386\devcon.exe in 32-bit Windows.

We will be using the formular covered here, however a further calculation is required as the the image size needs to be calculated in bytes. Total Bytes can be worked out by multiplying Total Sectors (the value calculated in step 3) by 512. To create a 2 GB (2048 MB) disk image -

  1. 2048 divided by 7.84423828125 = 261.0833488951136
  2. Cylinders = 261.0833488951136 rounded up/down to the nearest whole number = 261
  3. Total Sectors = 261 multiplied by 16065 = 4192965
  4. Total Bytes = 4192965 multiplied by 512 = 2146798080

Open a command prompt in the C:\Devcon\i386\ directory - Start > Programs > Accessories > Command Prompt, then enter CD C:\Devcon\i386 [enter]

  1. Use the following syntax to create a disk image (where Total_Bytes parameter is value calculated in step 3) -
    reg add HKLM\SYSTEM\CurrentControlSet\Control\Firadisk /v StartOptions /t REG_SZ /d "disk,vmem=my_image.ima,size=Total_Bytes" [enter]
    Using the figures calculated in the 2 GB example, use the following command to create disk image C:\my_disk.ima -
    reg add HKLM\SYSTEM\CurrentControlSet\Control\Firadisk /v StartOptions /t REG_SZ /d "disk,vmem=C:\my_disk.ima,size=2146798080" [enter]
  2. The previous step will create the image file when the firadisk driver is restarted (e.g. on reboot). To force the driver to restart use the command -
    devcon disable root\firadisk [enter]
    followed by -
    devcon enable root\firadisk [enter]
  3. The registry entry created earlier will attempt to mount/create the disk image whenever firadisk is restarted. Delete the entry by using the following command -
    reg delete HKLM\SYSTEM\CurrentControlSet\Control\Firadisk /v StartOptions
  4. Open Windows Disk Management - Start > Run > diskmgmt.msc [enter]
  5. Disk Management will start the Initialize and Convert Disk Wizard (if the wizard does not start automatically then Right-click on the disk in the bottom pane of the Disk Management console > select Initialize Disk > click on the Ok button and skip the next two steps) - on the welcome screen click on the Next > button to continue.
  6. When prompted to Select Disks to Initialize - select the available disk (in my case Disk 1, however this will depend on the number of disks attached to your system) and click on the Next > button to continue.
  7. When prompted to Select Disks to Convert - ensure the available disk is unselected and click on the Next > button to continue.
  8. To partition the disk image and create a MBR, Right-click on the disk in the disk management window and select New Partition..., then follow the steps on screen and choose the required settings (size, format, etc).
  9. Mark the partition as active by right-clicking on the partition in the disk management window and select Mark Partition as Active.
  10. Disable firadisk to unmount the disk image using command -
    devcon disable root\firadisk

Steps 1-4 can be automated using the following batch file, which should be copied to C:\Devcon\i386\ (highlight the text below and hold [ctrl]+[c] to copy and [ctrl]+[v] to paste into notepad, then save with a .cmd file extention) -

If using the above batch file, edit the following settings -