This post is about trying out FreeBSD on a Raspberry Pi B. I’m new to FreeBSD (any BSD flavor, really), so I’ve compiled this from a number of sources, e.g., this.

Creating the memory card

The images are found at

Guides on writing to memory card using different operating systems can be found here. Here I use a Mac. (On a GNU/Linux distribution use df to identify memory card and umount /dev/sdX to unmount the card; dd is still used for writing the image)

Extract the image:

bunzip2 FreeBSD-10.1-STABLE-arm-armv6-RPI-B-20150223-r279201.img.bz2

Identify the memory card:

$ diskutil list
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *160.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            159.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *7.9 GB     disk2
   1:             Windows_FAT_32 NO NAME                 104.9 MB   disk2s1
   2:                      Linux                         7.8 GB     disk2s2

In this case it is /dev/disk2. Unmount the card using diskutil unmountDisk /dev/disk2 and write the image using

sudo dd if=FreeBSD-10.1-STABLE-arm-armv6-RPI-B-20150223-r279201.img of=/dev/disk2

Unmount the newly written memory card with sudo diskutil eject /dev/disk2 and plug the memory card in the Pi.

Initial setup

By default, the only user is root with an empty password. Once logged in, be sure to add a password using passwd root.

My first setup is done ‘locally’, with the Pi plugged into a TV:

  • I use a Danish keyboard and FreeBSD assumes a US layout. To change this, edit the file /etc/rc.conf. Add the line keymap=danish.iso and reload the configurations using service syscons start (or reboot).
  • The output spills of the left of the screen. This can be fixed be adding the following lines to the top of /boot/msdos/config.txt:
  • To enable ssh login for root, edit the file /etc/ssh/sshd_config and add/uncomment the following lines:
PermitRootLogin yes

Restart the SSH service with service sshd restart.

After transferring my (public) key to .ssh, the line PasswordAuthentication yes is deleted and RSAAuthentication yes is added instead.

With these initial setups out of the way the rest is done using SSH. Remember to shutdown the Pi with the command shutdown -p now.

Further setup

The clock must be set correctly for a lot of stuff to work.

Find an IP address for an NTP server with ntpdate -q In /etc/rc.conf add the following lines and reboot:

ntpdate_flags="-u -b"

FreeBSD uses the ports system to install software; get it with

portsnap fetch
portsnap extract

Both commands will take a while to execute. During the extraction the local computer I used dropped the connection and this caused the command to cancel.

Install pkg:

cd /usr/ports/ports-mgmt/pkg
make install clean BATCH=yes

It appears at the time of writing that the available pre-compiled packages are very limited for FreeBSD on a Pi so everything has to be compiled locally; this is often very time consuming.

Furthermore, with a regular compile the user is prompted for several installation options during the compilation – this makes it difficult to start the installation and just leave it for the night. One way to make a quiet installation is to compile with

make install clean BATCH=yes

This accepts the standard options. To see the compilation options run make showconfig.

The first thing for me to install is a terminal multiplexer in order to log out during subsequent compilations; I use tmux (/usr/ports/sysutils/tmux).

Further necessary ports are Git, Vim, zsh, rcm, sudo.

Finally, add a normal user with adduser to avoid spending unnecessary time as root – and remember too add the user to the wheel group to allow use of the su command.

To give the new user access to the sudo command, edit the file /usr/local/etc/sudoers with

visudo -f /usr/local/etc/sudoers

When using locate for the first time you are informed that the database is too small. It is suggested to run /usr/libexec/locate.updatedb – but if you run this command as root you are informed that it is a security liability. As an alternative, run the command that periodically recreates the database: