Upgrading Alpine
This page covers upgrading to newer releases.
Doing regular security updates with the package manager is shown at Upgrading a running system.
![](/images/d/d8/Tango-dialog-warning.png)
Upgrading an Alpine Linux Hard-disk installation
Upgrading Alpine v2.x to v3.x
![](/images/d/d8/Tango-dialog-warning.png)
Installing statically linked tools
Statically linked version of apk-tools is needed, because the old musl version would stop working after a libc change (possibly in the middle of upgrade). Static version of busybox can be handy in case of the recovery from a failure.
apk add busybox-static apk-tools-static
Changing repositories to v3.x
To begin, you need to update your /etc/apk/repositories file. Here are some shortcuts for doing so:
- Launch
setup-apkrepos
Enter e to edit /etc/apk/repositories. Change the version number by hand. - Or, edit the file in place. This is how you'd change v2.7 to v3.0:
sed -i -e 's/v2\.7/v3.0/g' /etc/apk/repositories
- Launch
Upgrading system
Use statically linked version of apk to update content of repository:
apk.static update
Simulating upgrade is recommended in order to detect issues beforehand:
apk.static upgrade --no-self-upgrade --available --simulate
With no problems encountered or after resolving them, start proper upgrade:
apk.static upgrade --no-self-upgrade --available
Upgrading to latest release
Repository Settings
First thing is to to edit or check the /etc/apk/repositories file.
Besides doing it manually (see below) this may be done using one of the following shortcuts.
- Launching the corresponding Alpine setup script,
setup-apkrepos
and pressing e to edit /etc/apk/repositories. Then editing the repository lines to reflect the new version number. - Or, use a one-line command to edit all version numbers in the file "in place". Here's how you'd change v2.5 to v2.6:
sed -i -e 's/v2\.5/v2\.6/g' /etc/apk/repositories
- Launching the corresponding Alpine setup script,
Note, subsequent manual changes of the version numbers in /etc/apk/repositories may be avoided for future release upgrades by having the repository lines refer to "latest-stable" instead of an absolute value:
Contents of /etc/apk/repositories
However, beware of initiating unexpected release upgrades.
Manual editing of /etc/apk/repositories:
Edit the /etc/apk/repositories file using an editor (nano for instance) and if necessary, add references to the Alpine package repositories. In the example below, the file references the Alpine CD, so that if a requested package is available on the local media, it will be obtained from there instead of being downloaded from the remote repository:
Contents of /etc/apk/repositories
To upgrade, in this example, from version 3.3 to 3.2, simply change:
http://dl-3.alpinelinux.org/alpine/v3.3/main
to
http://dl-3.alpinelinux.org/alpine/v3.2/main
So that the file will look like this:
Contents of /etc/apk/repositories
http://dl-3.alpinelinux.org/alpine/v3.2/community
Above, only one possible repository is shown, however, http://dl-3.alpinelinux.org/alpine/
may also be replaced with any geographically close mirror from:
http://rsync.alpinelinux.org/alpine/MIRRORS.txt
Updating package lists
With the correct repositories file in place, the latest index list of available packages can be obtained with:
apk update
--update-cache
or -U
to another apk command, as in apk add -U ...
or apk upgrade -U
, has the same effect as always running apk update
immediately before the other apk command. Instead of auto-update it only if the index has not been updated recently.Upgrading packages
At times it is required to first upgrade just the Alpine Linux Package Manager itself to the latest available version, before upgrading any other package. This was the case, for example, when upgrading from a version of Alpine before 2.3.0_rc1. But simply always doing so shouldn't hurt, either:
apk add --upgrade apk-tools
Next, to upgrade all installed packages:
apk upgrade --available
The --available
switch is used to force all packages to be upgraded, even if they have the same version numbers. Sometimes changes in musl require doing this.
sync reboot
Upgrading to Edge
An upgrade of Alpine Linux from a stable version to the rolling development version edge basically requires the same steps as Upgrading to latest release.
The crucial difference is, that when editing the /etc/apk/repositories file, all referenced repository versions (such as v3.2
or latest-stable
) therein need to be pointing to edge
as in:
https://<mirror-server>/alpine/edge/main
![](/images/d/d8/Tango-dialog-warning.png)
After upgrading to edge, the currently installed edge version may be checked with
$ cat /etc/alpine-release
and referring to the build date that is attached to the release.
Upgrading from older versions
See Upgrading from older versions.
Upgrading Alpine Linux on CD
You may have an installation where the boot media being used (such as a CD, for example) is separate from the media used to store the configuration information. In this case, simply download the latest ISO, and replace the boot media contents with the contents of the latest ISO. If you are booting from a CD, this would simply mean replacing the CD with a CD made from the new image and rebooting the Alpine Linux box.
Update remaining packages from Web repository
If you are using APK caching you should also perform the following steps.
Edit the /etc/apk/repositories file using an editor (nano for instance) and if necessary, add references to the Alpine package repositories. In the example below, the file references the Alpine CD, so that if a requested package is available on the local media, it will be obtained from there instead of being downloaded from the remote repository:
Contents of /etc/apk/repositories
To upgrade, in this example, from version 3.3 to 3.2, simply change:
http://dl-3.alpinelinux.org/alpine/v3.3/main
to
http://dl-3.alpinelinux.org/alpine/v3.2/main
So that the file will look like this:
Contents of /etc/apk/repositories
http://dl-3.alpinelinux.org/alpine/v3.2/community
Above, only one possible repository is shown, however, http://dl-3.alpinelinux.org/alpine/
may also be replaced with any geographically close mirror from:
http://rsync.alpinelinux.org/alpine/MIRRORS.txt
Updating package lists
With the correct repositories file in place, the latest index list of available packages can be obtained with:
apk update
--update-cache
or -U
to another apk command, as in apk add -U ...
or apk upgrade -U
, has the same effect as always running apk update
immediately before the other apk command. Instead of auto-update it only if the index has not been updated recently.If you're upgrading from a version of Alpine before 2.3.0_rc1, ensure you have the latest available version of the Alpine Linux Package Manager first before upgrading anything else:
apk add --upgrade apk-tools
Next, upgrade all your packages:
apk upgrade --available sync
The --available
switch is used to force all packages to be upgraded, even if they have the same version numbers. Sometimes changes in uClibc require doing this.
After upgrading packages, save any configuration changes (you should have backed up your earlier configuration prior to upgrading).
lbu ci
Upgrading Alpine Linux on other removable media (such as CF/USB)
The following instructions are for run-from-RAM Alpine installations running on Compact Flash or USB media. Updating your repositories using the procedures detailed above, then running:
apk upgrade --update-cache --available
will suffice for some purposes. (If you want the new packages to be used after a reboot, you should enable APK caching.)
However, this is not an adequate general solution because it won't honor any kernel upgrades and the like. For the general solution, you'll need to upgrade your boot medium (Compact Flash or USB). That is what the following steps describe how to do.
Setup environment variables
To make the documentation a bit more "generic" we start by setting some environment variables.
vi /etc/lbu/lbu.conf
Make sure that the variable LBU_MEDIA
is not commented (by removing the leading '#').
You also need to set a appropriate value for your LBU_MEDIA
. The media you choose will be the media where you store your settings/configuration.
Examples:
LBU_MEDIA=usb
or:
LBU_MEDIA=sda1
Now that you have your /etc/lbu/lbu.conf configured for your needs, we will set the environment variables (note the leading .
).
. /etc/lbu/lbu.conf
You can test if your environment variable was set:
echo $LBU_MEDIA
It should output something like usb
, sda1
, or whatever you just configured.
Back up your config
Before starting to upgrade, it's wise to save your configuration.
lbu ci
Upgrade Operating System
Start by checking that you have enough space on your media. For a standard Alpine image, you need at least 400MB available space.
df -h | grep "Filesystem\|$LBU_MEDIA"
Download and verify new release
Make sure the media that holds your Alpine system is mounted readwrite.
mount -oremount,rw /media/$LBU_MEDIA
If using Alpine Linux 2.2.3 or newer: Download the latest release,
wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/<arch>/<image>.iso
and then use the following command to mount and copy files as needed for you:
setup-bootable -u alpine-extended-<version>-<arch>.iso /media/$LBU_MEDIA
Once the command completes, proceed to the Save changes section.
For older versions of Alpine
Start downloading a new '.iso' and a '.sha1' file
cd /media/$LBU_MEDIA wget -c {{#latestalp:alpine|url}} wget {{#latestalp:alpine|url}}.sha1
Check integrity of the downloaded files (it might take some time):
sha1sum -c {{#latestalp:alpine|file}}.sha1
The output of the above command should say 'OK'.
If says 'FAILED', delete the iso file and download it again.
If using Alpine Linux 1.10.4 or newer: there is a tool setup-bootable that will mount and copy the image you just downloaded to your boot medium. With this tool simply do:
setup-bootable -u {{#latestalp:alpine|file}} /media/$LBU_MEDIA
Instructions for older versions of Alpine are located elsewhere.
Save changes
Now that all upgrades are done, we should save our settings to our media (which you hopefully have backed up prior to doing this upgrade).
lbu ci
Load new kernel
In most cases you will need to reboot Alpine Linux (especially if there are changes in the kernel):
sync reboot
Update to latest kernel on armhf (eg. Raspberry Pi 0 or 1)
On Alpine 3.X and newer, kernel is not upgraded when using apk upgrade
and setup-bootable
does not work properly.
If you want to upgrade your kernel, you will need to get it from the latest release, but first you must have and run :
apk update; apk version -l '<'; apk upgrade; lbu ci;
So now all your packages are upgraded, you can upgrade your kernel.
1. We need to get some variables :
. /etc/os-release; . /etc/lbu/lbu.conf;
2. You must verify if they are correctly set, using this :
echo "alpine version : $VERSION_ID"; echo "lbu media : $LBU_MEDIA";
3. And it will output something like this (if not, do not continue this process) :
alpine version : 3.13.5 lbu media : mmcblk0p1
4. Then you can run this script :
cd /media/$LBU_MEDIA; mount -oremount,rw /media/$LBU_MEDIA; wget https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf/alpine-rpi-$VERSION_ID-armhf.tar.gz; wget https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf/alpine-rpi-$VERSION_ID-armhf.tar.gz.sha256; sha256sum -c *.sha256; tar xzf alpine-rpi-$VERSION_ID-armhf.tar.gz; rm alpine-rpi-$VERSION_ID-armhf.tar.gz alpine-rpi-$VERSION_ID-armhf.tar.gz.sha256; sync; reboot;
5. Test-it !
uname -a
Update remaining packages from Web repository
If you are using APK caching you should follow the instructions to Update remaining packages from Web repository, above.