My Adventures with NetBsd/mac68k

Or: Installing NetBsd 1.5 on an Apple Macintosh Performa 475 w/ Upgraded 68040 Processor.

Version I, 17.08.2001.

Contents

  1. Foreword
  2. Performa 475 Hardware Profile
  3. Downloading the Files
  4. Preparing the Machine
  5. Partioning the Hard Disk
  6. Formatting the NetBsd Partitions
  7. Installing the Base System
  8. The First Boot
  9. The Second Boot
  10. Easy Improvements
  11. The Bourne Again Shell (bash)
  12. Clock Synchronisation
  13. Accessing Mac Partitions
  14. The Secure Shell (ssh)
  15. Installing XWindows
  16. What's Missing
  17. What's Next
  18. References

1. Foreword

This little essay documents my efforts in installing, configuring and running NetBsd on an 68k Macintosh. It's the result of the idea to avoid an 8 years old piece of industrial witchcraft from being dumped or becoming useless. In spite, my intention was to examine if this Macintosh that has become an unreliable beast using the most recent Mac OS versions could have a future as a Unix server.

I first tried the Debian Linux-m68k distribution with no success. Then I discovered NetBsd claiming that even this computer "of course it runs NetBsd".

And it was true: I should successfully install the operating system going through some awkward hard disk partitioning, and in the end be the proud administrator of a stable running *nix box. Compared to the poking aroung with Debian, it was an ease to go for NetBsd. This is probably due to the extensive documentation of both, the general NetBsd system as well as the specific issues of the mac68k distribution.

I certainly was too lazy to immediately write down everything I did. Anyway, this should not be an exact manual sufficient to clear any detail about installation and configuration of NetBsd, rather the description of my personal experience and also focusing only on the issues of this specific platform most of the time. Many things I had to write down from my memory which can be quite deceptive sometimes...

Moreover, I never intended to make a Linux-like consumer workstation out of the Performa, using KDE and whatever shnick-shnack you can imagine... No, I mean, exactly this was what the machine has been before and from there I wanted it to advance.

However, I certainly hope that this text can be useful for at least some people, e.g. those who accidentally have the same machine and configuration at home and want to evolve a little bit in the same direction. It's a lot of fun.

2. Performa 475 Hardware Profile

More information about the Performa 475 is available at Apple's spec database or at EveryMac.com.

3. Downloading the Files

Although Mac OS 8 in fact runs on the 475, performance, memory usage and stability are beyond being acceptable anymore. System 7.5.3 is freely available from Apple and does a much better job (it is only used to boot the machine and then NetBsd, anyway):
System 7.5.3 (19 parts).

Since one can never be sure of a successful installation of NetBsd, I also downloaded the Network Access Disk from Apple's website to prepare an emergency floppy (a very wise idea as it turned out, later):

Network Access Disk 7.5.

The following files are needed for NetBsd 1.5 / Mac68k (mac68k/binary/sets/):

For installing XWindows another bunch of files is needed: These files are needed to set-up NetBsd from inside Mac OS (mac68k/installation/misc/): Finally, I got some files from the Debian Linux-m68k distribution utilized to partition the hard disk:

4. Preparing the Machine

Due to limitations of the NetBsd installer, I had to use the first 1024MB of the hard disk for the base installation. Ie. the installer failed when trying to access a partition greater than or starting beyond 1024MB.

The installation guides recommend Apple's HD SC Setup tool, patched to recognize non-Apple drivers, for partitioning hard disks. However, it can re-arrange the partitions only by destroying all data on the disk.

I wanted to keep the original Mac OS system files, the application and document data of the Performa (which altogether occipied approximately 1,5GB). And because I did not want to copy the hard disk's contents to another space via ethernet or – even worse –, via AppleTalk (as noted above, there was no external storage device available), I had to find a way to initialize only one partition for NetBsd.

5. Partioning The Hard Disk

Initially, I was trying out the Debian Linux-m68k port – unfortunately without success. But nevertheless, I could use Debian's booter application to quickly utilize a shell and the mac-fdisk command for more comfortable partitioning.

