stocksy.co.uk
"the site for those who crave disappointment"

Sponsored Links

NetBSD on my Mac LC 475

21st Mar 2006, 17:29:41

By James Stocks

Why? Well, I tried Debian, but it was just too slow on the old Mac. The newest kernel I could get to run reliably was 2.2.25. 2.6 is available, but was too unstable for me to use. No disrespect intended to the guys who work on the 68k port, but there were too many niggly issues (hwclock!) and I just don't have vast tracts of time to devote to this. It's supposed to be fun!

NetBSD on the other hand is fast on this little Mac.

As far as installation is concerned, I pretty much just followed this Guide to installing NetBSD, but I wanted to have all my notes in one place, hence I wrote this.

Requirements:

*I replaced my LC's unsupported 68LC040 with a full '040

Installing

Firstly, you'll want to partition your hard disk if you've not done so already. I have a non-apple SCSI drive, so I used a patched version of HDSC Setup on a bootable system 7 floppy. It is worth noting that the NetBSD files themselves (temporarily) take up 50 MB on the Mac partition. I took 150 MB for the Mac Partition, 50 MB for NetBSD swap and the rest for NetBSD root&usr .

I now had a blank hard disk, so I had to reinstall (as a minimum) 7.5.3, 7.5.5 updates, OpenTransport, Stuffit Expander and iCab. I used iCab to download the following:

Place these in a folder called 'Mac':

Place these in a folder called 'BSD':

Extract the Mac files but do not extract the BSD *.tgz files, this will happen automatically during the install.

Run the Mkfs program you extracted placed in the Mac folder and select the SCSI disk you partitioned.

Select the Root&usr partition and 'CHANGE' it to NetBSD Root & usr, then select the Swap partition and Change it to NetBSD Swap. Click each patition and 'FORMAT' them in turn - this takes a while. Click DONE to exit.

It's time to install, start the 'NetBSD/Mac68k Installer' program and choose your SCSI disk. Click File -> Install, then Add all of the .tgz files you placed in the BSD folder and then click 'done'.

Go to sleep, wash the cars, cook and eat Sunday lunch or whatever at this point, because this took hours on my LC. When the install Finally completes, choose File -> Build Devices and then quit the installer.

Run the BSD/Mac68k Booter. Choose Options -> Booting and tick 'Single User'

Click OK and choose Options -> Boot Now (cmd+b). If NetBSD boots, rejoice! If not, and you get an error regarding reading the filesystem here's that bad news: You need to start over from the Mkfs point and reinstall substituting kern-GENERIC.tgz for kern-GENERICSBC.tgz. Otherwise, lets continue.

Choose sh for the shell when prompted. Type:

export TERM=vt100
tset vt100
clear
mount /dev/sd0a

Mounting might complain that the file system is dirty - don't worry, this gets taken care of. Now vi /etc/rc.conf and make these changes:

# Use program=YES to enable program, NO to disable it. program_flags are
# passed to the program on the command line.
#
sshd=yes
#JS: This enables you to log in through ssh

# Load the defaults in from /etc/defaults/rc.conf (if it's readable).
# These can be overridden below.
#
if [ -r /etc/defaults/rc.conf ]; then
. /etc/defaults/rc.conf
fi

# If this is not set to YES, the system will drop into single-user mode.
rc_configured=YES

# Add local overrides below
# JS: The host/domain name are for you to choose. The default route is your
# gateway or router.
hostname="lc475"
domainname="local"
defaultroute="172.16.0.1"

Save the file and that's it, reboot by typing, err... reboot

Your Mac boots the Mac OS again, so load the NetBSD booter once more. Boot as before, but this time don't set single user mode (just hit cmd+b to boot). The Mac will pause for a looong time while generating the SSH keys - this made me chuckle, since it takes the blink of an eye on a modern PowerPC or x86.

Log in as root. Right away, set a password for root by typing:

passwd

Now create a user for yourself (not stocksy!):

useradd -m stocksy
passwd stocksy

Add yourself to the wheel group by doing vi /etc/group. Add your name to the first line so it looks like:

wheel:*:0:root,stocksy

Type exit and log in as yourself. Now use type su to get root access again.

To set up networking, you need to know what type of card you have. Type dmesg | grep -i ethernet, it will return something like:

ae0 at nubus0 slot e: EtherNet card, 16KB memory
ae0: Ethernet address 00:a0:4b:07:fd:64

We are interested in the first part of each line, in this case ae0. Create a file accordingly, e.g. vi /etc/ifconfig.ae0 and in it, specify your network settings:

inet 172.16.0.82 netmask 255.255.255.0

Those of you who have been paying attention will note that we haven't entered any nameserver addresses. Lets do that now by typing vi /etc/resolv.conf

domain local
nameserver 172.16.0.80
nameserver 172.16.0.81
lookup file bind

Enter as many nameservers as you (or your ISP) have. Set the domain to whatever you like, but do keep the lookup order as shown.

