Talk:386BSD

From Computer History Wiki
Revision as of 14:43, 30 June 2010 by Tor (talk | contribs) (Added comment)
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
wget http://downloads.sourceforge.net/project/bochs/bochs/2.4.2/bochs-2.4.2.tar.gz?use_mirror=kent
gunzip -c bochs-2.4.2.tar.gz |tar -xvf -
wget http://www.xs4all.nl/~dugo/pic.cc
mv -f pic.cc ./bochs-2.4.2/iodev/pic.cc
cd bochs-2.4.2
./configure --enable-cpu-level=3 \
            --enable-ne2000 \
            --with-term \
            --with-nogui \
            --enable-all-optimizations \
            --enable-docbook=no
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
vsftpd
cd /var/ftp
wget -r -np ftp://minnie.tuhs.org/BSD/386bsd-0.1/
wget -r -np ftp://minnie.tuhs.org/BSD/386bsd-patchkits/
mv minnie.tuhs.org/BSD ./
rmdir ./minnie.tuhs.org
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 192.168.1.1 becomes the gw and you can pick an ip in 192.168.1.0/24 for the guest later.

# set up the bsd dir w/ tunconfig
cd; mkdir bsd; cd bsd
printf '#!/bin/bash\n/sbin/ifconfig ${1##/*/} 192.168.1.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 192.168.1.0/24 -d ! 192.168.1.0/24 -j MASQUERADE >& /dev/null
/sbin/iptables -t nat -s 192.168.1.0/24 -d ! 192.168.1.0/24 -A POSTROUTING -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
__EOF
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
__EOF

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.

Dugo

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, 10.0.0.1 to where your ftpd lives, 192.168.1.1 to your gw and 192.168.1.2 to the ip you want to give the guest. Change odin into the name you want to give the guest.

echo "machine 10.0.0.1" >.netrc
echo "login ftp" >>.netrc
echo "password news@EU.net" >>.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 192.168.1.2 netmask 255.255.255.0 up
route add default 192.168.1.1
ftp 10.0.0.1

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
./mkpatchdirs
cd /patch
cd bin
(echo y; echo; echo; echo IALL; echo y ; echo ; echo q)|./patches
cd /patch
cd bin
sh -x afterinstall.sh

Recompile the GENERIC kernel.

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

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

cd /dist/bin
buildworld.sh
sync; sync; sync;
reboot

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 afterinstall.sh
rm -r /sys/compile/*
cd /sys/i386/conf
config GENERICISA
cd /sys/compile/GENERICISA
make depend
make
mv /386bsd /386bsd.old
cp 386bsd /386bsd
sync; sync; sync;
reboot
cd /patch/bin
./buildworld.sh
sync; sync; sync;
reboot

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 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 http://www.386bsd.org/past ? Dugo 05:26, 13 April 2010 (UTC)