Installing and running bochs


Source

http://bochs.sourceforge.net

Copy of my .boshrc here

Compilation and installation

download source
compile using

cd $SRCROOT

./configure
make
make install


Creating the Bochs Environment

You have to create a hard disk for bochs to use, an A: drive either on disk or the real one and link the cdrom or create a virtual cd from an iso

Make a directory in your home directory called bochs

mkdir bochs
cd bochs/

Install the sample .bochsrc into the bochs dir

cp $SRCROOT/.bochsrc $HOME/bochs/

Copy the bios files to the $HOME/bochs/ dir

cp -Rv $SRCROOT/bios $HOME/bochs/

create a virtual harddisk using bximage

bximage
hd <ENTER> # leave default
1028  <ENTER> # enter hard disk size (I entered 1028 as windows 2000 is 675MB)
c.img <ENTER> # leave the filename the default

copy and paste the string bximage outputs ( "ata0-master: type=disk, path="c.img", cylinders=20, heads=16, spt=63"  <-- don't use this string it's for a 10MB drive a bit small these days ) into .bochsrc in the appropriate place

crate a floppy disk image from a dos boot disk

cp /dev/fd0 $HOME/bochs/a.img

See these notes below also for more information on hdd and fonts (especially fonts)

Floppy disk access

Real floppy you can point you emulated floppy to either an ondisk file or /dev/fd0

for the real floppy put the following in .boshrc

floppya: 1_44=/dev/fd0H1440, status=inserted

Emulated floppy

./bximage
choose fd
select 1.44 (default disk size)
select a.img (default filename)


put the following line in .bochsrc

floppya: 1_44=a.img, status=inserted

CDROM Access

Real CDROM

if you have a cdrom at /dev/cdrom

edit the .bochsrc file to point to

ata0-slave: type=cdrom, path=/dev/cdrom, status=inserted

Emulated CDROM

make an iso image:
cp /dev/cdrom /path/to/isofile.iso

Then add the following to .bochsrc
ata0-slave: type=cdrom, path=/path/to/isofile.iso, status=inserted





The following is lifted straight for the docs-html/installation.html file in the bochs source

Setting up environment before running

In text mode, Bochs requires your X server to have access to the VGA font. If you don't already have it, you must install it from one of the font files in bochs-yymmdd/font.

There are two options; you may install the VGA font in a global place, or in a local directory. You may need to install it locally if you don't have root access.

Option 1: installing VGA font in global font directory

   # NOTE1: Make sure your DISPLAY variable points to local machine.
# NOTE2: These steps require root privileges.
# NOTE3: Your X11 fonts path will vary on different systems. For example:
# Solaris 2.x /usr/openwin/lib/X11/fonts
# Linux /usr/lib/X11/fonts/
root-> cp font/vga.pcf font-path-here/misc
root-> compress font-path-here/misc/vga.pcf # I had to use gzip because I didn't have compress on mandrake 9.1
root-> mkfontdir font-path-here/misc
root-> xset fp rehash
root-> /etc/rc.d/init.d/xfs restart (Restart your X font server)
The command to restart the X font server is given for Redhat systems, but it will vary between different machines, and might not even be necessary at all. If you cannot figure out how to restart your font server, you can just reboot.

Option 2: installing VGA font in local font directory

   # NOTE1: Make sure your DISPLAY variable points to local machine.
# NOTE2: The "xset" command needs to be run for each X session.
user-> mkfontdir bochs-YYMMDD/font
user-> xset fp+ [full-path]/bochs-YYMMDD/font
Hard Drive Image File: Bochs emulates a hard drive by using a large Unix file, which you must create. The size of the hard drive is dependent upon the number of cylinders, heads, and sectors-per-track that you would like to emulate. Here are some examples of possible drive geometries:

Size Cylinders Heads Sectors/Track Sectors Total
10MB 306 4 17 20808
20MB 615 4 17 41820
30MB 615 6 17 62730
46MB 940 6 17 95880
62MB 940 8 17 127840
112MB 900 15 17 229500
126MB 256 16 63 258048
483MB 1024 15 63 967680
504MB 1024 16 63 1032192
640MB 1300 16 63 1310400
886MB 1800 16 63 1814400
1280MB 2600 16 63 2620800
2215MB 4500 16 63 4536000
3495MB 7100 16 63 7156800
5020MB 10200 16 63 10281600
7088MB 14400 16 63 14515200
10041MB 20400 16 63 20563200
12206MB 24800 16 63 24998400
16045MB 32600 16 63 32860800
20672MB 42000 16 63 42336000
25003MB 50800 16 63 51206400
29974MB 60900 16 63 61387200
32238MB 65500 16 63 66024000

For hard disk sizes larger than 528MB, be sure that newharddrivesupport is enabled. This will be the compiled default in a future release, but for now your .bochsrc still needs the line "newharddrivesupport: enabled=1" in order to support >1024 cylinders.

Pick the size of the hard drive you want to emulate, and create a blank file according to the parameters in the table. If you have the 'dd' command, you can use it to create the file. Keeping in mind that there are 512 bytes in a sector, just use the number of "Sectors Total" from the table as the 'count=' option to dd, and tell dd to use a block size ('bs=') the same as a disk sector size (512). For example, for a 112MB drive, there are 229500 (900*15*17) sectors.

    unix-> dd if=/dev/zero of=112M bs=512 count=229500
Floppy Disk Image File: Bochs emulates a floppy drive/disk using either a Unix file, or a real floppy drive Unix device. To use either, you will need an entry in your '.bochsrc' file pointing to the regular or device file. Use the 'floppya:' and 'floppyb:' directives. If you are starting out, you will need to make a copy of an existing bootable floppy. Otherwise, you may create a blank image file, if you intend on formatting it using the OS you boot within Bochs.

Size Cylinders Heads Sectors/Track Sectors Total
0.720MB 80 2 9 1440
1.2MB 80 2 15 2400
1.44MB 80 2 18 2880
1.680MB 80 2 21 3360


To create a blank floppy image file, you can use the same concept as above for creating blank hard disk image files. For example, to create a blank 1.44MB floppy image file:
    unix-> dd if=/dev/zero of=1.44M bs=512 count=2880
To create a copy of an existing floppy disk, granted you have a floppy disk drive on your workstation, you can use one of the following commands, where '/dev/fd0' would be the path to your floppy drive device name.

NOTE: If your system uses a form of volume management to automount your floppy drive, you may have to tell it you popped in a new floppy, and use an alternative device name to access it.

    # Linux, direct use of floppy drive using 'dd'
unix-> dd if=/dev/fd0 ibs=512 of=1.44M

--or--

# Linux, direct use of floppy drive using 'cp'
unix-> cp /dev/fd0 1.44M