mercredi 19 octobre 2011

NetBSD on a Macintosh 68k computer

An Apple fanboy, that's what I used to be. The first computer I talked to was an Apple II, a funny little machine with a colorful logo and a plenty of addicting games, like Little Brick Out or Lemonade. Later, when I discovered the graphical interface and the All-in-one casing of the Mac Classic, I went crazy about it. When I could afford a computer, in 1995, it couldn't be anything but a Mac. I was grateful for Apple to have turned computers into machines that are simple and pleasant to use, even by non-computer scientists.

Frustration followed a perfect honeymoon. Years passed and I realized that new exciting software won't run on a Motorola 68k processor, with less than 36 MB, on a system prior to 9 or X. I maxed out the hardware : 68040 with a real FPU, 36 MB of RAM, a 40 GB disk (limited with jumpers at 32 GB), a new silent fan. My Performa 630 should have deserved its name, but instead I hardly slowed its programed obsolescence. Stuck in the past, with an eternally buggy System 7.5.5, a browser illiterate of today's web and SSL certificates that expired last century, my computer should have died. Was the charm too strong ? Instead of buying a newer Mac, I stayed faithful to my first one and kept it sitting on my desk, beside the less attractive and more useful PC. But, one day...

Reversing programmed obsolescence

Years ago, I heard about NetBSD. This Unix-like system is a free software, free as in free speech and free beer. If you want to help developers keep on going, you can give some money or hardware to the NetBSD foundation. It is not an all-graphic system ala MacOS. The graphical interface is optional and rather rough on the edges on this platform. Command-line and text file editing are the Unix way to go. In the early 2000, the install process was rather challenging, and didn't work on my internal IDE drive. But last week I gave the new NetBSD 5.1 version a try. This system software supports a variety of hardware starting from the mini-computer of the eighties (VAX), to Macintosh of all generations, Amigas, Alpha and Sun machines as well as recent 64 bits PC's. How can they achieve that ? NetBSD people claim they made a clean design, with very little machine specific code. Some years ago, I had a discussion with one of them, Emmanuel Dreyfus. He told me that about 2% of the code base is tied to a particular piece of electronic. This means that even drivers are mostly generic and shared amongst different type of machines. Thus, improvements brought to the code benefit all supported hardware, even the oldest.

Installing NetBSD

Given the modest power of a 1995 machine by today's standard, the best I hoped was to turn mine into a simple but decent FTP server to backup a single laptop on a home network. An IPv6 address would also be useful to reach it from outside home, through a secure SSH connection. But, before I could enjoy a modern setup on my vintage Mac, I had to install NetBSD.

The process is now called Sysinst. It boots a minimal version of NetBSD from a file on the Mac disk and prompts the user through different steps. Disk partitions, choice and download of software sets, preliminary configuration is piece of cake for anyone who has carefully read the fine netBSD guide. For the advanced configuration, rc.conf fine tuning, user creation, I had to mount first the newly created partitions under /mnt (mount /dev/wd0g /mnt/usr, et coetera) and then change root (chroot /mnt). I feel there is room for improvement here.

Some bugs in NetBSD install

When I tried to configure wsconsctl -w -k encoding=fr, to use my french keyboard, I got a wskbd device not configured message. After some search in the dmesg log, I found that only wskbd0 was configured. Linking wskbd with wskbd0 (ln -s /dev/wskbd0 /dev/wskbd) was probably a dirty hack, but at least, it worked. Pain wasn't to an end, though.

At reboot, it all went awry. The GENERIC kernel crashed consistently at exactly the same point in the boot process (setting tty's). How to get out of this ? The solution would be to build a new kernel, possibly trimmed down, and give different options to the compiler in hope that the faulty code doesn't make its way into the kernel. The compiler is the piece of software that outputs a machine executable from the source, human readable code. And to build a mac kernel you need a mac compiler that runs normally on NetBSD mac68k. But what if it can't even boot ?

Cross-compile NetBSD kernel

NetBSD allows to build a compiler for any target on any platform. I installed an other NetBSD on my amd64 PC to compile a mac68k compiler to build a mac68k kernel. As the INSTALL kernel worked, I took its config file as a start. After some try and many errors, I ended up with a working kernel on my Macintosh. The important option to include in the config file was:

makeoptions COPTS="-Os" # Optimise for space. Implies -O2

NetBSD on Macintosh is Insanely great !

Now, my Macintosh is useful again with its 21 GB free disk space and 480 KB/s network transfers. On Mac OS 7.5.5, they were ceiling at 150 KB/s. It's got a very well-tested IPv6 stack, full featured FTP and SSH servers and the best firewall to date, Packet Filter. I also installed Links, a console web browser, that displays today's web sites in a blink of an eye (but only the text). There are many programs available on NetBSD repositories that I'm eager to try.
The system seems to be faster, more responsive than with NetBSD 1.6, and it doesn't need more memory (about 17 MB). Usually newer software with more features downgrades your hardware, makes it actually slower.

At last.

I'm still an admirer of the elegant lines of Apple products and their well designed casing. But I value durability even more. Both come together with old Apple hardware and current high-end workstations. But on some laptops you can't even replace batteries. Portable devices are even worse: you are not supposed to install a software not made or approved by the Firm. Should it pull the plug, your shiny little gadget would quickly turn into a useless piece of crap. These expendable products should be avoided, if you don't want to feed the big dump and are not ready to cut you a path through the installation of a free system.

NetBSD on Macintosh 68k

1 commentaire:

  1. In 2007, I installed a Debian Linux on a G4 Macintosh (384 MB RAM, 750Mhz PPC processor), way easier than NetBSD sysinst. It replaced the crappy old System 9 and obsolete IE browser with a state of the art Unix system, nice graphical interface and the last version of the Firefox web browser.