How to upgrade Alpine Linux 3.9 to 3.10

last updated in Categories , ,

I am using Alpine Linux v3.7 or v3.8 with my LXD server. How do I upgrade Alpine Linux v3.8 to Alpine Linux v3.9? How can I upgrade Alpine Linux v3.8 to Alpine Linux v3.9?

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.
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. The kernel is patched with an unofficial port of grsecurity/PaX, and 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.

Make a backup of your LXD container

Type the following command to create container snapshots:
$ lxc snapshot alpine-www01 "JUNE272018"
Verify it:
$ lxc info alpine-www01
Sample outputs:

Name: alpine-www01
Remote: unix://
Architecture: x86_64
Created: 2019/01/04 06:25 UTC
Status: Running
Type: persistent
Profiles: default
Pid: 28917
Ips:
  lo:	inet	127.0.0.1
  lo:	inet6	::1
  eth0:	inet	10.105.28.45	vethJ4APTV
  eth0:	inet6	fe80::216:3eff:fee6:6afa	vethJ4APTV
Resources:
  Processes: 34
  CPU usage:
    CPU usage (in seconds): 3
  Memory usage:
    Memory (current): 201.15MB
    Memory (peak): 203.21MB
  Network usage:
    eth0:
      Bytes received: 87.31kB
      Bytes sent: 435.99kB
      Packets received: 384
      Packets sent: 333
    lo:
      Bytes received: 17.74kB
      Bytes sent: 17.74kB
      Packets received: 30
      Packets sent: 30
Snapshots:
  Feb-03-2019 (taken at 2019/02/02 18:38 UTC) (stateless)
  mar-04-2019 (taken at 2019/03/04 16:23 UTC) (stateless)
  may-04-2019 (taken at 2019/05/03 21:56 UTC) (stateless)
  June-21-2019 (taken at 2019/06/20 19:58 UTC) (stateless)
  June-24-2019 (taken at 2019/06/23 20:29 UTC) (stateless)

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

Find out your Alpine Linux version

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

How to upgrading to latest release

Edit /etc/apk/repositories file, enter:
# vi /etc/apk/repositories
Change the version number by hand. For example, the default entry for 3.4 is as follows:
http://dl-3.alpinelinux.org/alpine/v3.4/main
To update to 3.5.xx, enter:
http://dl-3.alpinelinux.org/alpine/v3.5/main
Change the version number by hand. For example, the default entry for 3.5 is as follows:
http://dl-3.alpinelinux.org/alpine/v3.5/main
To update to 3.5.xx, enter:
http://dl-3.alpinelinux.org/alpine/v3.6/main
Change the version number by hand. For example, the default entry for 3.6 is as follows:
http://dl-cdn.alpinelinux.org/alpine/v3.6/main
Make sure you change the version number by hand. For example, the default entry for 3.7 is as follows:
http://dl-cdn.alpinelinux.org/alpine/v3.7/main
Make sure you change the version number by hand. For example, the default entry for 3.8 is as follows:
http://dl-cdn.alpinelinux.org/alpine/v3.8/main
Make sure you change the version number by hand. For example, the default entry for 3.9 is as follows:
http://dl-cdn.alpinelinux.org/alpine/v3.9/main
Make upgrade to to 3.10.xx, enter:
http://dl-cdn.alpinelinux.org/alpine/v3.10/main
Save and close the file. Here is my sample config file displayed using cat command:
# cat /etc/apk/repositories
Sample outputs:

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

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

fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
v3.10.0-1-gbcc49b4c70 [http://dl-cdn.alpinelinux.org/alpine/v3.10/main]
v3.10.0-3-g43ac83e8aa [http://dl-cdn.alpinelinux.org/alpine/v3.10/community]
OK: 10415 distinct packages available

To upgrade all your packages, run apk command:
# apk upgrade --available
OR
# apk upgrade --purge
Sample outputs:

fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
v3.10.0-1-gbcc49b4c70 [http://dl-cdn.alpinelinux.org/alpine/v3.10/main]
v3.10.0-3-g43ac83e8aa [http://dl-cdn.alpinelinux.org/alpine/v3.10/community]
OK: 10415 distinct packages available
root@utls-newsletter-php7:~ # apk upgrade --available
Upgrading critical system libraries and apk-tools:
(1/1) Upgrading apk-tools (2.10.3-r1 -> 2.10.4-r1)
Executing busybox-1.29.3-r10.trigger
Continuing the upgrade transaction with new apk-tools:
(1/88) Upgrading musl (1.1.20-r4 -> 1.1.22-r2)
(2/88) Upgrading busybox (1.29.3-r10 -> 1.30.1-r2)
Executing busybox-1.30.1-r2.post-upgrade
(3/88) Upgrading alpine-baselayout (3.1.0-r3 -> 3.1.2-r0)
Executing alpine-baselayout-3.1.2-r0.pre-upgrade
Executing alpine-baselayout-3.1.2-r0.post-upgrade
(4/88) Upgrading openrc (0.39.2-r3 -> 0.41.2-r1)
Executing openrc-0.41.2-r1.post-upgrade
(5/88) Upgrading alpine-conf (3.8.1-r5 -> 3.8.3-r0)
(6/88) Upgrading libcrypto1.1 (1.1.1b-r1 -> 1.1.1c-r0)
(7/88) Upgrading libssl1.1 (1.1.1b-r1 -> 1.1.1c-r0)
(8/88) Replacing ca-certificates-cacert (20190108-r0 -> 20190108-r0)
(9/88) Upgrading libtls-standalone (2.7.4-r6 -> 2.9.1-r0)
(10/88) Upgrading ssl_client (1.29.3-r10 -> 1.30.1-r2)
(11/88) Replacing zlib (1.2.11-r1 -> 1.2.11-r1)
(12/88) Upgrading busybox-suid (1.29.3-r10 -> 1.30.1-r2)
(13/88) Upgrading busybox-initscripts (3.1-r6 -> 3.1-r7)
Executing busybox-initscripts-3.1-r7.post-upgrade
(14/88) Replacing scanelf (1.2.3-r0 -> 1.2.3-r0)
(15/88) Upgrading musl-utils (1.1.20-r4 -> 1.1.22-r2)
(16/88) Replacing libc-utils (0.7.1-r0 -> 0.7.1-r0)
(17/88) Upgrading alpine-keys (2.1-r1 -> 2.1-r2)
(18/88) Upgrading alpine-base (3.9.4-r0 -> 3.10.0-r0)
(19/88) Upgrading ncurses-terminfo-base (6.1_p20180818-r1 -> 6.1_p20190518-r0)
(20/88) Upgrading ncurses-terminfo (6.1_p20180818-r1 -> 6.1_p20190518-r0)
(21/88) Upgrading ncurses-libs (6.1_p20180818-r1 -> 6.1_p20190518-r0)
(22/88) Upgrading readline (7.0.003-r1 -> 8.0.0-r0)
(23/88) Upgrading bash (4.4.19-r1 -> 5.0.0-r0)
Executing bash-5.0.0-r0.post-upgrade
(24/88) Replacing bash-completion (2.8-r0 -> 2.8-r0)
(25/88) Installing openrc-bash-completion (0.41.2-r1)
(26/88) Upgrading bash-doc (4.4.19-r1 -> 5.0.0-r0)
(27/88) Upgrading bc (1.07.1-r0 -> 1.07.1-r1)
(28/88) Replacing ca-certificates (20190108-r0 -> 20190108-r0)
(29/88) Upgrading nghttp2-libs (1.35.1-r0 -> 1.38.0-r0)
(30/88) Upgrading libcurl (7.64.0-r2 -> 7.65.1-r0)
(31/88) Upgrading curl (7.64.0-r2 -> 7.65.1-r0)
(32/88) Replacing expat (2.2.6-r0 -> 2.2.6-r0)
(33/88) Upgrading pcre2 (10.32-r1 -> 10.33-r0)
(34/88) Upgrading git (2.20.1-r0 -> 2.22.0-r0)
(35/88) Upgrading git-bash-completion (2.20.1-r0 -> 2.22.0-r0)
(36/88) Replacing htop (2.2.0-r0 -> 2.2.0-r0)
(37/88) Replacing libressl2.7-libcrypto (2.7.5-r0 -> 2.7.5-r0)
(38/88) Replacing libressl2.7-libssl (2.7.5-r0 -> 2.7.5-r0)
(39/88) Replacing libressl2.7-libtls (2.7.5-r0 -> 2.7.5-r0)
(40/88) Replacing libressl (2.7.5-r0 -> 2.7.5-r0)
(41/88) Replacing popt (1.16-r7 -> 1.16-r7)
(42/88) Replacing logrotate (3.15.0-r0 -> 3.15.0-r0)
(43/88) Replacing logrotate-openrc (3.15.0-r0 -> 3.15.0-r0)
(44/88) Upgrading mariadb-common (10.3.15-r0 -> 10.3.16-r0)
Executing mariadb-common-10.3.16-r0.post-upgrade
(45/88) Replacing libgcc (8.3.0-r0 -> 8.3.0-r0)
(46/88) Replacing libstdc++ (8.3.0-r0 -> 8.3.0-r0)
(47/88) Upgrading mariadb-client (10.3.15-r0 -> 10.3.16-r0)
(48/88) Upgrading mysql-client (10.3.15-r0 -> 10.3.16-r0)
(49/88) Upgrading libbsd (0.8.6-r2 -> 0.9.1-r0)
(50/88) Replacing netcat-openbsd (1.130-r1 -> 1.130-r1)
(51/88) Upgrading pcre (8.42-r1 -> 8.43-r0)
(52/88) Upgrading nginx (1.14.2-r1 -> 1.16.0-r2)
Executing nginx-1.16.0-r2.pre-upgrade
Executing nginx-1.16.0-r2.post-upgrade
(53/88) Upgrading php7-common (7.2.19-r0 -> 7.3.6-r0)
(54/88) Upgrading libedit (20181209.3.1-r0 -> 20190324.3.1-r0)
(55/88) Upgrading libxml2 (2.9.9-r1 -> 2.9.9-r2)
(56/88) Upgrading php7 (7.2.19-r0 -> 7.3.6-r0)
(57/88) Upgrading php7-curl (7.2.19-r0 -> 7.3.6-r0)
(58/88) Upgrading php7-fpm (7.2.19-r0 -> 7.3.6-r0)
(59/88) Upgrading libxau (1.0.8-r3 -> 1.0.9-r0)
(60/88) Upgrading libxdmcp (1.1.2-r5 -> 1.1.3-r0)
(61/88) Upgrading libxcb (1.13-r2 -> 1.13.1-r0)
(62/88) Upgrading libx11 (1.6.7-r0 -> 1.6.8-r0)
(63/88) Upgrading libxext (1.3.3-r3 -> 1.3.4-r0)
(64/88) Replacing libice (1.0.9-r3 -> 1.0.9-r3)
(65/88) Upgrading libuuid (2.33-r0 -> 2.33.2-r0)
(66/88) Upgrading libsm (1.2.2-r2 -> 1.2.3-r0)
(67/88) Replacing libxt (1.1.5-r2 -> 1.1.5-r2)
(68/88) Replacing libxpm (3.5.12-r0 -> 3.5.12-r0)
(69/88) Replacing libbz2 (1.0.6-r6 -> 1.0.6-r6)
(70/88) Upgrading libpng (1.6.37-r0 -> 1.6.37-r1)
(71/88) Upgrading freetype (2.9.1-r2 -> 2.10.0-r0)
(72/88) Upgrading libjpeg-turbo (1.5.3-r4 -> 2.0.2-r0)
(73/88) Upgrading libwebp (1.0.1-r0 -> 1.0.2-r0)
(74/88) Upgrading php7-gd (7.2.19-r0 -> 7.3.6-r0)
(75/88) Replacing libintl (0.19.8.1-r4 -> 0.19.8.1-r4)
(76/88) Upgrading php7-gettext (7.2.19-r0 -> 7.3.6-r0)
(77/88) Upgrading php7-json (7.2.19-r0 -> 7.3.6-r0)
(78/88) Upgrading php7-openssl (7.2.19-r0 -> 7.3.6-r0)
(79/88) Upgrading php7-mysqlnd (7.2.19-r0 -> 7.3.6-r0)
(80/88) Upgrading php7-mysqli (7.2.19-r0 -> 7.3.6-r0)
(81/88) Upgrading php7-opcache (7.2.19-r0 -> 7.3.6-r0)
(82/88) Upgrading php7-phar (7.2.19-r0 -> 7.3.6-r0)
(83/88) Upgrading php7-session (7.2.19-r0 -> 7.3.6-r0)
(84/88) Upgrading php7-simplexml (7.2.19-r0 -> 7.3.6-r0)
(85/88) Downgrading libgd (2.2.5-r3 -> 2.2.5-r2)
(86/88) Replacing vnstat (1.18-r0 -> 1.18-r0)
(87/88) Replacing wget (1.20.3-r0 -> 1.20.3-r0)
(88/88) Purging libssh2 (1.8.2-r0)
Executing busybox-1.30.1-r2.trigger
Executing ca-certificates-20190108-r0.trigger
OK: 96 MiB in 88 packages

Restart the server/VM container:
# sync
# reboot

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

Conclusion – Upgrade Alpine Linux

And there you have it, Alpine Linux upgraded from version 3.9 to 3.10. For more information see https://alpinelinux.org/.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Notable Replies

  1. It is actually not updating current /etc/alpine-release file but creating another one. You can verify that with the following commands:

    ls -l /etc/alpine-release* 
    
  2. yes, if you followed info provided on my page your container is on 3.9. It is just that apk no longer updating original file and saving it as /etc/alpine-release.apk-new. Another way to verify it, just run:

    cat /etc/issue
    

    Screenshot%20from%202019-02-19%2016-18-39
    HTH

Continue the discussion www.nixcraft.com

4 more replies

Participants

Historical Comment Archive

9 comment


  1. 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

    Still, have a question? Get help on our forum!