UserCTL.xyz

Announcing BerryOS: a lightweight OS for your Raspberry Pi

(6 minutes read)

After a couple of weeks working on it, I am proud to finally be releasing the first version of BerryOS to the public!

What is BerryOS?

BerryOS Logo

BerryOS is a lightweight operating system for your Raspberry Pi based on the official Raspberry Pi OS Lite bootstrapped directly from its sources. It is available in two variant: BerryOS/armhf and BerryOS/arm64 for 32 & 64-bit ARM compatible hardware.

When building it, my goal was to create a lightweight version of Raspberry Pi OS Lite than can be configured headlessly at first boot using cloud-init. Other images including cloud-init already exists such as the Ubuntu Server RPi release or the now defunct HypriotOS, though most of them includes extra software or are not based on Debian itself.

In order to keep the same level of compatibility with 3rd party software and hardware, I decided to bootstrap it directly from the Raspberry Pi OS sources (Raspbian GNU/Linux and Debian GNU/Linux for its armhf and arm64 version respectively) with some tweaks to the list of pre-installed package and default configuration.

In the end, BerryOS turned out to be nearly 40% lighter than Raspberry Pi OS Lite, had fewer processes running by default while being completely configurable using cloud-init.

Here is a comparison table between the first BerryOS release (BerryOS Bullseye 2022.05.30) and the latest Raspberry Pi OS Lite release (Raspberry Pi OS Bullseye 2022.04.04) running on a Raspberry Pi 3 B:

StatBerryOS/armhfRaspiOS/armhfBerryOS/arm64RaspiOS/arm64
RAM usage37M57M52M72M
Running processes12181220
Disk usage807.1M1.3G611.7M1.3G
Pre-installed packages312530285521
Download size201M297M153M271M
Image size1312M1924M1112M1908M

The methodology for these results can be found in the Benchmark section of the BerryOS README file.

Where to get it?

BerryOS is completely open-source and licensed under the ISC License. Its source code is hosted on GitHub at github.com/0rax/BerryOS.

From there, you can download all current and previous version of each variant on its releases page or checkout its documentation (which is still a work in progress). You will also find some example configuration files to get you started.

If you decide to give it a go and find any issues with it, do not hesitate to open an issue on there, so we can fix as soon as possible.

How to use it?

Grab your closest Raspberry Pi and your SD card of choice, head to the latest release page and download the variant you need.

  • BerryOS/armhf should be compatible with ALL Raspberry Pi models.
  • BerryOS/arm64 should be compatible with the Raspberry Pi 3B, 3B+, 4 & 400, Compute Module 3, 3+ & 4 as well as the Raspberry Pi Zero 2 W.

Raspberry Pi 3B & SD Card

Fire up you favorite tool and flash your newly acquired image to your SD card. Any flashing tools should work, such as the official Raspberry Pi Imager, balenaEtcher, Hypriot’s flash tool or even dd on any *NIX like system.

Note

Hypriot’s flash tool can be used pretty efficiently with BerryOS as it allows you to specify extra configuration file to copy to your SD card after flashing directly from the command line.

For example to flash BerryOS with a custom user-data and config.txt file you already have on disk, you can just run:

flash --userdata user-data.yaml --bootconf config.txt ~/Downloads/berryos-arm64-bullseye-20220527.img.xz

Once successfully flashed, unplug and re-plug your SD card from your computer (to force remounting it) and open the drive named boot. You should be able to open the user-data file with your favorite text editor from there.

user-data is the configuration file that will be used by cloud-init to configure your system on its first boot. We have set it up to use the Cloud Config format as it makes configuring a system really simple, though other format are also available.

This is a really important file when setting up a BerryOS system, as this is where you will set up how to access your system.

Note

By default, BerryOS does not enable password based SSH access to the default user to follow the decision made by the Raspberry Pi Foundation in April 2022 to disable it on Raspberry Pi OS Bullseye going forward (source).

I would suggest going through the whole file (also available on GitHub) and read the comments to understand what you are able to configure using it. You can also have more extensive explanation of the configuration capabilities in the project documentation.

Here we will just update the default user (pi) password and enable SSH password authentication and set the system hostname. To do so, append the following lines to the user-data file:

hostname: berryos.userctl.xyz       # Set system hostname
manage_etc_hosts: true              # Update /etc/hosts with the new hostname

password: berryos                   # Set default user password
chpasswd: { expire: false }         # Do not expire password after first login
ssh_pwauth: true                    # Enable SSH password authentication for default user

The password field can either be a plaintext password or a hashed version of it. On *NIX system, a password can be hashed using the openssl passwd -6 command. The file would end up looking like:

password: $6$kEE0sV/2tz/jWBtQ$tRpM0XqKhl3xEroj837u6VCQadIoSL......nSY48unRmtsZv0
chpasswd: { expire: false }         # Do not expire password after first login
ssh_pwauth: true                    # Enable SSH password authentication

If you wish to assign a static IP to your Raspberry Pi, you should also edit the network-config file. For example, to assign the 192.168.1.128 IP to your Pi with a /24 netmask (equivalent to 255.255.255.0) and 192.168.1.1 as gateway, you should update the file to look like this.

version: 2
ethernets:
  eth0:
    dhcp4: false
    addresses:
      - 192.168.1.128/24
    routes:
      - to: 0.0.0.0/0
        via: 192.168.1.1

Save your modifications, un-mount your SD card and insert it in your Raspberry Pi. Connect you Ethernet cable and power supply, and after some time you should be able to access it using ssh pi@$ip.

As avahi-daemon IS NOT installed by default, you will not be able to use the Pi hostname to connect to it. If you haven’t given it a static IP, you will need to find it another way. The easiest solution is to plug a screen to it as BerryOS prints the system IPs on each TTY by default (you might need to switch to TTY2 to get a clean reading by using Alt + Right). Another solution is to check your router’s DHCP assignation table.

Note

If you require Wi-Fi connectivity, you should check out the Network Configuration guide in the BerryOS Wiki to set it up properly.

Congratulation, you can now enjoy BerryOS to its full extent!

The future of BerryOS

BerryOS is the operating system I with I had for quite some years now, thus I intend to support and keep it up to date with mainstream Raspberry Pi OS for the foreseeable future.

Having a lightweight alternative to the default operating system for your Raspberry Pi is the real goal here, something than can be used by anyone that just want to tinker a bit more with their hardware and have more control over its software. I do not want to create a complete new ecosystem but keep it as close and compatible with RaspiOS as possible without adding unnecessary software or removing capabilities.

The clear next step for the project now is to expand its documentation and add more example of how cloud-init can be used. Those Cloud Config files are great to share with each other setup and having great resources built around this possibility should be what we aspire to.

If this is something that you find interesting, come check it out, or even get involved with the project on GitHub.

#linux #raspberrypi #berryos