James Harris
unread,Apr 14, 2012, 4:34:15 AM4/14/12You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Having spent some time in the past week or so experimenting with hard
disk booting and what to put in a hard disk MBR I ended up with a
quite useful test setup. In case it is of use to others the details of
the test environment are below.
Ultimately, it allowed each new version of the code to be built and
tested with just a few keystrokes. That's especially useful for
debugging when writing for a bare environment.
A typical set of steps to test a new version of the source code would
be two commands at a command line and then two key commands to
Virtualbox, nothing more!
assemble
copy
start the guest
stop the guest
I'll describe the components I used but you could substitute your own
favourites.
First, to write the MBR code I used Nasm under Windows storing files
on a Linux server. Builds were with a command such as
nasm -f bin mbr1.nasm -o mbr1.bin -l mbr1.list
For the VM environment I used Oracle Virtualbox. It's the first time I
have tried it and I found it to be excellent in terms of ease of use.
I used it to set up HD images of the .vdi form. They have a 8192-byte
header so that the HD boot sector begins at offset 8192 or 0x2000.
While I ran Virtualbox under Windows the .vdi images were placed on
the Linux server along with the nasm source and object files. It is
important that the .vdi images are of fixed size, not variable, to
permit them to be manipulated outside of Virtualbox more easily so
bear this in mind when creating them. Small disk images should be fine
for testing. I made mine 32Mbytes. The rest of the virtual machine was
similarly very small and I limited its CPU usage. All these settings
are in the Virtualbox GUI.
To transfer the MBR object code to the .vdi image I used dd
dd conv=notrunc bs=1 seek=8192 if=mbr1.bin of=hdd1.vdi
(Before copying the file this way it is important to check that the
mbr1.bin file is small enough to fit below the data in the MBR.)
Once the MBR binary has been copied the VM can be started. One thing I
especially like about Virtualbox is its provision of keyboard
commands. Using the default "host key" of Right Control you may find
the following keyboard commands useful.
(In the main prog) Alt + m, t = start the guest
(In the guest window) Right control + p = pause the guest
(In the guest window) Right control + q, Enter = power off the guest
Finally, rather than build the partition table and the 0x55, 0xaa
signature in the assembler source I used a hex editor under Linux,
hexedit, to edit the .vdi file directly. With a suitable screen width
this gives 16 bytes per line, and it responds to page up and down as
well as cursor movement. Control + C aborts any changes made. Control
+ X saves them. I found the screen updates from a telnet session to be
a bit flaky. The screen can be redrawn with Control + L but I ended up
using RealVNC to get to the Linux server and edited the disk images in
a terminal window.
Other utils used were: ndisasm, cat, hd (for displaying a file in
hex), grep and the usual Unix gubbins. As so often Unix makes a lot of
things very easy. :-)
James