https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&user=Shimaore&feedformat=atomAlpine Linux - User contributions [en]2024-03-29T02:03:59ZUser contributionsMediaWiki 1.40.0https://wiki.alpinelinux.org/w/index.php?title=Raspberry_Pi&diff=16063Raspberry Pi2019-07-21T15:14:26Z<p>Shimaore: /* Preparation */ Adding a note as to which image is compatible with which platform, based on https://git.alpinelinux.org/aports/tree/scripts/mkimg.arm.sh and https://en.wikipedia.org/wiki/Raspberry_Pi#Specifications</p>
<hr />
<div>[[Category:Installation]]<br />
This tutorial will help you install Alpine Linux on your Raspberry Pi.<br />
<br />
== Preparation ==<br />
<br />
This section will help you format and partition your SD card:<br />
<br />
# [http://alpinelinux.org/downloads/ Download] Alpine for Raspberry Pi tarball for the '''armhf architecture''' which is named as <code>alpine-rpi-<version>-armhf.tar.gz</code>. You will need version 3.2.0 or greater if you have a Raspberry Pi 2.<br />
# Mount your SD card to your workstation<br />
# Use [https://en.wikipedia.org/wiki/GNOME_Disks gnome-disks] or [http://linux.die.net/man/8/fdisk fdisk] to create a FAT32 partition. If you are using fdisk, the FAT32 partition type is called ''W95 FAT32 (LBA)'' and its ID is 0x0C.<br />
# Mark the newly created partition as bootable and save<br />
# Mount the previously created partition<br />
# Extract the tarball contents to your FAT32 partition<br />
# Unmount the SD Card.<br />
<br />
Note: You should be safe using the '''armhf''' build on all versions of Raspberry Pi (including Pi Zero and Compute Modules); but it may perform less optimally on recent versions of Raspberry Pi. The '''armv7''' build is compatible with Raspberry Pi 2 Model B. The '''aarch64''' build should be compatible with Raspberry Pi 2 Model v1.2, and is compatible with Raspberry Pi 3 and Compute Module 3.<br />
<br />
=== Wifi support ===<br />
If you need wifi to work, perform the following before unmounting the SD card:<br />
# [https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm Download] the latest broadcom drivers for the Raspberry Pi to your machine and <br />
# Copy them to [SD card]/firmware/brcm/.<br />
<code><br />
git clone --depth 1 https://github.com/RPi-Distro/firmware-nonfree.git<br />
</code><br />
<br />
<code><br />
cp firmware-nonfree/brcm/* [SD card]/firmware/brcm<br />
</code><br />
<br />
== Installation ==<br />
<br />
Optionally create a "usercfg.txt" file on your SD card to configure low-level system settings. Specifications can be found [https://www.raspberrypi.org/documentation/configuration/config-txt here]. Some interesting values include:<br />
* Enable audio: dtparam=audio=on<br />
* If you see black edges around your screen: disable_overscan=1<br />
<br />
Alpine Linux will be installed as [[Installation#Installation_Handbook|diskless mode]], hence you need to use [[Alpine local backup|Alpine Local Backup (lbu)]] to save your modifications between reboots. Follow these steps to install Alpine Linux:<br />
<br />
# Insert the SD Card into the Raspberry Pi and turn it on<br />
# Login into the Alpine system as root. Leave the password empty.<br />
# Type <code>setup-alpine</code><br />
# Once the installation is complete, commit the changes by typing <code>lbu commit -d</code><br />
<br />
Type <code>reboot</code> to verify that the installation was indeed successful.<br />
<br />
== Post Installation ==<br />
<br />
=== Update the System ===<br />
<br />
Upon installation, make sure that your system is up-to-date:<br />
<br />
{{cmd|apk update<br />
apk upgrade}}<br />
<br />
Don't forget to save the changes:<br />
<br />
{{cmd|lbu commit -d}}<br />
<br />
=== Clock-related error messages ===<br />
<br />
During the booting time, you might notice errors related to the hardware clock. The Raspberry Pi does not have<br />
a hardware clock and therefore you need to disable the hwclock daemon and enable swclock:<br />
<br />
{{cmd|rc-update add swclock boot # enable the software clock<br />
rc-update del hwclock boot # disable the hardware clock}}<br />
<br />
Since Raspberry Pi does not have a clock, the Alpine Linux needs to know what the time is by using a<br />
[https://en.wikipedia.org/wiki/Network_Time_Protocol Network Time Protocol (NTP)] daemon. Make sure that you a<br />
NTP daemon installed and running. If you are not sure, then you can install NTP client by running the following<br />
command:<br />
<br />
{{cmd|setup-ntp}}<br />
<br />
Busybox NTP client might be the most lightweight solution. Save the changes and reboot, once the NTP software is<br />
installed and running:<br />
<br />
{{cmd|lbu commit -d<br />
reboot}}<br />
<br />
After reboot, make sure that the <code>date</code> command outputs the correct date and time.<br />
<br />
=== WiFi on boot ===<br />
If you have already [[Connecting_to_a_wireless_access_point|configured wifi]] during the setup, the connection will not return on reboot.<br />
You will need to start up a service to automatically connect to the wireless access point.<br />
# Run <code>rc-update add wpa_supplicant boot</code> to connect to the wireless access point on boot.<br />
# Run it manually with <code>/etc/init.d/wpa_supplicant start</code>.<br />
<br />
=== X11 Setup ===<br />
Here are what you need if you want to try and run a single X11 application like a browser kiosk or maybe even a desktop: {{cmd|setup-xorg-base <br />
apk add xf86-video-fbdev xf86-video-vesa xf86-input-mouse xf86-input-keyboard dbus setxkbmap kbd <br />
rc-update add dbus}}<br />
<br />
Install XFCE:<br />
{{cmd|apk add xfce4}}<br />
<br />
Commit your changes:<br />
{{cmd|lbu_commit -d}}<br />
<br />
<br />
{{cmd|startx}}<br />
<br />
=== Enable OpenGL (RPi 3) ===<br />
<br />
Remount the boot partition writeable (ie. /media/mmcblk0p1):<br />
<br />
{{cmd|mount -o remount,rw /media/mmcblk0p1}}<br />
<br />
Add the following lines to /media/mmcblk0p1/config.txt <br />
<br />
dtoverlay=vc4-kms-v3d<br />
gpu_mem=128<br />
<br />
256MB gpu_mem is also possible<br />
<br />
Install mesa-dri-vc4:<br />
{{cmd|apk add mesa-dri-vc4}}<br />
<br />
Reboot:<br />
<br />
{{cmd|lbu_commit -d; reboot}}<br />
<br />
== Persistent storage ==<br />
<br />
=== Loopback image with overlayfs ===<br />
<br />
The install is in disk-less mode and forces everything into memory, if you want additional storage we need to create loop-back storage onto the SD mounted with overlayfs.<br />
<br />
First make the sd-card writable again and change fstab to always do so:<br />
{{cmd|mount /media/mmcblk0p1 -o rw,remount<br />
sed -i 's/vfat\ ro,/vfat\ rw,' /etc/fstab}}<br />
<br />
Create the loop-back file, this example is 1 GB:<br />
<br />
{{cmd|dd if&#61;/dev/zero of&#61;/media/mmcblk0p1/persist.img bs&#61;1024 count&#61;0 seek&#61;1048576}}<br />
<br />
Install the ext utilities:<br />
<br />
{{cmd|apk add e2fsprogs}}<br />
<br />
Format the loop-back file:<br />
<br />
{{cmd|mkfs.ext4 /media/mmcblk0p1/persist.img}}<br />
<br />
Mount the storage: <br />
<br />
{{cmd|echo "/media/mmcblk0p1/persist.img /media/persist ext4 rw,relatime,errors&#61;remount-ro 0 0" >> /etc/fstab<br />
mkdir /media/persist <br />
mount -a}}<br />
<br />
Make the overlay folders, we are doing /usr here, but you can do /home or anything else:<br />
<br />
{{cmd|mkdir /media/persist/usr <br />
mkdir /media/persist/.work <br />
echo "overlay /usr overlay lowerdir&#61;/usr,upperdir&#61;/media/persist/usr,workdir&#61;/media/persist/.work 0 0" >> /etc/fstab <br />
mount -a}}<br />
<br />
Your /etc/fstab should look something like this:<br />
{{Cmd|/dev/cdrom /media/cdrom iso9660 noauto,ro 0 0<br />
/dev/usbdisk /media/usb vfat noauto,ro 0 0<br />
/dev/mmcblk0p1 /media/mmcblk0p1 vfat rw,relatime,fmask&#61;0022,dmask&#61;0022,errors&#61;remount-ro 0 0<br />
/media/mmcblk0p1/persist.img /media/persist ext4 rw,relatime,errors&#61;remount-ro 0 0<br />
overlay /usr overlay lowerdir&#61;/usr,upperdir&#61;/media/persist/usr,workdir&#61;/media/persist/.work 0 0}}<br />
<br />
Now commit the changes: (optionally remove the e2fsprogs, but it does contain repair tools)<br />
{{cmd|lbu_commit -d}}<br />
<br />
Remember with this setup, if you install things and you have done this overlay for /usr, you must not commit the 'apk add', otherwise while it boots it will try and install it to memory and not to the persist storage.<br />
<br />
If you do want to install something small at boot you can use `apk add` and `lbu commit -d`.<br />
<br />
If it is something a bit bigger then you can use `apk add` but then not commit it, it will be persistent (in /user), but do check everything you need is in that directory and not in folders you have not made persistent.<br />
<br />
=== Traditional disk-based (sys) installation ===<br />
<br />
{{Warning|This isn't yet supported by the Alpine setup scripts for Raspberry Pi. It requires manual intervention, and might break.}}<br />
<br />
It is also possible to switch to a fully disk-based installation: this is not yet formally supported, but can be done somewhat manually. This frees all the memory otherwise needed for the root filesystem, allowing more installed packages.<br />
<br />
Split your SD card into two partitions: the FAT32 boot partition described above (in this example it'll be <code>mmcblk0p1</code>) , and a second partition to hold the root filesystem (here it'll be <code>mmcblk0p2</code>). Boot and configure your diskless system as above, then create a root filesystem:<br />
<br />
{{cmd|apk add e2fsprogs<br />
mkfs.ext4 /dev/mmcblk0p2}}<br />
<br />
Now do a disk install via a mountpoint. The <code>setup-disk</code> script will give some errors about syslinux/extlinux, but you can ignore these: the Raspberry Pi doesn't need this to boot anyway.<br />
<br />
{{cmd|<nowiki>mkdir /stage<br />
mount /dev/mmcblk0p2 /stage<br />
setup-disk -o /media/mmcblk0p1/MYHOSTNAME.apkovl.tar.gz /stage<br />
# (ignore errors about syslinux/extlinux)</nowiki>}}<br />
<br />
Add a line to <code>/stage/etc/fstab</code> to mount the Pi's boot partition again:<br />
<br />
{{cmd|/dev/mmcblk0p1 /media/mmcblk0p1 vfat defaults 0 0}}<br />
<br />
Now add a <code>root=/dev/mmcblk0p2</code> parameter to the Pi's boot command line, either <code>cmdline-rpi2.txt</code> or <code>cmdline-rpi.txt</code> depending on model:<br />
<br />
{{cmd|<nowiki>mount -o remount,rw /media/mmcblk0p1<br />
sed -i '$ s/$/ root=\/dev\/mmcblk0p2/' /media/mmcblk0p1/cmdline-rpi2.txt</nowiki>}}<br />
<br />
You might also consider <code>overlaytmpfs=yes</code> here, which will cause the underlying SD card root filesystem to be mounted read-only, with an overlayed tmpfs for modifications which will be discarded on shutdown.<br />
<br />
Beware, though, that <b>the contents of /boot will be ignored when the Pi boots</b>: it will use the kernel, initramfs, and modloop images from the FAT32 boot partition. To update the kernel, initfs or modules, you will need to manually (generate and) copy these to the boot partition or you could use bind mount so that manually copy the files to boot partition is not needed.<br />
<br />
{{cmd|<nowiki>echo /media/mmcblk0p1/boot /boot none defaults,bind 0 0 >> /etc/fstab</nowiki>}}<br />
<br />
=== Persistent Installation on RPi3 ===<br />
<br />
See this page : https://wiki.alpinelinux.org/wiki/Classic_install_or_sys_mode_on_Raspberry_Pi<br />
<br />
See https://web.archive.org/web/20171125115835/https://forum.alpinelinux.org/comment/1084#comment-1084<br />
<br />
== See Also ==<br />
<br />
* [[Classic install or sys mode on Raspberry Pi]] - a variant.<br />
* [[Raspberry Pi 3 - Setting Up Bluetooth]]<br />
* [[Raspberry Pi 3 - Configuring it as wireless access point -AP Mode]]<br />
* [[Linux Router with VPN on a Raspberry Pi]]<br />
* [[Create a bootable SDHC from a Mac]]<br />
* Build custom Raspberry Pi images based on Alpine via [https://github.com/tolstoyevsky/pieman Pieman]</div>Shimaorehttps://wiki.alpinelinux.org/w/index.php?title=Talk:Raspberry_Pi&diff=15739Talk:Raspberry Pi2019-03-02T14:50:50Z<p>Shimaore: Suggest adding a section on which build to use</p>
<hr />
<div><br />
== Persistence ==<br />
Wouldn't it be more reasonable to partition the SD-Card accordingly? That way, you could have FS > 2GB, too. --[[User:Kurushiyama|Kurushiyama]] ([[User talk:Kurushiyama|talk]]) 10:53, 8 October 2016 (UTC)<br />
<br />
I have read that using a journalling fs is not a good idea for SD cards as it shortens their life by multiplying the read/writes. Wouldn't ext2 thus be a better fs for persistent overlays? -- [[User:Nevarmaor|Nevarmaor]] ([[User talk:Nevarmaor|talk]]) 21:56, 20 February 2017 (UTC)<br />
<br />
== Installing Alpine- Linux on raspberry pi zero w (udhcpc fail problem) ==<br />
<br />
The existing tutorial for raspberry pi is followed except on the reboot, the udhcpc attempts to connect and fails. I managed to fix this problem by editing the /etc/network/interfaces file and add the line:<br />
<br />
iface wlan0 inet dhcp<br />
pre-up wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf #<--This is the line added to pre-start the wpa_supplicant daemon and log on correctly. <br />
<br />
I learned this with the help of the tutorial by Jack Wallen: How to Configure Wireless... on linux.com website<br />
<br />
== Which version should I use? ==<br />
<br />
There are now three versions of Alpine to choose from (armv7, armhf, aarch64), it might be useful to have a table indicating which version is supported on which hardware. (I'm already unclear on why armv7 and armhf, I assume both are 32 bits and armv7 has soft-float-point instead of hard-float-point, but don't all RPi devices have hard-float-point capabilities? It would be useful to have a little text about this.)<br />
<br />
As I understand aarch64 only applies to BCM2837 and above chips (ARMv8 and above), which means it can only run on RPi 3 and above (but I believe RPi 3 and above should be able to use the other images since they also support the 32 bits mode).<br />
<br />
Conversely I assume armhf should be usable on all RPi.</div>Shimaore