How to Install FreeBSD on a Raspberry Pi 3b+
FreeBSD is a free open-source unix-like operating system for various platforms. It focuses on features, speed and stability. It is derived from BSD, the version of UNIX developed at the University of California, Berkeley. It is a mature, clean, and minimalist operating system. It is considered to be one of the most stable and reliable operating systems out there for use with embedded devices, single board computers and servers. Here is a fun fact, the legendary PlayStation 4's operating system
Orbis OS is a fork of FreeBSD (release 9).
In this guide we will go through the necessary steps to get up and running FreeBSD on your Raspberry Pi device.
Step 1: Download
In this step, we will download the latest available FreeBSD image to a temp folder called 'tmp', and use a tool called 'dd' to write this image to our Micro-SD card. Assuming your Micro-SD device is at /dev/sdb
cd ~ mkdir tmp && cd tmp wget https://download.freebsd.org/ftp/releases/arm64/aarch64/ISO-IMAGES/12.1/FreeBSD-12.1-RELEASE-arm64-aarch64-RPI3.img.xz
The image is stored on the FreeBSD servers in a compressed form
xz, will need to un-compress the image using a tool called
xz and redirect the output of the
xz tool via grep to the input of
dd to write the image directly to our Micro-SD card in a single step.
xz -d < FreeBSD-12.1-RELEASE-arm64-aarch64-RPI3.img.xz - | sudo dd of=/dev/sdb bs=1M status=progress sync
Step 2: Boot
After we have prepared our image, it is time to insert it to your Raspberry Pi and boot your device. SSH service is configured to start by default, but FreeBSD does not permit root login over SSH by default, so we will login using the regular user
freebsd and its password
freebsd. When you will need root permissions, you can elevate to root by typing
su - in the shell, the default root password is
Now, let's change the default password to make our system a little more secure:
If you prefer, you can create your own user, and remove the default one. Type
adduser into the shell and follow the on-screen steps.
su - adduser
output: click to expand
$ su -
root@generic:~ # adduser
Full name: test
Uid (Leave empty for default):
Login group [test]:
Login group is test. Invite test into other groups? :
Login class [default]:
Shell (sh csh tcsh nologin) [sh]:
Home directory [/home/test]:
Home directory permissions (Leave empty for default):
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]:
Enter password again:
Lock out the account after creation? [no]:
Username : test
Password : *****
Full Name : test
Uid : 1003
Groups : test
Home : /home/test
Home Mode :
Shell : /bin/sh
Locked : no
OK? (yes/no): yes
adduser: INFO: Successfully added (test) to the user database.
Add another user? (yes/no): no
To remove the default user, we will type
rmuser in our shell, followed by the user name we would like to remove.
Step 3: Networking
Vanilla FreeBSD image shipped with networking connection configured as DHCP by default, lets change that to static IP. The networking configuration file is located at
/etc/rc.conf, we will edit this file with
vi and add the following:
vi /etc/rc.conf #ifconfig_DEFAULT="DHCP" // comment this line ifconfig_ue0="inet 192.168.1.18 netmask 255.255.255.0" default_router="192.168.1.1"
Also, while at it, lets set a hostname for our Raspberry Pi, add the following line to the
/etc/rc.conf it is time to reload the network & routing services
/etc/rc.d/netif restart && /etc/rc.d/routing restart
Now, lets add our DNS servers to
# vi /etc/resolv.conf nameserver 192.168.1.1
Step 4: Timezone
To install packages, and fetch repository for ports, we will need to make sure that our system's time is properly set. Mismatched system time can cause unexpected issues and cause troubles to communicated and establish a secure handshake with our repository servers. To avoid that, we will configure our system to run
ntpd service which will make sure our system is getting the right time and also, we will use a command line tool called
tzsetup which will assist us to select a specific zone for our system.
First, lets add ntp options to
Second, lets run
tzsetup at the console.
/etc/ntp.conf and add ntp servers from your region pool. My location is at Asia, so in my case, I have added asian servers 0-4.
If you are not sure what is the right server for your timezone, you can find your pool here
# vi /etc/ntp.conf # pool 0.freebsd.pool.ntp.org iburst // comment this line server 0.asia.pool.ntp.org server 1.asia.pool.ntp.org server 2.asia.pool.ntp.org server 3.asia.pool.ntp.org
Reboot the system, and check that your system's clock is now synchronized with ntp. To do that, run the
date command in the terminal.
Step 5: Install Packages
Binary Package Management (pkg)
The preferred way to install a package in FreeBSD is to use the binary package management system
pkg. Installing an application from
pkg will ensure fast and easy way to setup the software you need and in most cases it would be enough.
More information about FreeBSD packages management can be found here.
FreeBSD has multiple ways to install packages to the system. The question is, would you prefer installing an application from source? Or would you like to skip app optimization and rather install a pre-compiled one? Installing a package using
pkg would be a quicker way, although not the optimized one.
In some cases you might need to have a specific option turned on which wasn't offered in the pre-built binary, but for most cases, the default options that are shipped with a pre-compiled binary will suite most users.
Make sure you only work with one mechanism or the other, DO NOT combine both on your system as it would cause messy packaging system with messy dependencies, make your system unstable and probably unusable.
Assuming we have an internet connection, lets install few packages to get things rolling. On the first time we plan to use the
pkg package management system, we will have to bootstrap our system to use
Update repository metadata:
pkg update -f
Install useful packages:
pkg install wget curl git vim zsh htop pfetch sudo tmux
curl -Lo install.sh https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh sh install.sh
Having a functional system allows us to focus on other services we would like to setup. At this point, we have a working FreeBSD operating system on our Raspberry Pi, from here, we can add additional packages such as installing the X system, which will provide you a graphical environment, or setup a FAMP stack and start hosting a webserver on this system.
After reading this guide you will understand how to prepared your Micro-SD card with FreeBSD image for your Raspberry Pi, configure user accounts, networking, Timezone and also how to install some daily used packages using FreeBSD's binary package manager.