To do this, I set up Penguin, the Debian booter, according to the manual using the Linux kernel (the file called linux) and the ramdisk image (root.bin) included in the Penguin package. The following pictures illustrate all necessary settings:


fig.1: The necessary files in one window.


fig.2: The settings in the Penguin "Kernel" tab.


fig.3: The settings in the Penguin "Options" tab.

Then I invoked the booting process and after the screen was completely filled with system messages, the Debian menu appeared.

I directly chose the option "Alternate: Partition a Hard Disk" because that's what I actually wanted to do.

The menu disappeared and I got a command line shell running mac-fdisk. First, I wanted to take a look at the current partition map, so I typed in p after the prompt and got:

        # type name             length   base      ( size ) system
/dev/sda1 map  Apple                63 @ 1         ( 31.5K) Partition map
/dev/sda2 Dr43 Macintosh            54 @ 64        ( 27.0K) Driver 4.3
/dev/sda3 Dr43 Macintosh            74 @ 118       ( 37.0K) Driver 4.3
/dev/sda4 ???? Patch Partit        512 @ 192       (256.0K) Unknown
/dev/sda5 HFS  Wittgenstein   24462148 @ 704       (  2.1G) HFS
/dev/sda6 HFS  Popper         24462148 @ 244628    (  2.1G) HFS
Due to the 1024MB limitations of the installer, I decided to split up the first HFS partition ("Wittgenstein") into three new partitons: To achieve this the following commands were necessary: Initially, I have had quite a hard time finding the underscore on the keyboard. I am using a german keyboard but the temporary Linux shell cannot handle other layouts than (US-)english ones. So I helped myself with a self-made keyboard comparison chart. This was very useful because also the original NetBsd installation would recognize only english keyboard layouts. but I digress.

The changed partition table was looking like that:

        # type name             length   base      ( size ) system
/dev/sda1 map  Apple                63 @ 1         ( 31.5K) Partition map
/dev/sda2 Dr43 Macintosh            54 @ 64        ( 27.0K) Driver 4.3
/dev/sda3 Dr43 Macintosh            74 @ 118       ( 37.0K) Driver 4.3
/dev/sda4 ???? Patch Partit        512 @ 192       (256.0K) Unknown
/dev/sda5 unix NetBsd Root     1843200 @ 704       (900.0M) Linux native
/dev/sda6 unix NetBsd Swap      131072 @ 1843904   ( 64.0M) Linux native
/dev/sda7 unix NetBsd User     2487871 @ 1974976   (  1.2G) Linux native
/dev/sda8 HFS  Popper         24462148 @ 244628    (  2.1G) HFS
It did not matter that the system entry of the unix partitions were called "Linux native". NetBsd was able to use all three properly.

After I was sure that the partition table is alright, I issued the command w to save the changes. I confirmed with y and the table was written. Then I quit with q and returned to the Debian menu. From there I simply had to reboot selecting the appropriate menu entry.

Now the hard disk was ready to for the Bsd file system...

6. Formatting the Unix Partitions

Running Mac OS again, I opened the "Mkfs" application to format the newly created NetBsd partitions with the Bsd 4.3 file system analogue to the description in the install guide:
  1. I selected the correct SCSI device (id 0)
  2. Chose the NetBsd partition to format
  3. Changed the partition type according to fig.4
  4. Clicked the "Format" button
  5. And repeated the last three steps for each NetBsd partition.
The formatting process took quite a while, but that's 68k...

fig.4: Choosing a NetBsd partition to format.

7. Installing the Base System

After I successfully had written the Bsd file system, I started the "NetBSD/Mac68k Installer" program to install the NetBsd base system onto the root partition:
  1. I again selected the correct SCSI device (id 0)
  2. Issued the "Install" command
  3. Added the package files (fig.5)
  4. Clicked the "Done" button
  5. And went to sleep.
The installation process took a long time. I became quite sceptical whether such an 68k processor was performing well enough to run some NetBsd services. But in the end my doubts were dispelled. Just any installation process is a time consuming task. However, the everyday work with the NetBsd system is fast enough and really fun.

