NetBSD on the Raspberry Pi

Frederic Cambus September 25, 2014 [NetBSD] [ARM]

Last spring, I finally caved in and ordered a Raspberry Pi. In fact, I had a very precise reason to do so: it makes a nice and affordable little board to run NetBSD natively.

Before starting, I recommend using a Class 10 SDHC Card as it will make the whole process of using pkgsrc faster.

Creating the SD card

As the Rapberry Pi port is still not part of the stable release, we will have to run NetBSD-current. Pre-built images can be downloaded here.

Let's fetch an image, and create the bootable media:

UPDATE: Now that images are being built for evbarm-earmv6hf, please use these instead of evbarm-earmhf ones.

wget http://nyftp.netbsd.org/pub/NetBSD-daily/HEAD/201404231000Z/evbarm-earmhf/binary/gzimg/rpi.img.gz
gunzip rpi.img.gz
dd if=rpi.img of=/dev/da0 bs=4M

I used FreeBSD to create the SD card, so please set the output file accordingly when using other systems.

Booting

Switch the Raspberry Pi on and login as root, there is no password by default.

We can run uname -a to get more details about the build:

NetBSD rpi 6.99.40 NetBSD 6.99.40 (RPI) #1: Wed Apr 23 12:06:29 UTC 2014  builds@b8.netbsd.org:/home/builds/ab/HEAD/evbarm-earmhf/201404231000Z-obj/home/builds/ab/HEAD/src/sys/arch/evbarm/compile/RPI evbarm

And here is /etc/motd customized with my NetBSD ASCII logo:

NetBSD 6.99.40 (RPI) #1: Wed Apr 23 12:06:29 UTC 2014

                  ________    _____
       _____     /       /   /    /___  _ _
    __|     \  _/    ___/ / /        /     |                 _ __
   /         \       \     /      __/     _|_______       ______/_
  /          /       /___ /      /____  \ \        \     /     / / _____
 /     :     \     _/    /     _/    /   \ \____    \   /     __/ /     |__
/      |      \          \           \  _ _    /    /___\     \__/         \
\      |       \  __      \____       \/      /    /     \       \     .    \
 \___ _|       / __/______/ __/_______/     __\    \      \      /     |     \
  \__  |______/    \_____/    \______/\    |        \    _/     /     __\     \
     |_|_____/                         \___|        /           \    |         \
       |                                \__|_______/______  Cl!  \___|         /
       |     Welcome to NetBSD/evbarm      | _____/ \____/_______/_  | _ _____/
       |                                   |             \______/  |_|______/
       |___ __   _______ _   _ ___ _ __  __|


This system is running a development snapshot of the NetBSD operating system,
also known as NetBSD-current.  It is very possible that it has serious bugs,
regressions, broken features or other problems.  Please bear this in mind
and use the system with care.

You are encouraged to test this version as thoroughly as possible.  Should you
encounter any problem, please report it back to the development team using the
send-pr(1) utility (requires a working MTA).  If yours is not properly set up,
use the web interface at: http://www.NetBSD.org/support/send-pr.html

Thank you for helping us test and improve NetBSD.

Add a password:

passwd

Add a regular user in the wheel group:

useradd -m -G wheel username

Add a password to the newly created user:

passwd username

Growing the root file-system

As the NetBSD image written to the SD card has a fixed size, we will need to resize the file system to span the whole card.

The NetBSD Wiki has the required steps listed here: NetBSD/evbarm on Raspberry Pi.

UPDATE: Since April 2015, the partition is automatically resized during first boot.

Keeping time synchronized

As the Raspberry Pi does not include a hardware clock on board, we will need to use NTP to keep the time synchronized.

Setting time zone:

ln -fs /usr/share/zoneinfo/Europe/Warsaw /etc/localtime

After adding the ntpdate directive in rc.conf:

echo "ntpdate=YES" >> /etc/rc.conf

We can start ntpdate manually:

/etc/rc.d/ntpdate start

Using pkgsrc

To fetch and unpack the pkgsrc current branch, run:

ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
tar xfz pkgsrc.tar.gz -C /usr

We can now start building:

echo "ACCEPTABLE_LICENSES+= vim-license" >> /etc/mk.conf

for package in chat/irssi editors/vim misc/screen misc/tmux net/nload net/mtr net/unbound net/wget shells/zsh sysutils/mc sysutils/pv www/curl www/links www/lynx www/nginx ; do
	cd /usr/pkgsrc/$package
	make install package clean clean-depends
done

