How to upgrade Alpine Linux 3.19 to 3.20

See all Alpine Linux related FAQ
I am using Alpine Linux v3.18 or v3.19 with my LXD/Incus server. How do I upgrade Alpine Linux v3.19 to Alpine Linux v3.20? How can I upgrade Alpine Linux v3.18 to Alpine Linux v3.20?

Before you type any one of the following command make sure that you have a backup of your important data before continuing to update your system. It is important that you keep full backup of your system. Alpine Linux is built around musl libc and busybox. This makes it smaller and more resource efficient than traditional GNU/Linux distributions. A container requires no more than 8 MB and a minimal installation to disk requires around 130 MB of storage. Not only do you get a fully-fledged Linux environment but a large selection of packages from the repository. It is perfect for Docker too.
Fig.01: upgrade Alpine Linux Hard-disk or LXD VM installation

Fig.01: Upgrading an Alpine Linux Hard-disk installation

Alpine Linux was designed with security in mind. All userland binaries are compiled as Position Independent Executables (PIE) with stack smashing protection. These proactive security features prevent exploitation of entire classes of zero-day and other vulnerabilities. When Alpine Linux is installed to hard drive or as LXD VM, upgrading to a newer stable version is straightforward.
Tutorial details
Difficulty level Intermediate
Root privileges Yes
Requirements Linux terminal
Category Package Manager
OS compatibility Alpine Linux
Est. reading time 4 minutes
Advertisement

📢 Make a backup of all critical data, config files, and databases before starting the upgrade procedure. The nixCraft or author is not responsible for any data loss.

How to upgrade Alpine Linux

When Alpine Linux is installed to hard drive or cloud server, upgrading to a newer stable version is easy:

  1. Apply pending updates to existing installation by running:# apk update
    # apk upgrade
  2. Edit the /etc/apk/repositories file, run: # vi /etc/apk/repositories
  3. Change the version number by hand. For example, Alpine 3.19 to 3.20.
  4. Save and close the file
  5. Fetch latest index by running the # apk update
  6. Upgrade all your Alpine Linux packages: # apk upgrade --available && sync
  7. Reboot the system, run: # reboot

Let us see all commands and examples in details.

What’s new in Alpine Linux 3.20.0

OpenSSL 3.0.x is now the default OpenSSL version. OpenSSL 1.1 is available via the openssl1.1-compat package. Other improvements in the setup scripts:

  • Initial support for 64 bit RISC-V was added.
  • Linux kernel 6.3.x – with signed kernel modules
  • musl libc 1.2.5
  • Python 3.12
  • Ruby 3.3
  • GNOME 46
  • Go 1.20
  • bash version 5.2
  • GCC 12.2
  • Better support for NVMe
  • LLVM 18
  • OpenSSL 3.3.xx
  • Perl 5.38.2
  • PostgreSQL 15/16
  • MariaDB 10.11
  • Node.js (lts) 20.10
  • Ceph 17.xx/18.xx
  • Go 1.22
  • KDE Plasma 6
  • Rust 1.78
  • .NET 8.0
  • PHP 8.3/8.2

See release notes.

Make a backup of your LXD container

Type the following command to create container snapshots:
$ lxc snapshot alpine-www01 "May242024-Before-Upgrade-To-3.20"
Verify it:
$ lxc info alpine-www01
Sample outputs:

Name: alpine-www01
Status: RUNNING
Type: container
Architecture: x86_64
PID: 1674
Created: 2023/07/08 09:29 UTC
Last Used: 2024/02/15 21:33 UTC

Resources:
  Processes: 14
  Disk usage:
    root: 219.90MiB
  CPU usage:
    CPU usage (in seconds): 31
  Memory usage:
    Memory (current): 64.38MiB
  Network usage:
    eth0:
      Type: broadcast
      State: UP
      Host interface: vethe29a4e49
      MAC address: 00:16:3e:5b:af:3e
      MTU: 1500
      Bytes received: 31.02MB
      Bytes sent: 60.60MB
      Packets received: 177349
      Packets sent: 177089
      IP addresses:
        inet:  10.147.164.14/24 (global)
        inet6: fe80::216:3eff:fe5b:af3e/64 (link)
    lo:
      Type: loopback
      State: UP
      MTU: 65536
      Bytes received: 48.22MB
      Bytes sent: 48.22MB
      Packets received: 80074
      Packets sent: 80074
      IP addresses:
        inet:  127.0.0.1/8 (local)
        inet6: ::1/128 (local)

Snapshots:
+----------------------------------+----------------------+----------------------+----------+
|               NAME               |       TAKEN AT       |      EXPIRES AT      | STATEFUL |
+----------------------------------+----------------------+----------------------+----------+
| autoupdate-2023-11-16-1700123714 | 2023/11/16 08:35 UTC | 2024/02/16 08:35 UTC | NO       |
+----------------------------------+----------------------+----------------------+----------+
| autoupdate-2023-11-21-1700592447 | 2023/11/21 18:47 UTC | 2024/02/21 18:47 UTC | NO       |
+----------------------------------+----------------------+----------------------+----------+
| autoupdate-2023-11-23-1700729943 | 2023/11/23 08:59 UTC | 2024/02/23 08:59 UTC | NO       |
...
.....
..
| Feb022024-Before-Upgrade-To-3.19 | 2024/02/16 01:00 UTC | 2024/05/16 01:00 UTC | NO       |
+----------------------------------+----------------------+----------------------+----------+


