Warning: include(../../outline.top.php) [function.include]: failed to open stream: No such file or directory in /home/c0000/domains/osdever.net/html/tutorials/bochs/bochs_nix.php on line 7

Warning: include() [function.include]: Failed opening '../../outline.top.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /home/c0000/domains/osdever.net/html/tutorials/bochs/bochs_nix.php on line 7

Bochs for Linux

by Alexander Blessing

What is Bochs?

Bochs is a i386 PC emulator. It's very useful for testing new kernels - you won't have to reboot your PC to test your kernel. I decided to write this document especially for Linux, because I know there's already a tutorial for Windows out there. Consider you're in Linux, developing your kernel. You made a basic change and want to test your Operating System. Now, instead of rebooting your PC (which takes you much time), you just run Bochs. Bochs is quite powerful, but not perfect. It can happen that Bochs is not able to handle your kernel. That happens if your kernel has special options, but normally, Bochs runs fine - I had problems with it, but managed to solve it (it was my fault).

Where to get Bochs

Bochs is available here. Download the Linux version, and install it on your PC.

How to run Bochs

You can run Bochs by just typing 'bochs' into the terminal. Bochs needs the XServer to be run... But before running Bochs the first time, you have to edit the .bochsrc file. This file contains the definitions for Bochs. Consider our kernel is loaded by GRUB. GRUB is installed on a floppy, that's the best way to do it. So we have to tell Bochs to boot from the floppy. That's my .bochsrc file:

megs: 32
romimage: file=/usr/local/bochs/1.4.1/BIOS-bochs-latest, address=0xf0000
vgaromimage: /usr/local/bochs/1.4.1/VGABIOS-elpin-2.40
floppya: 1_44=/dev/fd0, status=inserted
boot: a
log: bochsout.txt
mouse: enabled=0

That's it. Now let's go step by step through it:

Copy this file into your home directory. Attention, you have to be root, because a normal user is not allowed to read from /dev/fd0! So you must have the fil /root/.bochsrc.txt. Okay, now run 'bochs' at last. Insert the GRUB disk and press three times [ENTER]. A new window will appear. Bochs will now load GRUB. When he has finished it is time to load our kernel. So remove the GRUB disk and insert a new disk which contains your kernel. Now double-click on the floppy symbol (the floppy with an 'A') to load the floppy in memory. Then, proceed as usually:

kernel /myos.bin
boot

You don't need the root instruction...

Summary

That's it - you managed to run Bochs with GRUB and your kernel. It's quite useful, isn't it? I didn't have problems with Bochs yet (actually I had, but it was my fault).


best regards,
Alexander Blessing
© All Rights Reserved Bona Fide OS development 2001-2006. We Disclaim responsibility for all bad things, good things okay.