Finally, after all packages have been installed, I let the installer program "Build Devices" choosing the appropriate command from the "File" menu.


fig.5: Adding the base packages for installation.

8. The First Boot

I started the "BSD/Mac68k Booter" application and opened the "Booting Options" dialog from the "Options" menu to enter the kernel and partition name:

fig.6: Boot options in the NetBsd booter application.

And then the magical moment has come: I issued the "Boot Now" command, the booter application printed some final messages in the console window, and the screen turned blank:


fig.7: First messages during the booting process (the full message text is available as text file created via a dmesg dump).

It all ended with the prompt

Enter pathname of shell or RETURN for sh:

Lucky me! Everything worked and after hitting the return key i was in the shell. From here I followed the instructions of the installation guide again. I entered the lines

  1. export TERM=vt100
  2. tset vt100
  3. clear
  4. mount /dev/sd0a
  5. vi /etc/rc.conf
Now I was already editing a file with vi, a quite popular Unix text editor. Well, at least it is popular if you worked with it ever before. And even then I did myself hard in remembering the commands. So i took some advice from this reference of vi commands.

I set the cursor on the "N" of the line rc_configured=NO and typed

  1. x
  2. x
  3. a
  4. YES
  5. "Esc" key
  6. :wq!
  7. reboot
After the first step the "N" disappeared and after the second the "O" was gone. The third step made vi entering "append" mode, so that the fourth step actually wrote the letters "YES" after the equal sign. The fifth step saved the file and quit vi. Finally, the last command was issued from the shell again. And the Performa rebooted again into Mac OS.

9. The Second Boot

I opened the NetBsd booter application again, disabled the "Single User" checkbox in the "Boot" options and started the boot process.

The same system messages appeared on the screen, but this time NetBsd finally displayed the "Login:" prompt. At this time, there is only the "root" user available, so I typed root and hit return twice – no password needed, but I instantly changed this by typing:

  1. passwd
  2. Change local password for root.
  3. New password: newRootPassword
  4. Retype new password: newRootPassword
Then I added a new user "tobi" and configured the network following the appropriate steps in the installation guide:
  1. useradd -m tobi
  2. passwd tobi
  3. Change local password for tobi.
  4. New password: myNewPassword
  5. Retype new password: myNewPassword
  6. vi /etc/group
  7. Placed the cursor on the "t" in the line wheel:*:0:root
  8. a
  9. ,tobi
  10. "Esc" key
  11. :wq!
  12. vi /etc/rc.conf
  13. Placed the cursor on the last character
  14. a
  15. "Return" key
  16. hostname="pizzabox"
  17. domainname=""
  18. defaultroute="192.168.0.2"
  19. "Esc" key
  20. :wq!
  21. vi /etc/resolv.conf
  22. i
  23. domain helma.at
  24. nameserver 192.168.0.2
  25. nameserver 192.168.0.77
  26. lookup file bind
  27. "Esc" key
  28. :wq!
  29. vi /etc/ifconfig.ae0
  30. i
  31. inet 192.168.0.201 netmask 255.255.255.0
  32. "Esc" key
  33. :wq!
  34. vi /etc/inetd.conf
  35. Uncommented the lines starting with #ftp, #telnet, #shell and #login by placing the cursor on the "#" and typing x
  36. "Esc" key
  37. :wq!
I spared myself the part about setting up a router, because the machine works behind a firewall already. However, I know I will have to do it one fine day...

10. Easy Improvements

So here I was, being able to boot into NetBsd, login as "tobi", su to "root" and telnetting or ftp-ing to other machines.

However, I had to cope with the wrong keyboard layout, a hostile vi editor, a shell that bothered me and the internal clock running behind sooner or later.

I wanted to get a colon when typing one, not a bigger sign; I wanted to edit files as I used to do with pico, to use the command-line features available in bash. And I wanted to sync the internal time via the network time protocol.