Specifying the package option when invoking make will create a binary package in /usr/pkgsrc/packages/All. As compiling can take a long time on the Pi, this is especially handy when doing reinstalls or using multiple boards.

Here is the list of packages which have been created:

ls -l /usr/pkgsrc/packages/All
total 94284
-rw-r--r--  2 root  wheel    909780 Apr 24 06:18 autoconf-2.69nb4.tgz
-rw-r--r--  2 root  wheel    125681 Apr 25 00:44 bsdtar-2.8.4nb1.tgz
-rw-r--r--  1 root  wheel    760030 Apr 24 15:39 curl-7.36.0.tgz
-rw-r--r--  2 root  wheel   7141904 Apr 24 09:53 glib2-2.38.2.tgz
-rw-r--r--  2 root  wheel    512926 Apr 24 02:04 gmake-4.0.tgz
-rw-r--r--  2 root  wheel     85486 Apr 24 05:56 help2man-1.45.1.tgz
-rw-r--r--  2 root  wheel     43185 Apr 25 00:29 intltool-0.50.2nb2.tgz
-rw-r--r--  1 root  wheel    507486 Apr 24 10:21 irssi-0.8.15nb9.tgz
-rw-r--r--  1 root  wheel    442189 Apr 24 19:30 ldns-1.6.16nb3.tgz
-rw-r--r--  2 root  wheel     93192 Apr 24 06:28 libelf-0.8.13.tgz
-rw-r--r--  2 root  wheel    642068 Apr 24 18:29 libevent-2.0.21nb3.tgz
-rw-r--r--  2 root  wheel     43643 Apr 24 07:12 libffi-3.0.13.tgz
-rw-r--r--  2 root  wheel    257832 Apr 24 11:24 libidn-1.28.tgz
-rw-r--r--  2 root  wheel   1229536 Apr 24 13:41 libslang2-2.2.4nb2.tgz
-rw-r--r--  2 root  wheel    468947 Apr 24 01:11 libtool-base-2.4.2nb6.tgz
-rw-r--r--  1 root  wheel    451896 Apr 24 21:18 links-2.8nb1.tgz
-rw-r--r--  1 root  wheel   2339499 Apr 24 17:54 lynx-2.8.8.2.tgz
-rw-r--r--  2 root  wheel    215882 Apr 24 06:16 m4-1.4.17.tgz
-rw-r--r--  1 root  wheel   2102060 Apr 24 14:32 mc-4.7.0.10nb12.tgz
-rw-r--r--  1 root  wheel     43411 Apr 24 20:23 mtr-0.85nb3.tgz
-rw-r--r--  1 root  wheel    288745 Apr 24 21:54 nginx-1.4.7nb5.tgz
-rw-r--r--  1 root  wheel     52094 Apr 24 12:09 nload-0.7.4.tgz
-rw-r--r--  2 root  wheel    200993 Apr 25 00:27 p5-XML-Parser-2.41nb2.tgz
-rw-r--r--  2 root  wheel     15613 Apr 24 05:54 p5-gettext-1.05nb9.tgz
-rw-r--r--  2 root  wheel   1179041 Apr 24 07:06 pcre-8.34.tgz
-rw-r--r--  2 root  wheel  15767929 Apr 24 05:49 perl-5.18.2nb1.tgz
-rw-r--r--  2 root  wheel    207352 Apr 24 01:52 pkg-config-0.28.tgz
-rw-r--r--  1 root  wheel     51044 Apr 24 17:10 pv-0.9.6nb1.tgz
-rw-r--r--  1 root  wheel    188499 Apr 24 22:20 tmux-1.9a.tgz
-rw-r--r--  1 root  wheel    976804 Apr 24 19:06 unbound-1.4.22.tgz
-rw-r--r--  1 root  wheel    913978 Apr 25 00:18 vim-7.4.141.tgz
-rw-r--r--  2 root  wheel   6244854 Apr 24 23:32 vim-share-7.4.141.tgz
-rw-r--r--  1 root  wheel    932868 Apr 24 11:53 wget-1.15nb1.tgz
-rw-r--r--  1 root  wheel   2511673 Apr 24 11:04 zsh-5.0.5.tgz

Final words

So far, running NetBSD on the Raspberry Pi has been a very positive experience and the system is very stable. I would definitely recommend anyone wanting to use BSD on the Pi to give NetBSD a try, it's well worth it.

I should probably also mention that it's smaller than a toaster :-)

My Raspberry Pi running NetBSD

Lastly, for some prebuilt images with X.Org included: ftp://ftp.netbsd.org/pub/NetBSD/misc/jun/raspberry-pi/

Back to top