community.riocities.com
  • Home
  • Categories
  • Tags
  • Archives

Alpine Linux RPi - upgrading

Upgrade guide for Alpine Raspberry PI (RPi) System¶

This guide describes how to upgrade a diskless (booting from the microSD card) Alpine RPi between Alpine releases.

It expects your microSD card to be mounted to the /media/mmcblk0p1 directory, if it is not mounted there on your system, adjust the instruction to match your case.

Preparations¶

Backup all data from the microSD card (/media/mmcblk0p1 directory) so you have a fall-back.

Download the version of the tar.gz you are upgrading to, as well as the GPG signature file, to your workstation.

Example with the files for an upgrade to Alpine v3.11.

workstation $ curl -O <URL>/alpine-rpi-3.11.6-armv7.tar.gz
workstation $ curl -O <URL>/alpine-rpi-3.11.6-armv7.tar.gz.asc
workstation $ gpg --verify alpine-rpi-3.11.6-armv7.tar.gz.asc

Replace <URL> above with the path to the download server used; e.g. http://nl.alpinelinux.org/alpine/v3.11/releases/armv7/.

Copy alpine-rpi-3.11.6-armv7.tar.gz to your RPi (suggestion in /tmp/).

Perform the upgrade of the running system.¶

Check that LBU_MEDIA, in file /etc/lbu/lbu.conf, points to the device used to store the persistent configuration. In my case its /media/mmcblk0p1. If its not /media/mmcblk0p1 in your case, adjust the commands below to fit your case (e.g. /media/mmcblk0p1 -> /media/<your device>).

Edit file /etc/apk/repositories to point at the version you are upgrading to, then run the upgrade.

rpi $ sudo -i
rpi # apk update
rpi # apk upgrade --update-cache --available

Commit the changes to /etc with the lbu command.

rpi # lbu commit

Quick upgrade (Option A)¶

Only use this method if you have physical access to your RPi while running the upgrade. This method might fail to boot (RPi stuck at black screen) and you will have to perform upgrade using Option B instead.

Upgrade the boot media in /media/mmcblk0p1

rpi # . /etc/lbu/lbu.conf
rpi # mount /media/$LBU_MEDIA -o remount,rw

rpi # mkdir /media/$LBU_MEDIA/new
rpi # cd /media/$LBU_MEDIA/new
rpi # tar xfz <path to tar file>/alpine-rpi-3.11.6-armv7.tar.gz
rpi # cd ..

rpi # setup-bootable -u /media/$LBU_MEDIA/new /media/$LBU_MEDIA
rpi # rm -rf /media/$LBU_MEDIA/new
rpi # lbu commit
rpi # cd /
rpi # mount /media/$LBU_MEDIA -o remount,ro

After this the RPi can be rebooted.

Safe upgrade (Option B)¶

This option uses an microSD memory card in the microSD card reader of the RPi.

This is a more safe way of upgrading, and should be used when you are performing the upgrade remotely or if you are cross upgrading from armhf to armv7.

WARNING Before continuing You should make sure that the (login) shell of the RPi remote user is a shell that is present in the base Alpine installation! For example the default shell /bin/ash.

Save /media/mmcblk0p1/<hostname>.apkovl.tar.gz and /media/mmcblk0p1/usercfg.txt outside of /media/mmcblk0p1/ (e.g. in /tmp).

Perform the upgrade.

rpi # . /etc/lbu/lbu.conf
rpi # mount /media/$LBU_MEDIA -o remount,rw
rpi # cd /media/$LBU_MEDIA
rpi # rm -rf * .alpine-release
rpi # tar xfz <path to tar file>/alpine-rpi-3.11.6-armv7.tar.gz
rpi # mkdir /media/$LBU_MEDIA/cache

Copy back the saved <hostname>.apkovl.tar.gz and usercfg.txt files to /media/mmcblk0p1/.

rpi # cp /tmp/<hostname>.apkovl.tar.gz /media/$LBU_MEDIA/
rpi # cp /tmp/usercfg.txt /media/$LBU_MEDIA/

Prepare for reboot.

rpi # sync
rpi # reboot

Now the RPi will boot with only the base packages (packages added in /etc/apk/world will not be present) so we need to update the apk cache and reboot again in order to have all packages.

After reboot, login and synchronize the apk cache and do the upgrade to restore additional packages.

rpi # apk update
rpi # apk cache sync
rpi # apk upgrade --update-cache --available
rpi # lbu commit
rpi # reboot

If you are using an RTC module please follow this guide as well: Alpine Linux on a Raspberry Pi 3 B+ with a RTC module


  • « Alpine Linux on a Raspberry Pi 3 B+ with a RTC module
  • NitroKey HSM in Alpine »

Published

Sep 29, 2020

Author

henrik

Category

HOWTOs

Tags

  • Alpine 15

Social

  • atom feed
  • rss feed
  • ipv6 ready
  • Powered by Pelican. Theme: Elegant by Talha Mansoor