How to use bochs to run the Hurd

by Bruno Bonfils, <asyd at debian-fr dot org>

Since I don't have enough computers to dedicate a box to the Hurd, I'm trying to do my own harddrive image disk. I thougt there was some documentation about how to do that. But since I didn't find anything and I decided to write a small doc. I hope this document will be useful for some people who wants to try the Hurd.

Debian (Sid) GNU/Linux 2.4.19

ii  bochs          1.4.1.no.elpin IA-32 (x86) PC emulator
ii  bochs-x        1.4.1.no.elpin Bochs binary with X interface.
ii  grub           0.92+cvs200209 GRand Unified Bootloader
ii  gcc-i386-gnu   1.7-8          Cheap cross-compiler for GNU/Hurd.
ii  mig-i386-gnu   1.2-1          The GNU distribution of the Mach 3.0 interface

If you don't have time and if you trust me, you can download here [1] my own image file. (You don't need to run native-install)

In this example, I use a 112 MB image disk, but I think you can use any size without some problem.

Use createdisk command like this :

# createdisk hurd.img 112 

Disk Geometry:
C: 227
H: 16
S: 63
Total size: 117153792 bytes

Note on a paper or on your memory the disk geometry. Then, use the losetup command to create a loopback on the whole disk.

# losetup /dev/loop1 hurd.img

Now, call fdisk on /dev/loop1. Go into expert mode, and modify the disk geometry using the c, h, s commands. Return in normal mode, and create an unique primary partition which uses the whole disk. Then, detach the /dev/loop1 using :

# losetup -d /dev/loop1

First of all, you need to create a filesystem on the disk. Use the command losetup and -o <offset> option to attach /dev/loop1 on the first partition of an image disk. Offset is computed like this : offset = sector * block_size (512)

# losetup -o 32256 /dev/loop1 hurd.img

According to The Hurd Installation Guide [2], use mke2fs to create a filesystem.

# mke2fs -o hurd /dev/loop1

Just mount /dev/loop1 like a typical dev.

# mount /dev/loop1 /mnt/gnu

Download a GNU/Hurd archive as indicated in the Hurd Installation Guide, and decompress it in /mnt/gnu.

# cd /mnt/gnu
# tar --same-owner -xvzpf ~/gnu-latest.tar.gz

Copy default configuration (/usr/share/doc/bochs/examples/bochsrc.gz on debian) on your home directory and edit it with your favorite editor (GNU Emacs, i hope ;).

For my image file I have the following configuration :

config_interface: textconfig
display_library: x
romimage: file=/usr/share/bochs/BIOS-bochs-latest, address=0xf0000
megs: 32
vgaromimage: /usr/share/vgabios/vgabios.bin
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata1: enabled=0, ioaddr1=0x170, ioaddr2=0x370, irq=15
ata0-master: type=disk, path="/home/asyd/travail/hurd/bochs/hurd.img", cylinders=227, heads=16, spt=63
newharddrivesupport: enabled=1
boot: disk
floppy_bootsig_check: disabled=0
log: /dev/stdout
panic: action=ask
error: action=report
info: action=report
debug: action=ignore
debugger_log: -
com1: enabled=1, dev=/dev/ttyS0
vga_update_interval: 300000
keyboard_serial_delay: 250
keyboard_paste_delay: 100000
floppy_command_delay: 500
ips: 1000000
mouse: enabled=0
private_colormap: enabled=0
fullscreen: enabled=0
screenmode: name="sample"
keyboard_mapping: enabled=0, map=/usr/share/bochs/keymaps/x11-pc-fr.map
i440fxsupport: enabled=0

note most of them are actually in the default Debian example file. If you use these lines, don't forget to read the Networking section.

Remember that the Hurd is not an OS, it's just a collection of libraries and programs, so we can't actually boot the Hurd. We boot GNU Mach, and then launch the base servers.

The default GNU Mach which is provided by the default GNU/Hurd archive contains some modules / drivers which are not needed in bochs environment. If you use it, you'll probably have some kernel panic while booting. Don't be afraid and just say alwayscont.

Note: in my archive, I use a recompiled GNU Mach which contains only the drivers which are needed (--enable-floppy --enable-ide --enable-kmsg --enable-ne2000). If you want more informations on how to compile your own GNU Mach, just send me a mail and I'll add the section in this document.

Create a grub floppy disk or use my floppy image [3]. Adapt your bochsrc file according to your choice. If you want install Grub on the image disk, remember to copy stage1, stage2 Grub's files into /mnt/gnu/boot/grub.

Launch bochs - as root if you want networking (using sudo for example).

If you have stage1 and stage2 file, you can install Grub on the MBR.
<grub> root (hd0,0)
<grub> setup (hd0)

Finally, booting GNU mach

<grub> root (hd0,0)
<grub> kernel /boot/gnumach.gz root=hd0s1
<grub> module /boot/serverboot.gz
<grub> boot
Now, you can read the official Hurd Installation Guide [2].

You can try to test networking between the GNU/Linux (host OS) and the GNU/Hurd. First of all, please read [4], I currently have the *same* problem.

Verify your kernel configuration, you need to have :

CONFIG_NETLINK_DEV=m
CONFIG_ETHERTAP=m

(or y instead or m). Check if /dev/tap0 file exist, else create it with

# mknod /dev/tap0 c 36 16

and run this command on the guest os :

# ifconfig tap0 192.168.100.1 netmask 255.255.255.0

Use ip 196.168.100.10 on the GNU/Hurd and you can ping 192.168.100.1


Copyright (c) Bruno Bonfils
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation.
Last modified : Wed, 05 Feb 2003 15:50:51 +0100
Valid HTML 4.01!