Bochs for Linux

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:

  • The megs: line tells Bochs how many mega bytes of memory to use. 32 should be okay.
  • The romimage: and the vgaromimage line gives the path to the romimage respective the vgaromimage to use. I wouldn't bother about that, just look up these two files and tell Bochs the path...
  • The floppya: line tells Bochs where he can find the floppy. /dev/fd0 is the first floppy controller.
  • Now, the boot: line is quite important. This line sais from which device to boot. We decided to boot from a, that's the floppy.
  • The log: line tells Bochs to print informations at run-time to bochsout.txt
  • Finally, we disable the mouse because we won't need 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

Related

Report issues via Bona Fide feedback.

2001 - 2024 © Bona Fide OS Development | The Goal | Contributors | How To Help |