How to upgrade OpenSUSE 15.1 to 15.2 using the CLI

last updated in Categories ,

The latest OpenSUSE version is 15.2 and is an opportunity for both desktop and server users on the previous 15.1 release to update OpenSUSE Linux to get the newest software stack. It is easy to follow the procedure to upgrade OpenSUSE 15.1 to 15.2. In this tutorial, we will explain how to upgrade OpenSUSE 15.1 to 15.2.

Tutorial requirements
Operating system/appOpenSUSE Linux 15.1/15.1.1
Root privileges requiredYes
DifficultyAdvanced (rss)
Estimated completion time30-45m
Table of contents

ADVERTISEMENTS


Step 1. Preparations – Backup everything

You must back up all data and config files before typing any of the following commands. Make sure your system backup is up-to-date and restorable in case of an emergency. The author or nixCraft is not liable for damages. Hence, check your system backup. In my case, I have daily offsite backups, and I created a snapshot of my Linode and AWS VM.

Step 2. Update OpenSUSE 15.1 packages

Please note that openSUSE Leap version 15.2 is only available as the 64-bit release. Next, type the following zypper command to update all existing packages. To refresh a repository, run:
$ sudo zypper ref

Repository 'openSUSE-Leap-15.1-1' is up to date.
Retrieving repository 'openSUSE-Leap-15.1-Update' metadata ..........................................[done]
Building repository 'openSUSE-Leap-15.1-Update' cache ...............................................[done]
Retrieving repository 'openSUSE-Leap-15.1-Update-Non-Oss' metadata ..................................[done]
Building repository 'openSUSE-Leap-15.1-Update-Non-Oss' cache .......................................[done]
All repositories have been refreshed.

Update installed packages with newer versions

Run:
$ sudo zypper up

Loading repository data...
Reading installed packages...

The following 16 package updates will NOT be installed:
  aws-cli cloud-init cloud-init-config-suse cloud-netconfig-ec2 growpart
  libsodium23 python3-bcrypt python3-boto3 python3-botocore python3-cffi
  python3-cryptography python3-ec2imgutils python3-ec2metadata python3-jmespath
  python3-s3transfer python-rpm-macros

The following 332 NEW packages are going to be installed:
  adjtimex adwaita-icon-theme apparmor-parser-lang atk-lang at-spi2-atk-common
  at-spi2-atk-gtk2 bash-completion bash-doc bash-lang branding-openSUSE
The following product is going to be reinstalled:
  "openSUSE Leap 15.1"

The following 7 packages require a system reboot:
  dbus-1 glibc kernel-default-4.12.14-lp151.28.52.1 kernel-firmware
  libopenssl1_1 systemd udev

280 packages to upgrade, 332 new, 1 to remove.
Overall download size: 455.0 MiB. Already cached: 0 B. After the operation,
additional 1.3 GiB will be used.

    Note: System reboot required.
Continue? [y/n/v/...? shows all options] (y): y

Step 3. Reboot the box

Note down your Linux kernel version, execute:
$ uptime
$ uname -mrs

You must reboot the Linux system, run:
$ sudo reboot
## OR ##
$ sudo shutdown -r now

Log in using the ssh command:
$ ssh ec2-user@your-aws-ec2-ip-here
## OR ##
$ ssh root@your-Linode-ip-here

Verify version again after system reboots:
$ uname -mrs
How To Upgrade OpenSUSE Leap To 15.2

Step 4. Upgrade OpenSUSE 15.1 to 15.2

Now our system is up to date and patched for the OpenSUSE Leap version 15.1. It is time to update the server to OpenSUSE version 15.2.

List the repositories

The update repository must exist and is enabled and update before upgrading to 15.2. Verify it:
$ sudo zypper repos --uri
## OR ##
$ sudo zypper lr -u

Repository priorities are without effect. All enabled repositories share the same priority.
 