To my disappointment, I had to give up my first efforts in configuring the keyboard. As it turned out, the NetBsd/mac68k 1.5 distribution does not support the wscons driver. That's why the measures described in section 4.3 of Federico Lupi's short guide did not work with my installation. And as it seems all the other options appeared too difficult to me at that time of my experience with NetBsd. Anyway, I was more lucky with the text editor. I used NetBsd's package collection to download and install pico:

pkg_add ftp://ftp.netbsd.org/pub/NetBSD/packages/1.5/mac68k/editors/pico-4.0.tgz

This was the entire step necessary to do for me, the rest was done by NetBsd. And afterwards I was freed from vi and became a happy pico user.

11. The Bourne Again Shell (bash)

Because the installation of pico went so smooth, I decided to do the same with bash:
pkg_add ftp://ftp.netbsd.org/pub/NetBSD/packages/1.5/mac68k/shells/bash-2.05.tgz

After bash was installed successfully, I added the file .bashrc to my home directory /home/tobi including the following code I got from here:

## If we are not a login shell, source /etc/profile anyway
if [ "$0" != "-bash" ] ; then
    . /etc/profile
fi

## to add someting to your path, do something like the following
export PATH=${PATH}:${HOME}/bin:/usr/sbin:/usr/X11R6/bin

## set a happy editor for programs that want them
export EDITOR='pico'
export VISUAL='pico'

set history=40

## some usefull aliases, so new users don't hurt themselves
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ls='ls -F'
alias ll='ls -alF'

## this is to fool the automounter
cd ${HOME}

## my custom prompt
PS1='\u@\h:\w > '
Finally, I made bash my default shell by issuing chsh tobi and changing the line Shell: /bin/sh to Shell: /usr/pkg/bin/bash. A last time those steps are detailed here for vi, because after the next login pico will be the default editor:
  1. chsh tobi
  2. Placed the cursor after the colon in the line Shell: /bin/sh
  3. xxxxxxx (8 times)
  4. a
  5. /usr/pkg/bin/bash
  6. "Esc" key
  7. :wq!
Then I logged out and in again – et voilà! – my new prompt appeared:
tobi@pizzabox:~ > _

12. Clock Synchronization

To resolve the problem of the Performa's battery powered internal clock running late the longer the machine runs, just two easy steps were needed:

In /etc/rc.local I added the line

/usr/sbin/ntpd.

In /etc/ntp.conf I added

disable auth
server time.euro.apple.com
server swisstime.ethz.ch
server ntp.cesnet.cz

13. Accessing Mac Partitions

It is a pity, but there is no really comfortable way to directly mount hfs-formatted Macintosh partitions from within NetBsd (e.g. by issueing mnt /dev/sd0c /mac).

However, there is a software package called hfsutils that provides a set of special commands to mount, display, modify and transfer data from and to at least one Mac partition.

I installed it, again using the package system:

pkg_add ftp://ftp.netbsd.org/pub/NetBSD/packages/1.5/mac68k/sysutils/hfsutils-3.2.6.tgz
From now on I was able to issue the following commands:
  1. hmount /dev/sd0c 2
  2. hvol
  3. hls
  4. hcd Documents
  5. hdir
  6. hmkdir "New Folder"
  7. hcopy bsdfile.txt :"New Folder:macfile.txt"
  8. hdel :"New Folder:macfile.txt"
  9. hrmdir "New Folder"
  10. humount
This is a simulated procedure to copy a file into a new folder. Certainly, there are even more commands (hformat, hpwd and hrename) and almost all commands have refinements you easily can explore by referring to the man pages.

14. The Secure Shell (ssh)

To make my system at least a little bit more secure and anyway compatible to the other machines in the local network, I enabled ssh, the secure shell.

First of all, I generated the host keys:

  1. /usr/local/bin/ssh-keygen -q -b 1024 -f /etc/ssh_host_key -C '' -N '' > /dev/null
  2. /usr/local/bin/ssh-keygen -q -d -b 1024 -f /etc/ssh_host_dsa_key -C '' -N '' > /dev/null
Then I added the ssh daemon to the system configuration by inserting the line
/usr/sbin/sshd
in rc.local. I also found a script that checks if ssh and the host keys are present, and only then starts sshd:
#
# Start sshd if present.
#
if [ -x /usr/local/sbin/sshd ]; then
# Try to generate missing keys
   if [ -x /usr/local/bin/ssh-keygen -a ! -f /etc/ssh_host_key ]; then
      (echo; echo -n "  (sshd: generating RSA key)...") >/dev/console
      /usr/local/bin/ssh-keygen -q -b 1024 \
         -f /etc/ssh_host_key -C '' -N '' >/dev/null
      chmod 600 /etc/ssh_host_key ; chmod 644 /etc/ssh_host_key.pub
   fi
   if [ -x /usr/local/bin/ssh-keygen -a ! -f /etc/ssh_host_dsa_key ]; then
      (echo; echo -n "  (sshd: generating DSA key)...") >/dev/console
      /usr/local/bin/ssh-keygen -q -d -b 1024 \
         -f /etc/ssh_host_dsa_key -C '' -N '' >/dev/null
      chmod 600 /etc/ssh_host_dsa_key ; chmod 644 /etc/ssh_host_dsa_key.pub
   fi
# No keys - then no startup.
   if [ -f /etc/ssh_host_key -o -f /etc/ssh_host_dsa_key ]; then
      /usr/local/sbin/sshd & echo -n " sshd"	>/dev/console
   fi
fi

15. Installing XWindows

Excited by the ease and smoothness any installation was carried out, I felt the need for some jeopardy: would it be possible to run XWindows on this machine?

I rebooted the Performa into Mac OS, started the installer application and simply added all the XWindows files for installation:


fig.8: Adding the XWindows packages for installation.
I went to sleep once more, and the next day the installation completed. Then I just issued startx and to my surprise I quickly was displayed three terminal windows and the legendary Unix clock!

The mouse worked like a charm, the only disadvantage was the lack of two more mouse buttons, but who cares?

This day I tried out different settings for the window sizes and positions but soon noticed that system messages would always appear on top of all windows, being printed over the whole screen.

I found some advice as possible solutions for this problem. However, none of them should turn out to be working with this NetBsd installation. The only hope left is a customized kernel which means compiling it – and I am still not sure if me punce should dare that...

Anyway, at least I was proven that it's possible to use XWindows on the Performa 475. That it is actually not usable right now, is a minor misfortune I can live with. Especiall, since I can conntect via secure shell from a machine that has all the graphical user interface I need (and the keyboard layout suits much better, too).

16. What's Missing

In the meantime, step-by-step, I installed the following packages: Except php (which I don't get configured to work with Apache httpd), all work fine and perform acceptably respecting the machine speed.

Apache bravely is returning web documents, sometimes using Perl or Rebol for cgi processing and MySql is serving a test database used by a helma installation on another machine.

I also additionally configured different other services, e.g. the cron daemon using crontab to schedule a set of scripts that generate the list of recently updated websites at popo.at.

However, I wanted to spare me detailed descriptions of how I did all this because with NetBsd's package system is is a child's play at least to install the software.

The configuration of Apache or MySql might be more difficult, but if the official manual should not be sufficient, there is a whole bunch of third-party guides available online.

17. What's Next

Since I still did not resolve the issue with the keyboard layout and there's also that ugly console message running across the whole screen in XWindows, I tax my brain whether I should dare to compile a kernel myself one day...

Will be a close shave between "never change a running system" and being annoyed by blind-typing and the mistakes that occur in doing so. XWindows isn't that important to me, anyway.

I probably will throw out the full Mac OS 7.5.3 installation and replace it with Erik Winkler's minisystem 7.1 – given that the Performa will run it.

It's certainly a challenge to make the system more secure, configure a firewall etc., as well as simply trying to learn as much about Unix administration. If I should ever bomb the system, it won't be a desaster. It's a cool little machine for practising Unix.

18. References


This document was last edited on Sunday, 19 August 2001 by Tobi Schäfer.