Running NetBSD on IBM ThinkPad 380Z

Launched in 1998, the 380Z was one very fine ThinkPad. It was the last ThinkPad to come in the classic bulky and rectangular form factor. It was also one of the first to feature a huge 13.3" TFT display, powerful 233MHz Pentium II, and whopping 160 megs of RAM.

I recently stumbled upon one in perfect condition on eBay, and immediately thought it'd be a cool vintage gadget to put on the desk. I only wondered if I could still use it for some slow-paced, distraction-free coding, using reasonably modern software.

I evaluated a bunch of contemporary operating systems, including different variants of BSD and Linux. Usually, the experience was underwhelming in terms of performance, hardware support and stability. Well... except for NetBSD, which gave me such perfectly smooth ride, that I thought it was worth sharing.

ThinkPad 380Z booting NetBSD

Upgrading hard drive

First things first, to improve performance, I've replaced the original HDD with a 16GB mSATA. The 380Z comes with a standard 44-pin PATA interface, so I plugged it in through a generic mSATA-to-PATA adapter. It works almost seamlessly.

The only issue is that on the 380Z, the BIOS-reported disk size is limited to 8GB. It doesn't matter to operating systems, but it can be a problem for bootloaders using BIOS to look for their files. Some of them refuse to work right away from a partition that exceeds this limit.

The one in NetBSD happened to work initially, but would likely break later on, if its files ever got written on the disk beyond the first 8GB. To stay on the safe side, I used a smaller root partition and put /home on a separate one.

Connecting to network

The 380Z doesn't have a built-in network card. Fortunately it has both CardBus and USB slots, so there are plenty of options.

One that worked for me was Edimax EW-7108PCg — a WiFi CardBus card based on a RT2561S chipset. Another one was a generic no-name USB-to-LAN adapter based on RTL8153.

Booting the installer

Despite having a USB port, the 380Z doesn't support USB boot. My CD drive was also erratic and practically unusable - a common issue in vintage laptops. Fortunately, the 380Z supports yet another, rather unusual boot option — using a CardBus disk.

So I grabbed the NetBSD-10.0-i386-install.img image and wrote to a Compact Flash card. Then, plugged it in using a generic CF-to-CardBus adapter, and off it went. For NetBSD, booting from CardBus is business as usual, no questions asked.

To be fair, with other systems it's also doable, but usually requires some tinkering to mount the root filesystem.

Installation

NetBSD comes with a lightweight, friendly, text-mode installer. Step by step, it guides you through setting the keyboard layout, partitioning, selecting distribution sets, setting up the network, timezone, root shell and password, enabling the package manager, choosing optional daemons, and adding a user account.

Unless you go for automatic full-disk mode, the trickiest part may be partitioning, since NetBSD uses its own custom scheme on top of MBR partitions. Fortunately, the whole process is well documented.

In my case, when prompted for distribution sets, I selected "custom installation", and selected all sets except for source and debug ones. The resulting installation took about 1.6GB of disk space, and included the entire X11 environment.

NetBSD installer

Enabling framebuffer

NetBSD supports VESA console framebuffer, though it's not enabled by default, and not particularly advertised in the docs. Turning it on is as simple as adding vesa on; vesa 1024x768; commands to a menu item in /boot.cfg.

By the way, it's too bad that NetBSD's console doesn't support unicode, so it's not very usable without X. I think this could be a killer feature for hardware with even less RAM.

Saving RAM

Even NetBSD comes with some bloatware ;-) To save as much RAM as possible, you can turn it off by adding to /etc/rc.conf:

inetd=NO
postfix=NO
cron=NO
virecover=NO
makemandb=NO
powerd=NO
syslogd=NO

You can also reduce the amount of consoles by commenting them out in /etc/ttys.

After reboot, you'll have a pretty clean slate:

t380z# ps auxc
USER PID %CPU %MEM   VSZ   RSS TTY   STAT STARTED    TIME COMMAND
root   0  0.0 18.6     0 30300 ?     DKl   3:45PM 0:00.08 system
root   1  0.0  0.9  5836  1504 ?     Ss    3:45PM 0:00.08 init
root 345  0.0  2.0 12724  3292 ?     Ss    3:45PM 0:00.09 wpa_supplicant
root 707  0.0  1.0  6104  1544 ttyE0 O+    3:45PM 0:00.03 ps
root 711  0.0  3.1 12848  4988 ttyE0 Ss    3:45PM 0:00.54 login
root 712  0.0  1.4  6576  2216 ttyE0 S     3:45PM 0:00.24 sh
root 709  0.0  1.0  5744  1556 ttyE1 Ss+   3:45PM 0:00.03 getty

t380z# cat /proc/meminfo
        total:    used:    free:  shared: buffers: cached:
Mem:  139943936 32768000 107175936        0  8208384 18546688
Swap: 167759872        0 167759872
MemTotal:    136664 kB
MemFree:     104664 kB
MemShared:        0 kB
Buffers:     104664 kB
Cached:       18112 kB
SwapTotal:   163828 kB
SwapFree:    163828 kB

WireGuard

In case you'd like to use WireGuard, NetBSD's got you covered. It supports it out of the box, with no extra dependencies. The entire documentation is a single man page and it's very straighforward. However, it only shows commands to manually execute, there's no dedicated config file. To make your setup persistent, you can simply add it to /etc/rc.local:

echo -n 'Setting up wireguard: '

ifconfig wg0 create
ifconfig wg0 inet [ip/prefix]
wgconfig wg0 set private-key /etc/wg/key
wgconfig wg0 add peer [peer-name] \
        [public-key]
        --allowed-ips=[ip/prefix] \
        --endpoint=[endpoint]
ifconfig wg0 up

echo 'done.'

Setting locale

The default locale in NetBSD is C. The installer doesn't prompt you to change it, and there isn't any dedicated config file. Instead, you need to set it manually, for example in /etc/profile or ~/.profile:

export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LC_COLLATE=en_US.UTF-8

The X server

The GPU on 380Z is a NeoMagic MagicMedia 256AV and it has a dedicated driver in Xorg, called neomagic. However, only in NetBSD it worked out of the box without any tinkering, just by running startx. On other systems I tried, it required some adjustments or even resorting to plain VESA/FB drivers.

Window manager

The default desktop environment of NetBSD, as included in the basesystem, consists of CTWM, XClock and XTerm. It looks like this. It's as minimal as it gets, it's not too ugly, and it's somewhat usable.

I tried it for a bit, but couldn't get to like CTWM. Instead I've replaced it with EMWM (Enhanced Motif Window Manager), which is similarly lightweight.

NetBSD running EMWM

Terminal emulator

I haven't found a terminal with a smaller memory footprint than XTerm. Even urxvt or st were larger. However, for me XTerm is actually good enough, so I didn't spent much time looking for alternatives. I only adjusted some colors, changed the font to Terminus, and added shortcuts for copy-pasting:

XTerm*VT100.background: black
XTerm*VT100.foreground: grey90
XTerm*VT100.faceName: Terminus
XTerm*VT100.faceSize: 12
XTerm*VT100.allowBoldFonts: false
XTerm*VT100.translations: #override \
      Ctrl Shift V:    insert-selection(CLIPBOARD) \n\
      Ctrl Shift C:    copy-selection(CLIPBOARD)

The shell

In the basesystem, NetBSD comes with sh, csh and ksh. I've never bothered learning csh, but sh is fine for basic administrative tasks, and ksh is somewhere in between sh and bash in terms of functionality. I tried using ksh for a while but I kept missing features. Eventually I gave up on it and installed bash from packages.

Browsing web

The most reasonable web browser for the 380Z is Dillo. It lacks support for JavaScript and modern CSS layouts, so many pages render all over the place, but it's still useful for reading docs and static pages. To my surprise, Google seems to work, and doesn't block it with captcha.

One could argue Dillo is exactly what a web browser is supposed to be — a productivity tool for browsing nicely-formatted hypertext documents. I only wish I had some time to contribute to its development. Well, maybe when I retire...

NetBSD running Dillo browser

Playing music

NetBSD was the only system I tried that properly supported the built-in Crystal CS4237B soundcard. In fact, it detected it twice, with two different drivers, wss and sb. Unfortunately this caused a conflict and they both emited garbage noise. I was able to fix it by adding userconf disable wss to the bootloader line.

The most viable player is mpg123. It manages to play an online low-fi radio stream with only slight stuttering when other CPU-heavy tasks are running. Itself it seems to take around 10-20% of the CPU time. The audio quality of the soundcard is also just adequate for low-fi music, so for sure it won't be too distracting.

Once set up, what's it good for?

The 380Z has a very comfortable, high-profile, classic ThinkPad keyboard, as well as a crispy 4:3 display. It's not as snappy as your latest MacBook, but it's fine for many terminal-based tasks, for example:

Final thoughts on NetBSD

NetBSD is a lightweight, compact, finely engineered system. It doesn't get as much attention as its BSD cousins, not to mention Linux, but I just cannot overstate how pleasant it is to use.

It doesn't overwhelm you with thousands of packages and dozens of boot services right in a fresh install. On the contrary, it does only what you tell it to do. It puts you in charge and makes you feel like you can understand it top to bottom.

It happily boots on a 25-year old machine, like you moved back in time, but still provides you with a full repository of the latest software.

It may not be mainstream enough for a daily driver, but I think it's the ultimate UNIX to put on a spare, underpowered machine.

~luke, 2024-12-16