Save the file, reboot into Mac OS and boot NetBSD again. Try pinging/sshing to your Mac, if you can't, go back over the steps and see if you missed somthing.

I hate the csh/ksh shells that BSDs have and want to install bash right away. Lets do that.

pkg_add ftp://ftp.netbsd.org/pub/NetBSD/packages/1.6.2/m68k/All/bash-2.05.2.7nb1.tgz

Note: there are loads of packages you can install in ftp://ftp.netbsd.org/pub/NetBSD/packages/1.6.2/m68k/All/ - take a look.

Use chsh to set your shell to /usr/pkg/bin/bash. Do not set root's shell to bash with chsh, instead add the line /usr/pkg/bin/bash to the end of /root/.cshrc. In truth, it won't matter for this setup, but it is bad practice to use a 'fancy' shell for BSD root accounts since /usr could be on a separate (umountable) partition so that you can't get a shell in single user mode. It's also really easy to fat finger it and leave yourself unable to log in as (or su to) root!

Do Stuff

I hate faffing about with the default ftp client, so the first thing I did was get curl from curl.haxx.se. You'll either need to find an ftp mirror for this or download and scp it to the Mac. This compiled and installed fine:

tar zxf curl*
rm curl*.gz
cd curl*
su
./configure && make && make install

Now I can just retreive stuff with curl -O http://your.url/file.tar.gz

Because I am used to using sudo rather than su-ing to root, I wanted to install this. There's no m68k binary for it, so I had to build it. First I retreived the source by invoking

curl -O http://www.courtesan.com/sudo/dist/sudo-1.6.8p12.tar.gz

For me, sudo compiled without any trouble.

A BAPP Server (BSD, Apache, PostgreSQL, PHP)

I wanted to have Apache with PHP and a database back-end, just because it seemed like a cool thing to do with a 12 year old computer.

I thought I'd tackle Apache first, I knew it would be the easiest!

curl -O http://mirror.digital-fortress.co.uk/apache/httpd/httpd-2.2.0.tar.gz
tar zxf httpd-2.2.0.tar.gz
cd httpd-2.2.0
./configure --enable-modules=most --enable-shared=max --enable-ssl --enable-deflate --enable-headers --enable-proxy --disable-dav
make
sudo make install

sudo /usr/local/apache2/bin/apachectl start should start apache OK. httpd.conf is in /usr/local/apache2/conf

Initially, I tried to compile MySQL, but it wanted too many dependencies and I couldn't be bothered with it, so I thought this would be a good excuse to learn Postgres. PostgreSQL had just one dependency, gmake:

curl -O http://ftp.gnu.org/pub/gnu/make/make-3.80.tar.gz
tar zxf make-3.8.0.tar.gz
cd make-3.80
./configure
make
sudo make install

Postgres took ages to compile, but it went smoothly

curl -O ftp://ftp8.uk.postgresql.org/sites/ftp.postgresql.org/source/v8.1.3/postgresql-8.1.3.tar.gz
tar zxf postgresql-8.1.3.tar.gz
cd postgresql-8.1.3
./configure
gmake
sudo gmake install

After installation, there is a little configuration to do:

sudo -s
adduser -m postgres postgres
mkdir /usr/local/pgsql/data
chown /usr/local/pgsql/data postgres
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >logfile 2>&1 &
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test
\q

Before PHP will build, we need some tools and libraries first. m4 bison flex

m4:

curl -O http://ftp.gnu.org/pub/gnu/m4/m4-1.4.4.tar.gz
tar zxf m4-1.4.4.tar.gz
cd m4-1.4.4
./configure
make
sudo make install

bison:

curl -O http://ftp.gnu.org/pub/gnu/bison/bison-2.1.tar.gz
tar zxf bison-2.1.tar.gz
cd m4-1.4.4
./configure
make
sudo make install

flex:

curl -O http://ftp.gnu.org/pub/gnu/non-gnu/flex/flex-2.5.4a.tar.gz
tar zxf flex-2.5.4a.tar.gz
cd flex-2.5.4a
./configure
make
sudo make install

Also, we need perl for apxs.

curl -O ftp://ftp.cpan.org/pub/CPAN/src/perl-5.8.7.tar.gz
tar zxf perl-5.8.7.tar.gz
cd perl*
./configure
make
make test
make install

libxml next. It takes a long time!

curl -O http://xmlsoft.org/sources/libxml2-2.6.23.tar.gz
tar zxf libxml2-2.6.63.tar.gz
cd libxml2-2.6.63
./configure
make
sudo make install

Finally PHP itself:

curl -O  http://uk.php.net/distributions/php-5.1.2.tar.gz
tar zxf php-5.1.2.tar.gz
cd php-5.1.2
./configure --with-xml --with-zlib --with-pgsql=/usr/local/pgsql --with-apxs2=/usr/local/apache2/bin/apxs
make
sudo make install

New Comments

Some Rights Reserved