Now login to your Alpine Linux box/LXD VM using ssh command or lxc command.

Find out your Alpine Linux version

Type the following cat command:
$ cat /etc/alpine-release
3.19.1

Apply all pending updates for 3.19.xx

Simply run the apk command:
# apk update
# apk upgrade

(1/3) Upgrading bind-libs (9.16.33-r0 -> 9.16.36-r0)
(2/3) Upgrading bind-tools (9.16.33-r0 -> 9.16.36-r0)
(3/3) Upgrading linux-virt (5.15.84-r0 -> 5.15.85-r0)
Executing busybox-1.35.0-r17.trigger
Executing kmod-29-r2.trigger
Executing mkinitfs-3.6.2-r0.trigger
==> initramfs: creating /boot/initramfs-virt
Executing grub-2.06-r2.trigger
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-virt
Found initrd image: /boot/initramfs-virt
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
done
Executing syslinux-6.04_pre1-r10.trigger
/boot is device /dev/sda
extlinux: no previous syslinux boot sector found
OK: 270 MiB in 242 packages
Reboot the machine when a new Linux kernel is installed using the reboot command or shutdown command. For example:
# reboot

How to upgrading to latest release

Edit the /etc/apk/repositories file, enter:
# vi /etc/apk/repositories
Change the version number by hand. For example, the default entry for 3.19 is as follows:

http://dl-cdn.alpinelinux.org/alpine/v3.19/main

To update to 3.20, enter:

http://dl-cdn.alpinelinux.org/alpine/v3.20/main

Save and close the file. Here is my sample config file displayed using cat command:
# cat /etc/apk/repositories
Here is my updated file:

https://dl-cdn.alpinelinux.org/alpine/v3.20/main
https://dl-cdn.alpinelinux.org/alpine/v3.20/community

It is also possible to use the last stable release on the repository file. For instance:

http://dl.alpinelinux.org/alpine/latest-stable/main
http://dl.alpinelinux.org/alpine/latest-stable/community

I avoid setting up the last stable release as I update my Alpine Linux fleet using Ansible. So I need to verify manually and then run Ansible job for multiple servers.

Upgrading alpine Linux

Next, grab the latest index using apk command:
# apk update
Sample outputs:

fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/community/x86_64/APKINDEX.tar.gz
v3.20.0-7-g04aec3b1d0c [https://dl-cdn.alpinelinux.org/alpine/v3.20/main]
v3.20.0-6-g38613459a10 [https://dl-cdn.alpinelinux.org/alpine/v3.20/community]
OK: 24330 distinct packages available

Try to detect upgrade problems by simulating the procedure to avoid downtime. Hence, pass the following options:
# rm /etc/alpine-release
# apk upgrade --no-self-upgrade --available --simulate

Dry run output:

(1/188) Upgrading alpine-baselayout-data (3.4.3-r2 -> 3.6.5-r0)
(2/188) Upgrading musl (1.2.4_git20230717-r4 -> 1.2.5-r0)
(3/188) Upgrading busybox (1.36.1-r18 -> 1.36.1-r28)
(4/188) Upgrading busybox-binsh (1.36.1-r18 -> 1.36.1-r28)
(5/188) Upgrading alpine-baselayout (3.4.3-r2 -> 3.6.5-r0)
(6/188) Upgrading ifupdown-ng (0.12.1-r4 -> 0.12.1-r5)
(7/188) Upgrading libcap2 (2.69-r1 -> 2.70-r0)
(8/188) Upgrading openrc (0.52.1-r2 -> 0.54-r1)
(9/188) Upgrading mdev-conf (4.6-r0 -> 4.7-r0)
(10/188) Upgrading busybox-mdev-openrc (1.36.1-r18 -> 1.36.1-r28)
.....
.......
(181/188) Upgrading linux-pam (1.5.3-r7 -> 1.6.0-r0)
(182/188) Upgrading runuser (2.39.3-r0 -> 2.40.1-r1)
(183/188) Replacing sed (4.9-r2 -> 4.9-r2)
(184/188) Upgrading shellcheck (0.9.0-r4 -> 0.10.0-r1)
(185/188) Upgrading vim-common (9.0.2127-r0 -> 9.1.0414-r0)
(186/188) Upgrading xxd (9.0.2127-r0 -> 9.1.0414-r0)
(187/188) Upgrading vim (9.0.2127-r0 -> 9.1.0414-r0)
(188/188) Upgrading wget (1.21.4-r0 -> 1.24.5-r0)
OK: 232 MiB in 187 packages

If no problems found or after solving them, start the proper upgrade procedure. Hence, type any one of the following command to upgrade all your packages, run apk command:
# apk upgrade --available
Look out for messages and warnings:

(1/188) Upgrading alpine-baselayout-data (3.4.3-r2 -> 3.6.5-r0)
(2/188) Upgrading musl (1.2.4_git20230717-r4 -> 1.2.5-r0)
(3/188) Upgrading busybox (1.36.1-r18 -> 1.36.1-r28)
Executing busybox-1.36.1-r28.post-upgrade
(4/188) Upgrading busybox-binsh (1.36.1-r18 -> 1.36.1-r28)
(5/188) Upgrading alpine-baselayout (3.4.3-r2 -> 3.6.5-r0)
Executing alpine-baselayout-3.6.5-r0.pre-upgrade
Executing alpine-baselayout-3.6.5-r0.post-upgrade
(6/188) Upgrading ifupdown-ng (0.12.1-r4 -> 0.12.1-r5)
(7/188) Upgrading libcap2 (2.69-r1 -> 2.70-r0)
(8/188) Upgrading openrc (0.52.1-r2 -> 0.54-r1)
Executing openrc-0.54-r1.post-upgrade
(9/188) Upgrading mdev-conf (4.6-r0 -> 4.7-r0)
(10/188) Upgrading busybox-mdev-openrc (1.36.1-r18 -> 1.36.1-r28)
(11/188) Upgrading alpine-conf (3.17.2-r0 -> 3.18.0-r0)
(12/188) Replacing alpine-keys (2.4-r1 -> 2.4-r1)
(13/188) Upgrading alpine-release (3.19.1-r0 -> 3.20.0-r0)
(14/188) Replacing ca-certificates-bundle (20240226-r0 -> 20240226-r0)
....
......
..
(177/188) Upgrading py3-pygments (2.17.2-r0 -> 2.18.0-r0)
(178/188) Upgrading libeconf (0.5.2-r2 -> 0.6.3-r0)
(179/188) Upgrading skalibs (2.14.0.1-r0 -> 2.14.1.1-r0)
(180/188) Upgrading utmps-libs (0.1.2.2-r0 -> 0.1.2.2-r1)
(181/188) Upgrading linux-pam (1.5.3-r7 -> 1.6.0-r0)
(182/188) Upgrading runuser (2.39.3-r0 -> 2.40.1-r1)
(183/188) Replacing sed (4.9-r2 -> 4.9-r2)
(184/188) Upgrading shellcheck (0.9.0-r4 -> 0.10.0-r1)
(185/188) Upgrading vim-common (9.0.2127-r0 -> 9.1.0414-r0)
(186/188) Upgrading xxd (9.0.2127-r0 -> 9.1.0414-r0)
(187/188) Upgrading vim (9.0.2127-r0 -> 9.1.0414-r0)
(188/188) Upgrading wget (1.21.4-r0 -> 1.24.5-r0)
Executing busybox-1.36.1-r28.trigger
Executing ca-certificates-20240226-r0.trigger
OK: 210 MiB in 179 packages

Restart the server/VM container using the reboot command:
# sync
# reboot

Verify it:
$ cat /etc/alpine-release
3.20.0

Please note that in some case /etc/alpine-release may not be updated, so query:
cat /etc/alpine-release.apk-new

Another alternative is to query /etc/issue:
# cat /etc/issue

Welcome to Alpine Linux 3.20
Kernel \r on an \m (\l)

Here is how it actually looks:

Welcome to Alpine Linux 3.20
Kernel 6.6.31-0-virt on an x86_64 (/dev/console)

alpine-www01 login: 

One can query the /etc/os-release:
# cat /etc/os-release
Outputs:

NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.20.0
PRETTY_NAME="Alpine Linux v3.20"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"

Do check Linux kernel version, run the following uname command:
# uname -mrs
Linux 6.6.31-0-virt x86_64

Check log files using the grep command or cat command/tail command/more command:
# tail -f /var/log/messages
# grep -i -E 'err|warn|alert' /var/log/my_app.log

Make sure all ports are open using the ss command or netstat command:
# ss -tulpn
OR
# netstat -tulpn

Conclusion – Upgrade Alpine Linux

And there you have it, Alpine Linux upgraded from version 3.19 to 3.20. For more information see project home page (https://alpinelinux.org/).

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

5 comments… add one
  • Dimdo Feb 6, 2017 @ 15:29

    Why two slashes?

  • Legion Anonymous Feb 17, 2017 @ 3:33


    RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.5/main' | tee -a /etc/apk/repositories \
    && echo 'http://dl-cdn.alpinelinux.org/alpine/v3.5/community' | tee -a /etc/apk/repositories \
    && apk upgrade --purge

  • Jimmy Jan 20, 2021 @ 7:36

    Perfect. Just before running apk upgrade –available I do this
    # rm /etc/alpine-release
    So after reboot my server will have correct version.

  • Anonymous Feb 16, 2024 @ 2:50

    Hey, thank you so much. Just upgraded from 3.16 to 3.19 EC2.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.