Reviving a Raspberry Pi with NetBSD

I started getting into BSDs (specifically NetBSD) as a result of my membership in SDF. I have a good deal of Linux experience but hadn't really had a good reason to try out one of the BSD operating systems. I remembered I had a first-gen Raspberry Pi (Model B) languishing in my desk drawer and decided to put NetBSD's slogan (“Of course it runs NetBSD!“) to the test.

The Model B features a 32-bit armv6 chip and 256MB of RAM (!). I poked around on the NetBSD homepage and found this page which told me “earmv6hf” was the NetBSD port I wanted for an rpi 1.

This article on does a fantastic job of showing the initial steps to get it running, and I won't attempt to reproduce those here. Instead, I want to fill in some gaps.


So you've followed the article above and you're sitting at a root prompt with your Pi hooked up to a TV and a keyboard plugged into one of the two USB ports. Now, you want to be able to use the Pi as a “server” and stash it somewhere. Unfortunately, Pis this old don't have onboard WiFi, so you'll need an adapter. This is one area where NetBSD is a bit rough around the edges: the WiFi adapter support isn't as strong as some Linux distributions. Even if your Pi has onboard WiFi, it is unlikely that NetBSD supports it.

I used this adapter and I know that it works out of the box with NetBSD 8.0. If that Amazon link ever dies, the adapter is the Edimax EW-7811Un. Be aware that this adapter does not have dual-band support, so you'll have to stick with 802.11n. This means you can't use the 5GHz band of your router.

Once you have the adapter, shut down the pi at the root prompt with shutdown -p now. You'll eventually see a message saying “press any key to restart”. Once you see this, unplug the Pi. Now, plug in the Edimax adapter to the empty USB port and reconnect the Pi. When you're back at your root prompt, follow the instructions here to set up wpasupplicant, which is the NetBSD daemon that handles WPA/WPA2. I was able to copy/paste the “simple” example from the wpasupplicant page:

        ssid="my favourite network"

I replaced the ssid and psk with my network's info. The tutorial tells you to edit /etc/rc.conf and add the following lines:

wpa_supplicant_flags="-i iwn0 -c /etc/wpa_supplicant.conf"

iwn0 is a network interface - find yours by typing ifconfig and looking for interface name whose address starts with 74:da:38 (provided you're using my recommended adapter). Mine is urtwn0, so I replaced iwn0 in the above command with urtwn0. Now you should be able to find the Pi on your network and SSH into it - no need for the TV anymore!

bash issues

After enabling bash as my shell per the guide, I found that some things were not on my $PATH by default. I loaded a custom .bashrc file to get my normal aliases, and found that “pkgadd” was no longer on the PATH. Also, it seems that no .bashprofile is created by default in your user's home directory. To fix both these issues, add the below lines to the newly-created ~/.bash_profile:


source .bashrc


The guide talks about pkgsrc, which allows for the installation of both binary and source packages for NetBSD. If you're coming from Linux though, you're probably expecting something that works like yum or apt. pkgsrc does not work this way and crucially, it doesn't have a great story for updates. Pkgin is what you're looking for here. Run pkg_add -v pkgin as root and then follow the guides on the pkgin homepage from there. Pkgin uses pkgsrc under the hood. Remember that your old Pi 1 is very underpowered, so expect package installations to take a while.

After you've installed pkgin, there will be a message telling you to run pkgin update. Before you do this, check the file in /usr/pkg/etc/pkgin/repositories.conf. The url in there was wrong by default on my installation. For an rpi 1, it should be Once that's correct, run pkgin update.

Assorted gotchas

Go forth!

Now you can install the packages you're used to, like vim, git, etc. Happy hacking!


I hope you've enjoyed this post. Hit me up on Mastodon with any questions or comments!