From Computer History Wiki
Jump to: navigation, search

You can get 386BSD to run in a patched bochs 2.4.2, full blown with all the patches, triple make world, the works. Ok, ok, try to compile perl-5.10.1 and the compiler segfaults, but what is in the distro works. Everything works. There exists a broken (in a mere two pieces) shell script that reproduces a bochs image and environment on an AWS default fedora server. The script is of such questionable and perverted command line art that it is deemed unredistributable in its current form. It can be done! Dugo

Can you give more details? Suddenly this is interesting again... !

neozeed 17:57, 3 April 2010 (UTC)

Ok here goes. Take a eg. Basic Fedora Core 8 box and install required software.

yum -y install wget
yum -y install gcc
yum -y install gcc-c++
yum -y install ncurses-devel
yum -y install vsftpd

The 386BSD bootflop does something odd. The workaround is to patch bochs to ignore it instead of panic when 386BSD tries to write 0x02 to port 20h.

# get bochs
cd /usr/local/src
gunzip -c bochs-2.4.2.tar.gz |tar -xvf -
mv -f ./bochs-2.4.2/iodev/
cd bochs-2.4.2
./configure --enable-cpu-level=3 \
            --enable-ne2000 \
            --with-term \
            --with-nogui \
            --enable-all-optimizations \
make && make install

During installation the 386BSD distribution files can be fetched with ftp. To facilitate this set up an anon ftpd that serves up the files. There is a catch 22. 386BSD comes without gzip, but the patches are gzipped, here your chance to get around that.

echo listen=YES >> /etc/vsftpd/vsftpd.conf
cd /var/ftp
wget -r -np
wget -r -np
mv ./
rmdir ./
cd /var/ftp/BSD/386bsd-patchkits
gunzip *gz

To make bochs' ne2k work without a spare NIC in your host you need to set up tunneling.

echo alias char-major-10-200 tun >>/etc/modprobe.d/modprobe.conf.dist
depmod -a
ln -s /dev/net/tun /dev/net/tun0

Make a tunconfig script for bochs to fire off when the ne2k comes up. In this example becomes the gw and you can pick an ip in for the guest later.

# set up the bsd dir w/ tunconfig
cd; mkdir bsd; cd bsd
printf '#!/bin/bash\n/sbin/ifconfig ${1##/*/}\n' >tunconfig
printf 'date; echo ${1##/*/} >/tmp/x'  >>tunconfig
cat >>tunconfig <<__EOF
# carnival, put your masks on and go
/sbin/iptables -D POSTROUTING -t nat -s -d ! -j MASQUERADE >& /dev/null
/sbin/iptables -t nat -s -d ! -A POSTROUTING -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
chmod +x tunconfig

The 386BSD installation fails on a box with a lot of mem, hence the `megs: 8' stanza in the bochs configuration.

cat >bochsrc <<__EOF
config_interface: textconfig
display_library: term
romimage: file=/usr/local/share/bochs/BIOS-bochs-legacy
cpu: count=1, ips=80000000, reset_on_triple_fault=0
megs: 8
vgaromimage: file=/usr/local/share/bochs/VGABIOS-lgpl-latest
vga: extension=none
floppya: 1_44=boot.img, status=inserted
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=disk, path="disk.img", mode=flat, cylinders=1024, heads=16, spt=63, translation=none, model=generic
boot: disk, floppy
floppy_bootsig_check: disabled=0
log: bochsout.txt
panic: action=ask
error: action=report
info: action=report
debug: action=ignore
vga_update_interval: 400000
keyboard_serial_delay: 250
keyboard_paste_delay: 1000000
mouse: enabled=0
private_colormap: enabled=0
keyboard_mapping: enabled=0, map=
i440fxsupport: enabled=0
ne2k: ioaddr=0x300, irq=9, mac=fe:fd:00:00:00:01, ethmod=tuntap, ethdev=/dev/net/tun0, script=/root/bsd/tunconfig
com1: enabled=0

Prepare the 386BSD boot floppy for our box with a fancy 1.44MB floppy drive.

(cat /var/ftp/BSD/386bsd-0.1/bootable/dist.fs;dd if=/dev/zero bs=1 count=245760)>boot.img

Make a hard drive for the installation.

rm disk.img; printf "hd\nflat\n504\ndisk.img\n" |bximage

You should now be able to fire up bochs in your terminal and start your journey back in time.

bochs -q -f bochsrc

Bochs will come up booting a tiny 386BSD from floppy, this needs to go to disk, which can be done with a simple

(echo y; echo y)|install

Now try to reboot with..:

shutdown -r now

..this will go horribly wrong but don't panic. Boch will probably crash, just fire it up with..:

bochs -q -f bochsrc

386BSD comes up and shuts down immediately causing bochs to crash again. This is a reoccuring theme, don't worry about it and fire bochs up again anytime this happens. Next, the real work, installing the distro.


The tiny 386BSD kernel keeps kprinting `startartstartart' to your screen once network is up and running. This can get on your nerves, so try to do as much as possible with shell scripts. In this case everything just goes into .netrc.

Extract will complain about something being missing, according to an ancient FAQ this is a joke from Jolitz. Extract also opens more files than tiny 386BSD sh can handle, hence the use csh.

