by December 2, 2003 0 comments



You may have Windows as your base OS and also want to run Linux and BeOS (or any other OS) on your machine. To switch between OSs, you have to reboot your machine each time, causing wastage of time. But, with Bochs, you can use multiple OSs on your machine simultaneously without having to reboot it each time. You simply toggle between windows or use the Alt+Tab keys. Similarly, you can even emulate peripherals across hardware platforms. 

Bochs is an open-source PC emulator that works on Windows (Win 95/NT, DOS) and all flavors of Linux, and on most hardware platforms (Intel x86, PPC (PowerPC), Alpha, Sun and
MIPS). 

Running Win 98 inside WinXP

Written in C++, it works by interpreting the instructions from power-up to shutdown and creating a customized I/O device model for all standard peripherals (such as keyboard, mouse, VGA card/monitor and network card). Since, Bochs works on image files, when you switch on the PC, it loads the customed BIOS, looks for the bootable image file of the OS and then boots from that image file. Remember that for each OS image that you have on your system, Bochs will repeat this process.

Bochs is controlled by a config file called ‘bochsrc’, which contains the configuration of your emulated BIOS and peripherals.

You can even define your own parameters in this file and change the behavior of the Bochs virtual machine.

CODING
# bochsrc config disk image
# Memory required for the virtual machine 
megs: 62
# ROM image emulation
romimage: file=$BXSHARE/BIOS-bochs-latest, address=0xf0000
# VGA emulation
vgaromimage: $BXSHARE/VGABIOS-elpin-2.40
# Floppy disk emulation (Note: a.img and b.img below are floppy image files. You can create any floppy-based bootable image using the dd command in Linux or from floppy image 2.2 in Windows.)
floppya: 1_44=a.img, status=inserted
floppyb: 1_44=b.img, status=inserted
# Hard disk/CD-ROM emulation
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15
# c.img is an image created in Step 2 and replaces the value you noted there
ata0-master: type=disk, path=”c.img”, mode=flat, cylinders=4063, heads=16,
spt=63
# Emulate cdrom as drive letter e:
cdromd: dev=e:, status=inserted
# Choose the boot disk sequence from floppy/cdrom/hard disk
boot: a
# Where to send log messages
log: bochsout.txt
# Disable/enable mouse support, 1 to enable/0 to disable
mouse: enabled=1
# Enable key mapping, using US layout as default
keyboard_mapping: enabled=1, map=$BXSHARE/keymaps/x11-pc-us.map

In this article, we’ll see how to configure Bochs on a PC running Win XP, with Win 98 and PicoBSD being the two virtual OSs within Win XP. 

STEP
ONE
To install Bochs, copy the Bochs-2.1.pre1.exe file from our this month’s DVD on your Windows desktop and install it. Then create a folder where you will keep the image and configuration files for the virtual
OSs. 

Next, create one raw image file for each of the virtual disks depending on the disk size you want. To create a raw image, open a command prompt and go to C:\Program Files\Bochs-2.1.pre1 directory. From here run bximage command. This will ask you to create an image of a floppy drive [fd] or hard disk [hd]. Select hd, then specify the disk size for the virtual disk (the virtual disk is in the form of an image file). For example, if you want 2 GB, then give a value of 2000 and press Enter. It will then ask you to name the image file, which by default is c.img. This will give the values for cylinders, heads and sectors. Keep a note of these values.

STEP
THREE
After creating the virtual disk in the form of an image file (c.img), copy that file to the folder that you would have created in Step 1. Next, create a config file for the virtual machine. Open Notepad and write the configuration given in the box. (The explanation of the code is preceded by a hash.)

Save the config file as bochsrc.bxrc. This file will show a box icon in the Explorer window. Copy this file to the folder created in Step 1, where you have also kept the c.img file. You can even emulate other peripherals for which you’ll have to make further entries in the config file. The software’s documentation explains how you can do it. 

BOCHS
ON LINUX
Bochs works on Windows and Linux. This article talks about configuring it in Windows. To use Bochs in Linux, read Multiple OSs in Linux on page 121 in this issue.

STEP
FOUR
To install Win 98, create a DOS or 9x bootable floppy, and ensure that it contains fdisk and format commands. Then create an image of the floppy using the dd command in Linux or Floppy Image 2.2 in Windows (get it from download.com). Call the image file a.img. Place this image in the folder created in Step 1, and go to this folder from Windows Explorer. Double click on the bochsrc.bxrc file to start your virtual machine. Boot the virtual PC using its virtual floppy drive a.img (floppy image), which is mentioned in bochsrc.bxrc file. After booting the virtual machine from the floppy image, run the fdisk command to create a primary partition on the virtual disk (c.img created in step 1). Then run format c: /s to format the virtual disk and make it bootable. Next open bochsrc.bxrc and find the boot: a entry and replace it with boot: cdrom and save this file. Now place a Win 9x bootable installation CD in the CD drive and double click on bochsrc.bxrc file to start the virtual PC. The virtual PC will boot from CD-ROM and install Win 9x on the virtual C disk drive (c.img). After installation, open bochsrc.bxrc and change the boot: cdrom entry to boot: c. Save the change and click on bochsrc.bxrc to power on the virtual PC. Now the virtual PC will boot from Win 9x. 

Sanjay Majumder

No Comments so far

Jump into a conversation

No Comments Yet!

You can be the one to start a conversation.

Your data will be safe!Your e-mail address will not be published. Also other data will not be shared with third person.