EDIT: I noticed several serious errors in the earlier version of this, which I have now fixed (I hope). Mea culpa.Any version of
dd(1) (including
WinDD or the Cygwin and MinGW ports) should work, pretty much the same way you would for a floppy image, except that sector 0 would need to be the
MBR, and the boot block would be in whichever sector you define in the MBR's
Partition Table as the start of the partition to use (probably sector 1, for a simple single-partition layout).
Note that if you have VirtualBox set to use UEFI booting (which it usually will if the underlying platform does, I think - corrections on this are welcome), you will want to use a
GPT rather than a legacy partition table.
To actually create the image with a command-line
dd(1), you might use something like:
Code:
dd if=/dev/zero of="hdd.img" bs=512 count=<desired-img-size>
dd if="myMBR.bin" of="hdd.img" bs=512 count=1 conv=notrunc
dd if="myBoot.bin" of="hdd.img" bs=512 seek=1 count=1 conv=notrunc
dd if="myKernel.bin" of="hdd.img" bs=512 count=<kernel-size> seek=2 conv=notrunc
Keep in mind that
bs,
ibs and
obs are in bytes, while
seek,
skip and
count are in blocks of the
ibs or
obs sizes. Technically, both
bs defaults to 512, and can be skipped here, but you probably want to have it explicitly despite this.
You can use suffixes to indicate the sizes as well. So, for a 100M image and a 1M kernel, you would have the MBR
count as 200K and the kernel count as 2K.
Note also that
/dev/zero is a part of Unixoid OSes like Linux; I am not sure offhand what to use in Windows instead. I have seen that some
dd implementations for Windows mock up
/dev/{null|zero|random|urandom} for cases like this, but I don't know if all of them do.