Thursday, October 31, 2013

Happy 20th Birthday FreeBSD!

In honor of the 20th birthday of FreeBSD, we've reconstituted FreeBSD 1.0 on Qemu.  We had some help from Warren Block's  post.  Nonetheless, it was a significant challenge.

Here's how we got it up and running.  If you're up to the challenge, grab the ISO and give it a whirl.  In case you just can't get it working, I've included some links to a working Qemu image at the end of this blog post.

If you just want to copy and paste, be aware  that just copying and pasting the examples below from this website may introduce extra lines or characters.  Copy first to a local text file and clean up as needed.

First, we needed to use the stable version (0.11.1) of Qemu instead of the development version.  We had to use the Bochs bios instead of Seabios.  We could not get Seabios to recognize a second floppy drive.  Refresh your ports collection and make Qemu from source with the options shown:

# Build Qemu from ports with the options shown

cd /usr/ports/emulators/qemu
make
make install













# Set up a working directory and disk image name.
# Also setup some handy environment variables.

mkdir /usr/fbsd1_0
export QDIR=/usr/fbsd1_0
export QHDA=FreeBSD-1.0_HDA.img

# Next, grab the 1.0 ISO (cd1.iso) , mount it, copy all
# all the files to a directory we will later use for FTP.

# Something like:

