Alpine Linux on a Raspberry Pi
Author: -fab- <fab@redterminal.org>
License: CC BY-SA 4.0
Published on: Sat, 18 Sep 2021 02:08:38 +0200
Last updated: Sat, 18 Sep 2021 02:08:38 +0200
I'm pretty new to Alpine Linux. All I knew about it was, that it's widely used for Docker containers because of it's size. I just wanted to test it as I found out there is a version for the Raspberry Pi. And I was immediatly convinced by it's simplicity and it's small size.
Alpine Linux Homepage
Refreshingly small
Here are some command outputs:
$ free -m
total used free shared buff/cache available
Mem: 7812 41 7657 0 114 7664
Swap: 0 0 0
As you can see it takes only 41MB of RAM. I was reminded of the early days of Linux by this, when machines had much less memory. It seems to have a very economic way to deal with it. Without all the bloated systemd crap.
$ df -Th
Filesystem Type Size Used Available Use% Mounted on
devtmpfs devtmpfs 10.0M 0 10.0M 0% /dev
shm tmpfs 3.8G 0 3.8G 0% /dev/shm
/dev/sda2 ext4 438.5G 224.3M 416.0G 0% /
tmpfs tmpfs 1.5G 136.0K 1.5G 0% /run
/dev/sda1 vfat 511.0M 33.5M 477.5M 7% /boot
It only takes 225MB of space on my SSD. And there are already some additional packages installed. A fresh install shouldn't take more than 160-170MB. On a docker image based on Alpine Linux you can get as low as 8MB for the OS as stated on the homepage.
$ top -n 1
Mem: 158644K used, 7841104K free, 136K shrd, 22800K buff, 36532K cached
CPU: 2% usr 0% sys 0% nic 97% idle 0% io 0% irq 0% sirq
Load average: 0.11 0.16 0.11 1/104 4340
PID PPID USER STAT VSZ %VSZ CPU %CPU COMMAND
2633 1 chrony S 7340 0% 0 0% /usr/sbin/chronyd -f /etc/chrony/c
4279 2729 root S 4348 0% 3 0% sshd: pi [priv]
2729 1 root S 4320 0% 2 0% sshd: /usr/sbin/sshd [listener] 0
4281 4279 pi S 4296 0% 0 0% sshd: pi@pts/0
2689 1 root S 3980 0% 3 0% /usr/sbin/rngd -b -p /run/rngd.pid
4282 4281 pi S 1740 0% 0 0% -ash
2546 1 root S 1664 0% 3 0% /sbin/syslogd -t
4340 4282 pi R 1660 0% 1 0% top -n 1
2661 1 root S 1652 0% 0 0% /usr/sbin/crond -c /etc/crontabs
1 0 root S 1644 0% 3 0% /sbin/init
2510 1 root S 1644 0% 2 0% /sbin/udhcpc -b -R -p /var/run/udh
2739 1 root S 1644 0% 2 0% /sbin/getty 38400 tty4
2737 1 root S 1644 0% 3 0% /sbin/getty 38400 tty2
2603 1 root S 1644 0% 0 0% /sbin/acpid
2741 1 root S 1644 0% 2 0% /sbin/getty 38400 tty6
2740 1 root S 1644 0% 3 0% /sbin/getty 38400 tty5
2736 1 root S 1644 0% 0 0% /sbin/getty 38400 tty1
2738 1 root S 1644 0% 2 0% /sbin/getty 38400 tty3
The running processes are quite manageable and uncluttered. It could be even stripped down a little more by removing all that unnecessary getty processes on a headless system.
Building blocks
Alpine Linux is built around the musl libc, which is a lightweight and simple implementation of the Linux Standard library libc. It's much leaner than the standard glibc used by most distros.
It uses busybox, which is a replacement of a lot of common UNIX utilities with one simple executable. Busybox was designed to be used in embedded systems where disk space is precious. It provides a fairly complete Linux environment.
Instead of using the bloated systemd init system, it utilizes OpenRC. I've never made any experiences with OpenRC or any other alternative init system besides systemd. In fact, I'm not a systemd hater, and I think that it's doing a good job. I use systemd on my desktop and laptop as well as on my cloud servers. Nevertheless is OpenRC and it's simplicity a positive experience to me. After diving in a little I like it a lot.
My use case
I've converted all my Raspberry Pis into Alpine Linux machines except my Pihole, which still uses a standard installation of Raspberry Pi OS (rasbian).
For my NAS, Alpine Linux was essential. My NAS is a RPi4 (8GB) connected to a 4-Bay USB3 HDD case. It's running a ZFS raidz1. Raspberry Pi OS did always panic after a while when I started a zpool scrub. After switching to Alpine Linux this behaviour was gone and a scrub runs until it finishes.
Another RPi4 (4GB RAM) uses Alpine as Docker host. It boots from a SSD and runs several docker images for Home Automation and a Wireguard Server as a VPN for my smartphone.
The third RPi4 (8GB) has another USB3 harddrive attached to it as an additional backup for my NAS. I send the whole zpool (incremental) from the NAS to it every sunday. It also functions as a SyncThing server using a fast SSD.
Conclusion
I can wholeheartedly recommend Alpine Linux on the Raspberry Pi for a headless installation. It's small and simple and still has all the features you need. The utilization of OpenRC is refreshing and a good choice for the Pi. It's completley unbloated from the beginning and you can even run the whole OS from RAM and only store your data on a SSD and keep the OS itself immutable (you can still explicitly update it).
I can't say anything about Alpine Linux on the desktop/Laptop with Xorg/Wayland, but for a server it's a good operating system.
All that said I have to say again, that I'm not a professional. There may be solutions better suited to your use case. But I can say that I'm completely satisfied with Alpine Linux.
--
Back to index
Homepage