# | Alias                             | Name                              | Enabled | GPG Check | Refresh | URI
--+-----------------------------------+-----------------------------------+---------+-----------+---------+--------------------------------------------------------------
1 | openSUSE-Leap-15.1-1              | openSUSE-Leap-15.1-1              | Yes     | (r ) Yes  | Yes     | http://download.opensuse.org/distribution/leap/15.1/repo/oss/
2 | openSUSE-Leap-15.1-Update         | openSUSE-Leap-15.1-Update         | Yes     | (r ) Yes  | Yes     | http://download.opensuse.org/update/leap/15.1/oss/
3 | openSUSE-Leap-15.1-Update-Non-Oss | openSUSE-Leap-15.1-Update-Non-Oss | Yes     | (r ) Yes  | Yes     | http://download.opensuse.org/update/leap/15.1/non-oss/

Item number 2 and 3 indicate that version 15.1 update repos are enabled. If the Enabled column says No, enable it by issuing the command:
$ sudo zypper modifyrepo --enable openSUSE-Leap-15.1-Update
$ sudo ref
$ sudo up
## if a new kernel and libs installed ##
$ sudo reboot

Find out if version number hard-coded or not

Find out if your Leap repos defined in /etc/zypp/repos.d/ are using the $releasever variable or not. It would be best if you verified this. Otherwise, the update will not take place. To get a list of all enabled repos using the following awk command/grep command:

zypper lr -u | \
awk -F'|' '$4 ~ /Yes/ { gsub (" ", "", $2); 
                        r="/etc/zypp/repos.d/"$2".repo"; 
                        print "\nFile: " r; system("cat " r) 
                      }'

Sample outputs indicating that $releasever defined and no need to use the sed command:

File: /etc/zypp/repos.d/repo-non-oss.repo
[repo-non-oss]
name=Non-OSS Repository
enabled=1
autorefresh=0
baseurl=http://download.opensuse.org/distribution/leap/$releasever/repo/non-oss/
type=rpm-md

File: /etc/zypp/repos.d/repo-oss.repo
[repo-oss]
name=Main Repository
enabled=1
autorefresh=0
baseurl=http://download.opensuse.org/distribution/leap/$releasever/repo/oss/
type=rpm-md

File: /etc/zypp/repos.d/repo-update.repo
[repo-update]
name=Main Update Repository
enabled=1
autorefresh=0
baseurl=http://download.opensuse.org/update/leap/$releasever/oss/
type=rpm-md

File: /etc/zypp/repos.d/repo-update-non-oss.repo
[repo-update-non-oss]
name=Update Repository (Non-Oss)
enabled=1
autorefresh=0
baseurl=http://download.opensuse.org/update/leap/$releasever/non-oss/
type=rpm-md

Here is another outputs indicating that the version number is hard-coded and you need to execute the sed command:

File: /etc/zypp/repos.d/openSUSE-Leap-15.1-1.repo
[openSUSE-Leap-15.1-1]
name=openSUSE-Leap-15.1-1
enabled=1
autorefresh=1
baseurl=http://download.opensuse.org/distribution/leap/15.1/repo/oss/
path=/
type=rpm-md
keeppackages=0

File: /etc/zypp/repos.d/openSUSE-Leap-15.1-Update.repo
[openSUSE-Leap-15.1-Update]
enabled=1
autorefresh=1
baseurl=http://download.opensuse.org/update/leap/15.1/oss/
type=rpm-md

File: /etc/zypp/repos.d/openSUSE-Leap-15.1-Update-Non-Oss.repo
[openSUSE-Leap-15.1-Update-Non-Oss]
enabled=1
autorefresh=1
baseurl=http://download.opensuse.org/update/leap/15.1/non-oss/
type=rpm-md

Linux sed command to update hard-coded version

WARNING: Only type the following commands if you have hard-coded version values.

Let us try out a combination of bash for loop and sed. First, switch to the root user account using the sudo command:
$ sudo -i
Now we can easily execute the following commands as root:

files="$(zypper lr -u | awk -F'|' '$4 ~ /Yes/ { gsub (" ", "", $2); r="/etc/zypp/repos.d/"$2".repo"; print r }')"
for f in $files
do
  echo "Backup of $f saved to /root/ before patching it up ..."
  cp -f "$f" /root/
  sed -i 's+/leap/15.1+/leap/$releasever+' "$f"
  sed -i 's+15.1.1+15.2+' "$f"
  sed -i 's+15.1+15.2+' "$f"
