Upgrading Alpine Linux to a new release branch
Upgrading an Alpine Linux Hard-disk installation
Upgrading to latest release
Update Repositories File
First step is to to check the /etc/apk/repositories file and update it using one of the following methods.
Using setup-apkrepos script
Launching the corresponding Alpine setup script,
# setup-apkrepos
and pressing e to edit /etc/apk/repositories using the default vi editor. Then editing the repository lines to reflect the new version number.
Using sed command
One can also use a one-line command to edit all version numbers in the file "in place". Here's how you'd change v3.19 to v3.20:
# sed -i -e 's/v3\.19/v3\.20/g' /etc/apk/repositories
Manual editing of /etc/apk/repositories
Edit the /etc/apk/repositories file using any editor of your choice (nano for instance) to edit the Alpine Linux package repositories.
Contents of /etc/apk/repositories
In the above file, to upgrade Alpine Linux from version 3.19 to 3.20, simply replace the number 3.19 by 3.20 in all the places, so that the updated repositories file looks like below:
Contents of /etc/apk/repositories
Using latest-stable instead of version number
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
latest-stable
may initiate unexpected release upgrades. So beware of the consequences of unexpected release upgrades, when using latest-stable
.
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
.
When using edge branch, testing repository can be added if the packages that one needs are available only in testing repository.
Contents of /etc/apk/repositories
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 any editor of your choice (nano for instance) to edit the Alpine Linux package repositories.
Contents of /etc/apk/repositories
In the above file, to upgrade Alpine Linux from version 3.19 to 3.20, simply replace the number 3.19 by 3.20 in all the places, so that the updated repositories file looks like below:
Contents of /etc/apk/repositories
Ensure you have the latest available version of the Alpine Linux Package Manager first before upgrading anything else:
apk add -u apk-tools
apk upgrade sync
Upgrading Alpine Linux on Flash Memory (such as CF/USB)
Your installation may consist of Alpine Linux running on Compact Flash or USB media. In most cases, it should be sufficient to upgrade most packages using the Alpine Linux Hard-disk Installation upgrade procedures described above. However, for new packages to survive after a reboot, you should enable APK caching.
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.
You need at least 400MB available space.
df -h
Download and verify new release
Make sure the media is mounted readwrite.
mount --remount rw /media/$LBU_MEDIA
setup-bootable -u {{#latestalp:alpine|url}} /media/$LBU_MEDIA
Once the command completes, proceed to the Load new kernel section.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.
Copy the new release
setup-bootable -u {{#latestalp:alpine|file}} /media/$LBU_MEDIA
Once the command completes, proceed to the Load new kernel section.Mount the ISO.
mount -t iso9660 {{#latestalp:alpine|file}} /mnt
Back up files that you have modified. For example, you might have modified syslinux.cfg to show console output on a serial port.
cp /media/$LBU_MEDIA/syslinux.cfg /media/$LBU_MEDIA/syslinux.cfg.my
Install the rsync package if necessary, and copy the files:
cd /mnt apk add rsync rsync --delete -rltv .alpine-release * /media/$LBU_MEDIA/
Restore your backed up files (in case you had any)
mv -f /media/$LBU_MEDIA/syslinux.cfg.my /media/$LBU_MEDIA/syslinux.cfg
Make sure that all files are permanently saved in right place
sync
Clean up
Clean up the downloaded/unpacked files
cd .. umount /mnt rm /media/$LBU_MEDIA/{{#latestalp:alpine|file}} rm /media/$LBU_MEDIA/{{#latestalp:alpine|file}}.sha1
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):
reboot
Update remaining packages from Web repository
If you are using APK caching you should perform the following steps:
Edit the /etc/apk/repositories file using any editor of your choice (nano for instance) to edit the Alpine Linux package repositories.
Contents of /etc/apk/repositories
In the above file, to upgrade Alpine Linux from version 3.19 to 3.20, simply replace the number 3.19 by 3.20 in all the places, so that the updated repositories file looks like below:
Contents of /etc/apk/repositories
Ensure you have the latest available version of the Alpine Linux Package Manager first before upgrading anything else:
apk add -u apk-tools
apk upgrade sync