Home Alpine Linux How To Upgrade Alpine Linux To Latest Version

How To Upgrade Alpine Linux To Latest Version

By sk
26K views

The Alpine Linux development team announced the latest stable release of Alpine Linux 3.15.0 on November 24, 2021. This step by step guide explains how to upgrade Alpine Linux to latest available stable version or rolling release version.

What's new in Alpine Linux 3.15?

Alpine Linux 3.15.0 is the first release in the v3.15 stable series. It ships the latest Linux Kernel 5.15 LTS version.

Alpine Linux 3.15.0 version ships with many important updates and changes. Some notable changes are:

  • Kernel modules are now compressed with gzip.
  • Framebuffer drivers have been disabled in kernel and replaced by simpledrm.
  • qt5-qtwebkit and related packages have been removed due to lack of upstream support.
  • The MIPS64 port is discontinued.

The other significant updates are;

  • llvm 12
  • nodejs 16.13 (LTS) / nodejs-current 17.0
  • postgresql 14
  • openldap 2.6
  • ruby 3.0
  • rust 1.56
  • openjdk 17
  • kea 2.0
  • xorg-server 21.1
  • GNOME 41
  • KDE Plasma 5.23 / KDE Applications 21.08 / Plasma Mobile Gear 21.10
  • Support for disk encryption in installer
  • Support for out-of-tree kernel modules via AKMS (inspired by DKMS)
  • Initial support for UEFI Secure Boot on x86_64

Alpine developer team have also announced that "sudo" will be replaced with "doas". Starting from Alpine Linux 3.16, "sudo" will be moved to community.

Now let us upgrade to Alpine Linux 3.15 from older versions. Believe or not, upgrading Alpine Linux is very easy, fast and straight forward.

Before continuing to update and upgrade your Alpine Linux box, backup your important data that you can't afford to lose.

Update Alpine Linux

Let us check the currently installed Alpine Linux version using command:

$ cat /etc/alpine-release 

Sample output:

3.12.9
Check Alpine Linux version
Check Alpine Linux version

As you can see, the currently installed Alpine Linux version is 3.12.9. Let us upgrade it to latest release i.e. Alpine Linux version is 3.15.0.

Next, update the list of available packages and upgrade the installed packages to latest available versions by running the following Apk commands one by one:

$ sudo apk update
$ sudo apk upgrade

Alternatively, you can combine both commands into one like below:

$ sudo apk -U upgrade

Or,

$ sudo apk --update-cache upgrade

Well, we have updated all installed packages in Alpine Linux. It is time to start the upgrade!

Alpine Linux is available in two editions, stable release and rolling release.

First we will see how to upgrade Alpine Linux to stable release.

1. Upgrade Alpine Linux to latest stable version

The section shows how to upgrade from Alpine 3.x.x to latest release. I assume you have currently installed 3.x.x version.

1.1. Update Alpine Linux repositories

Edit /etc/apk/repositories file using command:

$ sudo setup-apkrepos

You will be presented with list of available mirrors and three options to select a preferred one. The first option is to choose one mirror from the given list.

The second option is to detect and add fastest mirror from the list.

And the third option is to edit /etc/apk/repositories file to update the repository list.

Since we are going to upgrade the system, we need to choose the third option and modify the existing repositories to point to the new release.

To update the repositories, type e and hit ENTER key:

Available mirrors:
1) dl-cdn.alpinelinux.org
2) uk.alpinelinux.org
3) dl-4.alpinelinux.org
4) dl-5.alpinelinux.org
5) mirror.yandex.ru
.
.
.
53) mirror.kumi.systems
54) mirror.sabay.com.kh
55) alpine.northrepo.ca
56) alpine.bardia.tech
57) mirrors.ocf.berkeley.edu
58) mirrors.pardisco.co

r) Add random from the above list
f) Detect and add fastest mirror from above list
e) Edit /etc/apk/repositories with text editor

Enter mirror number (1-58) or URL to add (or r/f/e/done) [f]: e
Edit Alpine Linux repository list
Edit Alpine Linux repository list

The file will open in the default text editor i.e. vi. If you have set different $EDITOR in your $PATH, it will open the file in that editor. My default editor is vi.

Here is the original contents of my /etc/apk/repositories file:

https://sjc.edge.kernel.org/alpine/v3.12/main
https://sjc.edge.kernel.org/alpine/v3.12/community

Change the version number 3.12 to reflect to latest version 3.15.

To do so, press "i" to enter into insert mode and update version number (i.e. 3.15) and finally press ESC and type :wq to save the file and exit.

After updating the version number, the file should look like below:

https://sjc.edge.kernel.org/alpine/v3.15/main
https://sjc.edge.kernel.org/alpine/v3.15/community
Update Alpine Linux repositories to latest 3.15 stable version
Update Alpine Linux repositories to latest 3.15 stable version

If you don't know the exact latest version number, simply replace the v3.x with latest-stable as shown below:

https://sjc.edge.kernel.org/alpine/latest-stable/main     
https://sjc.edge.kernel.org/alpine/latest-stable/community
Change Alpine Linux repositories to latest stable version
Change Alpine Linux repositories to latest stable version

Press ESC and type :wq to save the file and exit.

Upon exit, the repository indexes will be updated automatically. You can also manually do it using command:

$ sudo apk update

Sample output:

fetch https://sjc.edge.kernel.org/alpine/latest-stable/main/x86_64/APKINDEX.tar.gz
fetch https://sjc.edge.kernel.org/alpine/latest-stable/community/x86_64/APKINDEX.tar.gz
v3.15.0-11-g233c924df0 [https://sjc.edge.kernel.org/alpine/latest-stable/main]
v3.15.0-11-g233c924df0 [https://sjc.edge.kernel.org/alpine/latest-stable/community]
OK: 15920 distinct packages available

1.2. Start Alpine Linux upgrade

Now, run the following command to upgrade Alpine Linux to latest available stable version:

$ sudo apk upgrade --available

Here, the --available flag is used to force all packages to be upgraded, even if they have the same version numbers.

Sample output:

Upgrading critical system libraries and apk-tools:
(1/2) Upgrading musl (1.1.24-r10 -> 1.2.2-r7)
(2/2) Upgrading apk-tools (2.10.8-r0 -> 2.12.7-r3)
Executing busybox-1.31.1-r21.trigger
Continuing the upgrade transaction with new apk-tools:
(1/92) Replacing acct (6.6.4-r0 -> 6.6.4-r0)
(2/92) Upgrading busybox (1.31.1-r21 -> 1.34.1-r3)
Executing busybox-1.34.1-r3.post-upgrade
(3/92) Upgrading alpine-baselayout (3.2.0-r7 -> 3.2.0-r18)
Executing alpine-baselayout-3.2.0-r18.pre-upgrade
Executing alpine-baselayout-3.2.0-r18.post-upgrade
(4/92) Installing ifupdown-ng (0.11.3-r0)
(5/92) Upgrading libcrypto1.1 (1.1.1l-r0 -> 1.1.1l-r7)
.
.
.
(90/92) Upgrading wget (1.20.3-r1 -> 1.21.2-r2)
(91/92) Purging libtls-standalone (2.9.1-r1)
(92/92) Purging libgcc (9.3.0-r2)
Executing busybox-1.34.1-r3.trigger
Executing kmod-29-r2.trigger
Executing ca-certificates-20191127-r7.trigger
Executing mkinitfs-3.6.0-r0.trigger
==> initramfs: creating /boot/initramfs-virt
Executing syslinux-6.04_pre1-r9.trigger
/boot is device /dev/vda1
OK: 131 MiB in 91 packages
Upgrade Alpine Linux to latest version
Upgrade Alpine Linux To Latest Version

Finally, restart all services that have been upgraded and reboot the system by running the following commands:

$ sudo sync
$ sudo reboot

After logging in to the system check if Alpine Linux is upgraded to latest version:

$ cat /etc/alpine-release 
3.15.0

Check the running Kernel version:

$ uname -r
5.15.4-0-virt
Display Alpine Linux version and Kernel details
Display Alpine Linux version and Kernel details

Yes, it is! As you see in the above screenshot, I am running Alpine Linux 3.15.0 stable release with Kernel 5.15.4 version.

2. Convert Alpine Linux stable version to rolling release

Some of you may want to convert the Alpine Linux stable edition to rolling development edition called edge.

To do so, edit /etc/apk/repositories file with command:

$ sudo setup-apkrepos

Type "e" and press ENTER to edit the repository file.

Change the version number to edge:

https://sjc.edge.kernel.org/alpine/edge/main         
https://sjc.edge.kernel.org/alpine/edge/community   

Save the file and exit.

Update the repository index and start upgrading from Alpine Linux stable version to rolling release version by running the following command:

$ sudo apk upgrade --update-cache --available

Or,

$ sudo apk upgrade -U -a

Once the upgrade task is completed, reboot the system:

$ sudo sync
$ sudo reboot

Check the Alpine Linux version and Kernel using the following commands:

Display Alpine Linux rolling release version and Kernel details
Display Alpine Linux rolling release version and Kernel details

As you can see in the above output, the latest rolling release version at the time of updating this guide is 3.15.0 and the latest Kernel version is 5.15.4.

The stable and rolling release versions are same here, because Alpine Linux stable version is just released. In a couple days, the rolling release version will be higher than the stable version.

3. Upgrade From Alpine Linux 2.x to Alpine Linux 3.x

Some of you might have still running Alpine Linux version 2.x.x. If so, this part explains how to upgrade from Alpine Linux 2.x to 3.x latest version.

First of all, update the repositories and upgrade all installed packages in your Alpine system:

$ sudo apk update
$ sudo apk upgrade

Next install statically linked version of busybox and apk-tools. You should do this before updating the system, because the old musl version would stop working after a libc change.

$ sudo apk add busybox-static apk-tools-static

Sample output:

fetch https://sjc.edge.kernel.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch https://sjc.edge.kernel.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
(1/2) Installing apk-tools-static (2.10.1-r0)
(2/2) Installing busybox-static (1.28.4-r3)
Executing busybox-1.28.4-r3.trigger
OK: 148 MiB in 80 packages

Next modify the repositories as shown in 1.1. Update Alpine Linux repositories section.

Before doing the actual upgrade, it is recommended to simulate the upgrade process to find issues beforehand:

$ sudo apk.static upgrade --no-self-upgrade --available --simulate

If there are no errors, run the following command to upgrade Alpine Linux 2.x to 3.x version:

$ sudo apk.static upgrade --no-self-upgrade --available

After the upgrade process is completed, restart all the services that are upgraded and reboot your system:

$ sudo sync
$ sudo reboot

Hope this helps.

Resource:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More