Change the ips below, to where your ftpd lives, to your gw and to the ip you want to give the guest. Change odin into the name you want to give the guest.

echo "machine" >.netrc
echo "login ftp" >>.netrc
echo "password" >>.netrc
echo "macdef init" >>.netrc
echo "#" >>.netrc
echo "pasv" >>.netrc
echo "prompt" >>.netrc
echo "bin" >>.netrc
echo "lcd /tmp" >>.netrc
echo "cd BSD/386bsd-0.1/bindist/" >>.netrc
echo "mget *" >>.netrc
echo "cd ../etcdist/" >>.netrc
echo "mget *" >>.netrc
echo "cd ../srcdist/" >>.netrc
echo "mget *" >>.netrc
echo "cd ../../386bsd-patchkits" >>.netrc
echo "mget *tar" >>.netrc
echo "!echo odin |extract bin01" >>.netrc
echo "!csh -c \"limit openfiles 512; extract src01 ; extract etc01 ; tar -cf /dist.tar /tmp/ ; cp pk023.tar /pk023.tar ; cp pk023024.tar /pk023024.tar ; sync ; sync ; sync ; /sbin/shutdown -r now\"" >>.netrc
echo "quit" >>.netrc
echo "#newl" >>.netrc
echo "" >>.netrc
chmod 400 .netrc
# .netrc is now ready to do the installaion
# fire up the network and go, go go
ifconfig ne0 netmask up
route add default

When all goes well bochs crashes when 386BSD shuts down. Restart twice and 386BSD should greet you with a login prompt and scold you for loging in as root (no password) when you do. Next up, patch the system and do a buildworld. Dugo

Now run the first pile of patches.

cd /
tar -xvf pk023.tar
mv patch /dist
cd /dist
cd bin
cd /patch
cd bin
(echo y; echo; echo; echo IALL; echo y ; echo ; echo q)|./patches
cd /patch
cd bin
sh -x

Recompile the GENERIC kernel.

rm -r /sys/compile/*
cd /sys/i386/conf
cd /sys/compile/GENERICISA
make depend
mv /386bsd /386bsd.old
cp 386bsd /386bsd
sync; sync; sync;

When bochs goes down because of the reboot, up the amount of mem or the following will take ages.

cd /dist/bin
sync; sync; sync;

Now do it all again with the second patch set.

cd /
tar -xvf pk023024.tar
cd patch/bin
(echo y ; echo ; echo ; echo IALL ; echo y ; echo ; echo q )|./patches
sh -x
rm -r /sys/compile/*
cd /sys/i386/conf
cd /sys/compile/GENERICISA
make depend
mv /386bsd /386bsd.old
cp 386bsd /386bsd
sync; sync; sync;
cd /patch/bin
sync; sync; sync;

For good meassure and proof the box works do another buildworld. Then go do something fun with it. Hack a uname system call into the kernel, fix the ancient zoneinfo, fail at getting ssh to work on it, etc..

If something is broken in the commands/scripts above, sorry, I fsckd up, but they should contain enough hints to get a 386BSD box emulated. Dugo Dugo

Very interesting. I was using the 0.1 release (actually it may have been the 0.0 release, around Jan. 1992) for a short while when it came out, the reason I switched over to Linux 0.95 (early 1992) was IIRC something about the disk usage - I seem to recall that 386BSD wanted the whole disk while it was easy enough to partition with Linux. Or something other that made it easier to let Linux co-exist. Fuzzy memory. -- Tor 13:43, 30 June 2010 (UTC)

Damn dude, that's like an install article... feel free to write one (use any tutorial as a template if you want) or I'll just do it...

Thanks that's some great work thought!!!!!!

neozeed 04:21, 5 April 2010 (UTC)

I'll try to iron out any misdirections in the above and fold it into a networking with bochs and a 386BSD on bochs tutorial. Dugo 10:23, 5 April 2010 (UTC)

Awesome job so far! neozeed 20:40, 9 April 2010 (UTC)

Getting there. While I think it is important to have this piece of history (386BSD 0.1 + patchkits) preserved for future emulator use there is something missing. Anyone with a clue where I can get an ISO of the 386BSD 1.0 release William & Lynne Jolitz show off on their website ? Dugo 05:26, 13 April 2010 (UTC)

Re: "The 386BSD bootflop does something odd. The workaround is to patch bochs to ignore it instead of panic when 386BSD tries to write 0x02 to port 20h."
I had a look at bochs-2.4.6, and it appears to have the 386BSD workaround patch included now. --Tor (talk) 01:40, 2 April 2013 (PDT)
Thx, updated the install manual. Dugo (talk) 03:43, 3 April 2013 (PDT)


I browsed through a load of old DDJ in the late 90s but can't remember a full blown 2.0 CDROM release. A Net release would have left traces on Dejanews google news. The German wiki on 386BSD mentions something about an update disk.

"Ebenfalls von Dr. Dobb's Journal wurde schließlich 1995 noch ein Update auf die letzte öffentliche Version 386BSD 2.0 in Form einer Update-Diskette herausgegeben."

64 bit Jolix

Just musings I suppose..