done

Running the upgrade for 15.2

So far, we verified and updated the hard-coded version. It is time to switch and refresh all repositories to 15.2 using the following syntax:
$ sudo zypper --releasever=15.2 ref

Warning: Enforced setting: $releasever=15.2
Retrieving repository 'openSUSE-Leap-15.2' metadata ......................................[done]
Building repository 'openSUSE-Leap-15.2' cache ...........................................[done]
Retrieving repository 'openSUSE-Leap-15.2-Update' metadata ...............................[done]
Building repository 'openSUSE-Leap-15.2-Update' cache ....................................[done]
Retrieving repository 'openSUSE-Leap-15.2-Update-Non-Oss' metadata .......................[done]
Building repository 'openSUSE-Leap-15.2-Update-Non-Oss' cache ............................[done]
All repositories have been refreshed.

Make sure repos correct for getting updates for OpenSUSE 15.2:
$ sudo zypper lr -u

Repository priorities are without effect. All enabled repositories share the same priority.
 
# | Alias                             | Name                              | Enabled | GPG Check | Refresh | URI
--+-----------------------------------+-----------------------------------+---------+-----------+---------+--------------------------------------------------------------
1 | openSUSE-Leap-15.2                | openSUSE-Leap-15.2                | Yes     | (r ) Yes  | Yes     | http://download.opensuse.org/distribution/leap/15.2/repo/oss/
2 | openSUSE-Leap-15.2-Update         | openSUSE-Leap-15.2-Update         | Yes     | (r ) Yes  | Yes     | http://download.opensuse.org/update/leap/15.2/oss/
3 | openSUSE-Leap-15.2-Update-Non-Oss | openSUSE-Leap-15.2-Update-Non-Oss | Yes     | (r ) Yes  | Yes     | http://download.opensuse.org/update/leap/15.2/non-oss/

Finally, execute the following command for full distribution upgrade to 15.2 from 15.1. Please note that command must be typed from non-GUI (KDE/GNOME) mode. Hence, it is recommended you run the command from either runlevel 3 (text + network), or a virtual console. You can press Ctrl-Alt-F2 (all at the same time) to switch to virtual terminal 2. One can also issue sudo init 3. See this page for more information.
$ sudo zypper --releasever=15.2 dup
Upgrade OpenSUSE 15.1 to 15.2 using zypper
The procedure to download and install packages could take some time. It all depends upon your Internet and cloud server/VM speed. At the end you should see an output as follows indicating you must reboot the system:

Executing %posttrans scripts ............................................................[done]
There are running programs which still use files and libraries deleted or updated by recent upgrades. They should be restarted to benefit from the latest updates. Run 'zypper ps -s' to list these programs.
 
Core libraries or services have been updated.
Reboot is required to ensure that your system benefits from these updates.

Hence, reboot the server:
$ sudo reboot

Step 5: Verification

Make sure everything is working. First, find OpenSuse Linux Version and other info:
$ uname -mrs
$ lsb_release -a
$ hostnamectl

How to Upgrade OpenSUSE 15.1 to OpenSUSE 15.2 and verify it
Check your server logs. For example, use the journalctl command/tail command/dmesg command and more:
$ sudo tail -f /var/log/nginx/access_log
$ dmesg
$ journalctl -xe

My software stack is now updated to the latest stable release as follows:

  • Nginx 1.16.1 (caching and reverse proxy server)
  • PHP 7.4.6 (FastCGI)
  • Apache 2.4.43 (app server)
  • Python 3.6.10
  • Perl v5.26.1
  • MariaDB 10.4.13 (database)

Conclusion

In this tutorial, we learned how to update OpenSUSE Linux Leap from 15.1 to 15.2 using the CLI. For more information, see the release note and download OpenSUSE Linux here.

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.


ADVERTISEMENTS

2 comment

  1. I did all the above and it looks like the upgrade went fine, but lsb_release -a still says:
    LSB Version: n/a
    Distributor ID: openSUSE
    Description: openSUSE Leap 15.1
    Release: 15.1
    Codename: n/a

Leave a Comment