mkdir -p /var/ftp/pub/FreeBSD-1.0
mdconfig -a -t vnode -f cd1.iso -u 0
mount -t cd9660 /dev/md0 /mnt
cp -av /mnt/* /var/ftp/pub/FreeBSD-1.0 

# Copy all the floppies we will need to get bootstrapped
# into our working directory:

cp -av /mnt/floppies/*.flp $QDIR


# Now create the Qemu hard disk image. We'll use the qcow
# format for now.  See the Qemu docs if you want a different
# Qemu image format.  2GB is plenty of space.


cd $QDIR
qemu-img create  -f qcow $QHDA 2G


# OK, here we go!  Light 'er up...

export QHDA=FreeBSD-1.0_HDA.img
export QDIR=/usr/fbsd1_0
/usr/local/bin/qemu -monitor stdio \
-vga cirrus \
-m 128 \
-localtime \
-fda $QDIR/kcopy_ah.flp \
-fdb $QDIR/filesyst.flp \
-hda $QDIR/$QHDA \
-boot a \
-net nic,vlan=0 \
-net user,vlan=0 \
-name "FreeBSD 1.0"

# Hit "B" to load the filesystem floppy:

















# Take the defaults except for "Install FreeBSD on entire disk" option (y)
# and MS DOS option (n), and if you want a verbose install (y).

# Do not take the default disk layout.  Give the root disk
# about 500MB (1000 sectors) and the /usr filesystem the rest.
# Everything should work (partition and newfs).
#
# Depending on the speed of your system, the disk creation
# and formatting can take 20 minutes or longer.
# Grab a cup of coffee and check your email.
# The guest installer will want you to reboot.  You can
# exit Qemu and reuse the same command line, or just hit
# return at the guest reboot prompt.

# For the 2nd boot - just hit RETURN on the disk switch prompt.
# Enter "copy" at the kc> prompt, and "wd0a" for the disk.

















# 3rd boot.  For this boot, you'll have to shut down the
# Qemu guest and restart with the cpio.flp in floppy b
# and select '1' at the prompt.  Use the command line
# below:

export QHDA=FreeBSD-1.0_HDA.img
export QDIR=/usr/fbsd1_0
/usr/local/bin/qemu -monitor stdio \
-vga cirrus \
-m 128 \
-localtime \
-fda $QDIR/kcopy_ah.flp \
-fdb $QDIR/cpio.flp \
-hda $QDIR/$QHDA \
-boot c \
-net nic,vlan=0,model=ne2k_isa \
-net tap,vlan=0,ifname=tap0 \
-name "FreeBSD 1.0"


# Files are copied from the floppy to the hard disk.
# If you selected no MS DOS option above, enter
# 'n' for "Install optional dos floppy?" prompt.
# Enter 'halt' to reboot.
















# You need networking for the next step.

# Set up for bridge/tap networking here
# and start an FTP server on the host.
# You'll need the 1.0 sources in the ftpd
# download directory you copied above (/var/ftp/pub/FreeBSD-1.0/)

# Might need to disable any firewall you have running
pfctl -d

# Start up an FTP server
/etc/rc.d/ftpd onestart

# Load some kernel modules for bridge and tap devices
kldload aio
kldload if_bridge
ifconfig bridge0 create
ifconfig bridge0

kldload if_tap
ifconfig tap0 create
ifconfig tap1 create

# Add devices to the bridge.
# Replace em0 with your network interface on the next line.
ifconfig bridge0 addm tap0 addm em0

# or, if your host is using wireless interface,

# ifconfig bridge0 addm tap0 addm wlan0

# These sysctls allow a user program (Qemu) to open the tap device.
sysctl net.link.tap.user_open=1
sysctl net.link.tap.up_on_open=1

# Make sure the bridge is actually running!
ifconfig bridge0 up


# Now boot from the hard disk.  No floppies needed.
# The OS will complain that the filesystem has
# not been checked and will run fsck to check it.
# and will then reboot by itself.


export QHDA=FreeBSD-1.0_HDA.img
export QDIR=/usr/fbsd1_0
/usr/local/bin/qemu -monitor stdio \
-vga cirrus \
-m 128 \
-localtime \
-hda $QDIR/$QHDA \
-boot c \
-net nic,vlan=0,model=ne2k_isa \
-net tap,vlan=0,ifname=tap0 \
-name "FreeBSD 1.0"

















# Qemu should now boot from hd(0a,)/386bsd
# and you should get to the shell prompt with the
# "To finish installation:"  screen.
#
# It's now time to load all the tarballs.

# We will set up a network interface (ed1)
# on the Qemu guest and FTP back to the host system.
# Both the host and the guest should be on the
# same network segment.  For this example, the
# host is at 192.168.1.200/24, and the guest is set to
# 192.168.1.150/24.  Choose the network address
# that works best for you.

# Commands indented below are entered on the GUEST, not the HOST.

      mkdir /usr/distrib
      cd /usr/distrib

      ifconfig ed1 192.168.1.150 netmask 255.255.255.0

# check the TAP interface onthe host above.
# both tap0 and bridge0 devices should be UP.
# Now FTP  into the HOST and cd to the  1.0 download area
# and get the files you need.

   ftp 192.168.1.200
      anonymous
      you@

      cd pub/FreeBSD-1.0/tarballs/bindist

      prompt off
      hash on
      binary
      mget *
      quit















 















# Extract the bindist tarballs onto the guest
# The EXTRACT.sh script produces no output by default
# and can take several minutes, possibly as long as
# 30 minutes for some tarball extractions.


      sh EXTRACT.sh


     # It looks like this:

     #!/bin/sh
     #
     # This file will extract all of the FreeBSD binaries into /.
     #
     #  SOURCEDIR=.
     #  DESTDIR=/
     #  cd $SOURCEDIR

     # Note that base.aa is REQUIRED to be able to use the source tree for
     # building in.
     #
     #  cat bin_tgz.* | gunzip | tar --directory ${DESTDIR} -xpf -

     # Wait for it to finish


     # Note that you should FTP and EXTRACT.sh the bindist,
     # objdist, srcdist, xfree86, and xfreesrc tarballs separately
     # because each has it's own EXTRACT.sh file.

     # Finally, from the install.txt doc:

     mv /.profile /.profile.install
     ln /root/.profile /.profile


     # Then read "Configuring Your System" in the install.txt guide
     # and run the command "configure"
     #
     # Now halt the guest system and shut down Qemu.
     #

# Finally, back on the host, reboot Qemu with the command:

export QHDA=FreeBSD-1.0_HDA.img
export QDIR=/usr/fbsd1_0
/usr/local/bin/qemu -monitor stdio \
-vga cirrus \
-m 128 \
-localtime \
-hda $QDIR/$QHDA \
-boot c \
-net nic,vlan=0,model=ne2k_isa \
-net tap,vlan=0,ifname=tap0 \
-name "FreeBSD 1.0"


# Hopefully, you now have a working FreeBSD 1.0 system!

# Note that, by default, there is no root password.
# Please set a root password if that is a concern for your system.

Here are some links:

Qemu image from the above, with all tarballs loaded (but no root password!):
Use the last command line above to run.

http://aorn.jimby.name:81/fbsd1.0/FreeBSD-1.0_HDA.img

MD5 (FreeBSD-1.0_HDA.img) = faf0df70ec09940e47e9a497eb113786
SHA1 (FreeBSD-1.0_HDA.img) = 2351afeaf7b86ba3542f03e257db811e36e58af6


Whimsical demo with sound by the Berlin Philharmonic. (Wait for it...)

http://aorn.jimby.name:81/fbsd1.0/fbsd_bd.mpg

MD5 (fbsd_bd.mpg) = 6565df650f0067126fa0ae51d757ee48
SHA1 (fbsd_bd.mpg) = b16044a0e2746985416e216e0b85040b3294fd74



The above demo works with VLC.  Sound under Firefox may not work.

No comments:

Post a Comment

Post a Comment