Home Linux DistributionsAlpine Linux How To Upgrade Alpine Linux To Latest Version
How To Upgrade Alpine Linux To Latest Version

How To Upgrade Alpine Linux To Latest Version

By sk
2605 Views

The Alpine Linux development team announced the latest stable release of Alpine Linux 3.13.0. 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.13?

Alpine Linux 3.13.0 is the first release in the v3.13 stable series. It ships the latest Linux Kernel 5.10.7 LTS version. In this releases, Alpine team has introduced ifupdown-ng as a replacement for busybox ifupdown. This new release has also shipped with PHP 8.0, improved wifi support in setup scripts, and initial support for cloud-init. One of the notable change is Node.js (LTS) is compiled with -O2 instead of -Os which noticeably improves performance.

The other significant updates are;

  • musl 1.2
  • Busybox 1.32.1
  • GCC 10.2.1
  • Git 2.30.0
  • Knot DNS 3.0.3
  • MariaDB 10.5.8
  • Node.js 14.15.4
  • Nextcloud 20.0.4
  • PostgreSQL 13.1
  • QEMU 5.2.0
  • Xen 4.14.1
  • Zabbix 5.2.3
  • ZFS 2.0.1

Now let us upgrade to Alpine Linux 3.13 from Alpine Linux 3.12 and 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.8.5
Check Alpine Linux version
Check Alpine Linux version

As you can see, the currently installed Alpine Linux version is 3.8.5. Let us upgrade it to latest release i.e. Alpine Linux version is 3.13.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-2.alpinelinux.org
4) dl-4.alpinelinux.org
5) dl-5.alpinelinux.org
.
.
.
48) tux.rainside.sk
49) alpine.cs.nctu.edu.tw
50) mirror.ihost.md
51) mirror.ette.biz
52) mirror.lagoon.nc
53) alpinelinux.c3sl.ufpr.br

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-53) or URL to add (or r/f/e/done) [f]: e
Update Alpine Linux repositories
Update Alpine Linux repositories

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. Mine is vi editor.

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

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

Change the version number 3.8 to reflect to latest version 3.13.

To do so, press "i" to enter into insert mode and update version number (i.e. 3.13) 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.13/main
https://sjc.edge.kernel.org/alpine/v3.13/community
Change Alpine Linux repositories to latest 3.13 stable version
Change Alpine Linux repositories to latest 3.13 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

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/v3.13/main/x86_64/APKINDEX.tar.gz
fetch https://sjc.edge.kernel.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
v3.13.0_rc5-69-g09276e69ab [https://sjc.edge.kernel.org/alpine/v3.13/main]
v3.13.0_rc5-68-g10a1134646 [https://sjc.edge.kernel.org/alpine/v3.13/community]
OK: 13945 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/5) Upgrading musl (1.1.19-r11 -> 1.2.2_pre7-r0)
(2/5) Installing libcrypto1.1 (1.1.1i-r0)
(3/5) Installing libssl1.1 (1.1.1i-r0)
(4/5) Upgrading apk-tools (2.10.1-r0 -> 2.12.0-r4)
(5/5) Upgrading musl-utils (1.1.19-r11 -> 1.2.2_pre7-r0)
.
.
.
(80/85) Installing libidn2 (2.3.0-r0)
(81/85) Upgrading wget (1.20.3-r0 -> 1.21.1-r1)
(82/85) Purging libressl2.7-libtls (2.7.5-r0)
(83/85) Purging libssh2 (1.9.0-r1)
(84/85) Purging libressl2.7-libssl (2.7.5-r0)
(85/85) Purging libressl2.7-libcrypto (2.7.5-r0)
Executing busybox-1.32.1-r0.trigger
Executing ca-certificates-20191127-r5.trigger
Executing kmod-28-r0.trigger
depmod: WARNING: could not open modules.order at /lib/modules/4.14.167-0-virt: No such file or directory
depmod: WARNING: could not open modules.builtin at /lib/modules/4.14.167-0-virt: No such file or directory
Executing mkinitfs-3.5.0-r0.trigger
==> initramfs: creating /boot/initramfs-virt
Executing syslinux-6.04_pre1-r6.trigger
/boot is device /dev/sda1
OK: 164 MiB in 88 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.13.0

Check the running Kernel version:

$ uname -r
5.10.7-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.13.0 stable release with Kernel 5.10.7 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:

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 writing this guide is 3.13.0 and the latest Kernel version is 5.10.7. The stable and rolling release versions are same because Alpine Linux stable version is just released. In couple days, the rolling release version will be higher than the stable version.

You can also use the following command to check the current Alpine Linux version:

Check Alpine Linux version
Check Alpine Linux 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:

Related read:

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. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More