tudor’s website

How to Speed Up Package Installations on OpenSUSE

tags: howto, linux, opensuse, tools

Currently, this article applies only to openSUSE Tumbleweed.

(sidenote:The default package manager on OpenSUSE and SUSE Linux Enterprise.) just added support for parallel downloads, which can make large upgrades become twice as fast. Here I will write about some more tweaks I discovered that make Zypper even quicker.

In short

  1. Make sure you are using the newest Zypper and libzypp:
$ sudo zypper update libzypp zypper
  1. Install the openSUSE-repos package to use CDN-based repositories:
$ sudo zypper install openSUSE-repos

This applies multiple tweaks in one, see below for a detailed explanation.

  1. Enable the experimental single RPM transaction mode:
$ echo "export ZYPP_SINGLE_RPMTRANS=1" > /etc/profile.d/my-zypp-settings.sh
  1. If you run Zypper with sudo: let sudo pass the values of ZYPP_PCK_PRELOAD and ZYPP_SINGLE_RPMTRANS.

    Run sudo visudo -f /etc/sudoers.d/zypper-vars to safely edit the file and write the following:

    Defaults env_keep += "ZYPP_PCK_PRELOAD ZYPP_SINGLE_RPMTRANS"
    
  2. Log out and log back in for environment variable changes to take effect.

You should not skip this step if you preferred to not turn on the experimental single RPM transaction mode from above. Step 2 also does some environment variable changes behind the scenes.

openSUSE-repos

Installing this package replaces the default Zypper repo definitions with ones derived from openSUSE’s Repository Index Service, which is a facility provided by Zypper to (sidenote: According to the OpenSUSE Wiki page about Repository Index Service, the protocol is an extension of Novell Update, part of the Zenworks Linux Management “client-server protocol”. Zenworks Linux Management is a configuration management product that allows one to “embrace and extend” Linux in their enterprise environment. These might all sound unrelated, but openSUSE is partly developed by SUSE, which is a company that used to be part of the Attachmate Group, which contained Novell, and this group was purchased by Micro Focus, which is now named OpenText. You can see part of these companies’ histories in this inoffensive feature! (Source.) ). These repositories are basically the same as the default ones, the only difference being that they are served from a CDN. From the post that announces Zypper’s parallel download abilities, we learn that this package also enables both parallel downloads and the new file download backend, which reduces overhead.

After installing this package, you need to log out and log back in because parallel downloads are enabled by means of installing a snippet in /etc/profile.d/ which toggles the right environment variable.

Single RPM transaction mode

I haven’t looked into it yet, but Zypper for some reason runs a separate RPM transaction for every package it installs. This can quickly add overhead when you install a package that needs many dependencies, or when upgrading many packages at once. For a couple of years already, Zypper has been offering an experimental mode in which all package installations done by a command would be done in a single transaction, toggled by the ZYPP_SINGLE_RPMTRANS environment variable.

Be aware that some package installations can fail in this mode! Packages are not always tested for installing with this experimental feature turned on. If this happens, run Zypper like so:

$ sudo ZYPP_SINGLE_RPMTRANS=0 zypper ... # the rest of your command

Another catch is that YaST might not be able to do some package management operations any more, as highlighted in the announcement of this feature.

sudo config

When run normally, sudo provides only a limited set of environment variables to the program you want to run, even when those variables are set system-wide in /etc/profile.d. You can run sudo with the -i flag to run the command in a login shell, which will load files from /etc/profile.d, or you can configure sudo to pass the environment variables we use to tweak Zypper. I prefer the latter, because it brings fewer changes to the way sudo runs commands.