I am trying out the minimal GNU/Linux distribution Alpine Linux on a Raspberry Pi. By default, Alpine for a Raspberry is run from memory and not the SD card.
There is an unofficial guide for disk-based installation at Alpine’s Wiki. The installation process described here is a more detailed version of this guide with inspiration from https://www.rigon.tk/documentation/alpine-raspberry-pi.
I am preparing the SD card on a laptop running Linux Mint.
Download the tarball for the Raspberry Pi. At the time of writing the newest version is
Mount the SD card and determine the mount point with e.g.
lsblk(8). In my case:
Unmount the partion(s):
- Create a bootable FAT32 partition with around 150 MB and fill the remainder of the SD card with another partition. Here I am using GNU parted. In interactive mode the FAT32 partition can be created as follows:
Alternatively, create the partitions using the shell:
You can verify that the partition has been created successfully in parted’s interactive mode.
- Format the partition as FAT32:
- Extract the tarball contents to the FAT32 partition:
--no-same-owner I get permission errors from
Apparently this is because the SD card is mounted with SMB.
/mnt/alpine/config.txt on the SD card containes configurations for multiple Raspberry version.
The unnecesarry parts can be remove by changing it to be
Insert the SD card into the Raspberry Pi and turn it on.
Log in as
root with an empty password.
Setup the installation by running
setup-alpine and save the changes with
lbu commit -d.
Note that in this disk-less installation changes are only saved if you commit them – this also includes any installed programs.
You can verify that the setup works by rebooting (with
reboot or turning off with
Once the basic setup is done, you can move on to the disk-based installation.
- Create the filesystem in
/dev/mmcblk0p2(if it is not already created):
- Do a disk install via a mountpount
You will get some error messages from extlinux, but they can be ignored.
At this point I would run out of space on the FAT32 partition, implying that I cannot edit the files required in the remaining steps.
However, it turns out that all the disk space is consumed by the local APK cache folder,
Delete some files in this folder to free space.
- Add this line to
/stage/etc/fstabto mount the Raspberry’s boot partition again:
/media/mmcblk0p1to make it writeable:
and add “
root=/dev/mmcblk0p2” to (the end of)
/media/mmcblk0p1/cmdline.txt so that it looks like
- Copy relevant boot files to the FAT32 partition. Here we first backup the previous files:
After rebooting, Alpine starts from
First I create a non-root user and add it to the
wheel group (to allow changing to
Uncomment the line
wheel ALL=(ALL) ALL.
The Raspberry does not have a hardware clock and ALpine informs you of this at boot. In order to add a software clock and delete the hardware clock, run
An NTP daemon is needed to get the time and if one is not installed, run
setup-ntp (in my case it was already running).
Save the changes and reboot to check if the setup is working