Installing FreeBSD on Raspberry Pi using Linux

Raspberry Pi is a cheap computer that’s perfect for trying FreeBSD without investing too much money (or time in this case since you don’t even have to go through installing it or struggling with device compatibility issues).

In this guide we’ll see how to use a Linux machine to build a bootable disk for FreeBSD. In 10 minutes you’ll boot into FreeBSD console (no GUI). You need:

  • Raspberry Pi (any version)
  • An SD/MicsoSD card (depending on your Raspberry Pi version) with at least 1GB capacity
  • A USB keyboard (mouse not needed)
  • A monitor that supports HDMI
  • A micro USB charger (like the one from your mobile phone)
  • A Linux machine with an Internet connection (download size is around 150MB) and a built-in or external card reader

Identify your Raspberry Pi model

FreeBSD officially supports Raspberry Pi and binary images are available for download. In order to find the right download file, you need to know which Raspberry Pi you have. Here is the official guide.

For example I’m using a 5 year old Raspbery Pi B with 0.5GB RAM and a 4GB SD Transcend SD card using Lubuntu machine.

Download the image

Go to the official FreeBSD download site and download the latest version of the .img.xz file for your Raspberry Pi. Skip the CHECKSOME files and go to the bottom of the page. For me at the time of writing the newest version is: FreeBSD-11.0-STABLE-arm-armv6-RPI-B-20170323-r315855.img.xz

Decompress the image

Decompress the FreeBSD-XXXXXX.img.xz file to get an .img file.

This will replace your .img.xz file with the uncompressed .img file. If you want to keep the compressed downloaded file use the --keep option:

Identify the device name for the SD card

There are many ways to do that. For writing the image, we need a reference to the whole drive (ex. /dev/sdb) not a particular partition on it (ex. /dev/sdb1 or /dev/sdb2).

The easiest way is to run the following command right after you insert the card into the card reader:

This command gives you the latest kernel message which is sure gonna have something about your SD card insertion event.

On Ubuntu 18.04 I use the Disks application to get the name of the device:

The device name is /dev/mmcblk0

If the SD card is mounted, another way to get a reference is to run:

This will give you all the device files and their corresponding mount points.

Another method is to ask Linux about the device name that is mounted to a particular directory that you know represents your SD card:

In my case since I had Raspbian on the card and it has made a /boot partition for me, I run this:

Which gives me /dev/sdb1 so the reference to the SD card is /dev/sdb. And for the sake of documentation one of the coolest solutions is lsblk:

Write the image to the SD card

Note: this stage is very sensitive and may fuck up your system if you pick the wrong device name for the of (output file) option.

dd is a useful Unix command that writes the contents of a file (in this case the downloaded and decompressed image) into a device file (in this case your SD card). It has two options:

  • if: path to the input file
  • of: the device file for the SD card you identified in an earlier step (again, you need a reference to the whole file not just a partition on it)

In my case it is:

Note: if you want to do it the other way around (copying from an SD card to a *.img, possibly for cloning an already existing and configured disk) do this:

And finally unmount the disk to put it into Raspberry Pi.

Boot FreeBSD

  • Connect the HDMI to the monitor
  • Attach the USB keyboard.
  • Put the SD card in place
  • Connect the power.

It’ll show some boot messages and eventually gives you the login prompt (on my Raspberry Pi B it took about a minute).

  • The default username is freebsd and its password is freebsd.
  • The root account is root and its password is root as well.

So the first thing you wanna do after logging in is to change your password as soon as possible:

What’s next?

If you use a non-English keyboard, the first thing you wanna do is to set your keyboard layout:

The BSD distributions have a reputation of having excellent documentation.

Checkout the newbie guide on FreeBSD’s website. If you’re using Linux, you want to check out FreeBSD for Linux users. Also if you like a GUI, here is how to set it up.

Bonus: FreeBSD can run Linux programs without having to recompile!

Liked what you read? Follow me to be notified when I write something new.