Last active
June 13, 2023 18:32
-
-
Save psammarco/1a444019869eb7acedb9b4bf495cc831 to your computer and use it in GitHub Desktop.
Build AlpineLinux 3.7 aarch64 for the RaspberryPi 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following steps will show you how to deploy a AlpineLinux 3.7 aarch64 for the RaspberryPi 3 from a chrooted environment. | |
# | |
# This image was built using a Gentoo aarch64 HOST. | |
# | |
# Steps for building the kernel are not provided in this guide. | |
# | |
# However I have used this wiki page as guidance to build mine https://wiki.gentoo.org/wiki/Raspberry_Pi_3_64_bit_Install . | |
# | |
# I am sure you will find lots of weirdness here along with many things that can be improved. | |
# | |
# If so and care to help, feel free to email your feedbacks to pietro.sammarco@googlemail.com . | |
# mkdir alpine | |
# cd alpine | |
- As we speak latest version is apk-tools-static-2.9.1-r0. If you get 404 you will need to change it with actual version. | |
# wget http://uk.alpinelinux.org/alpine/latest-stable/main/aarch64/apk-tools-static-2.9.1-r0.apk | |
# tar -xzf apk-tools-static-*.apk | |
- Pulling the "stage3" binaries; | |
# ./sbin/apk.static -X http://uk.alpinelinux.org/alpine/latest-stable/main --arch aarch64 -U --allow-untrusted --root . --initdb add alpine-base | |
- Mounting the chrooted environment; | |
# mount -t proc none proc | |
# mount -o bind /sys sys | |
# mount -o bind /dev dev | |
# cp /etc/resolv.conf etc/ | |
# chroot . /bin/sh -l | |
# source /etc/profile | |
# export PS1="(alpine) ${PS1}" | |
- Adding the APK repo; | |
# echo "http://uk.alpinelinux.org/alpine/latest-stable/main" > /etc/apk/repositories | |
- Installing few essential packages; | |
# apk update && apk upgrade | |
# apk add chrony | |
# apk add openssh openssh-server | |
# apk add wpa_supplicant | |
# apk add sudo | |
- Enabling a bunch of rc services; | |
# rc-update add devfs sysinit | |
# rc-update add dmesg sysinit | |
# rc-update add mdev sysinit | |
# rc-update add modules boot | |
# rc-update add sysctl boot | |
# rc-update add hostname boot | |
# rc-update add bootmisc boot | |
# rc-update add syslog boot | |
# rc-update add mount-ro shutdown | |
# rc-update add killprocs shutdown | |
# rc-update add savecache shutdown | |
# rc-update add udhcpd boot | |
# rc-update add swclock boot | |
# rc-update add sshd default | |
# rc-update add wpa_supplicant boot | |
# rc-update add local default | |
# rc-update add ntpd default | |
- Your /etc/fstab should look similar to this (this is a simple rootfs plus /boot layout); | |
/dev/mmcblk0p1 /boot vfat noauto,noatime 1 2 | |
/dev/mmcblk0p2 / ext4 noatime 0 1 | |
- This create a 50mb compressed zram swap disk. The script goes into /etc/local.d/zram.start; | |
# | |
#!/bin/sh | |
modprobe zram | |
SIZE=50 | |
echo $((50*1024*1024)) > /sys/block/zram0/disksize | |
mkswap /dev/zram0 | |
swapon /dev/zram0 -p 20 | |
# | |
# chmod +x /etc/local.d/zram.start | |
- This will unmount the zram swap disk prior to shutdown. Script goes into /etc/local.d/zram.stop; | |
# | |
#!/bin/sh | |
swapoff /dev/zram0 | |
echo 1 > /sys/block/zram0/reset | |
modprobe -r zram | |
# | |
# chmod +x /etc/local.d/zram.stop | |
- Add the following to /etc/network/interfaces; | |
auto eth0 | |
iface eth0 inet dhcp | |
auto wlan0 | |
iface wlan0 inet dhcp | |
- Specifying a server for ntpd to work; | |
# echo 'NTPD_OPTS="-4 -N -p pool.ntp.org"' > /etc/conf.d/ntpd | |
- Create a new user; | |
# adduser alpine -s /bin/sh -h /home/alpine | |
- In order for the Wireless NIC to work you will need to install the linux-firmware package which contains the Broadcom drives; | |
# apk update && apk add linux-firmware | |
- Since /lib/firmware/brcm is only really needed, if you want to save space you could backup the brcm folder, remove the linux-firmware package and place back the brcm folder to /lib/firmware/ . | |
- Load the Broadcom modules on boot | |
# echo -e 'b43 \nbrcmfmac' >> /etc/modules | |
- Add the following entries to /boot/cmdline.txt. Make sure root= matches the / partition; | |
root=/dev/mmcblk0p2 rootfstype=ext4 fsck.repair=yes rootwait | |
- If you made it this far you should now have a minimal Alpinelinux 3.7 aarch64 rootfs. Though you might also want a kernel to actually boot the system up... | |
- Here is the /boot folder https://goo.gl/hKECev which contains kernel 4.10.17-v8+, blobs for the Wireless NIC the bootcode as well as the usual overlays for the RPI3. | |
- Basically just extract it directly to the /boot partition of the sdcard; | |
# tar xvjf rpi3-alpine-boot.tar.bz2 -C /path/of/whatever/boot | |
- Installation guide needs to be revised, though aside from some nonesense it should work just fine https://pastebin.com/raw/RfNQ5tXv | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment