SDB:Keep multiple kernel versions

Jump to: navigation, search


Tested on openSUSE

Recommended articles

Related articles

Icon-help.png


This article is about openSUSE's multiversion kernel feature and how to enable and configure it.

Icon-warning.png
Warning: This feature should only be used by experienced users.

Default behaviour when installing a new kernel

When downloading and installing a new kernel with YaST or Zypper the default behaviour of an openSUSE installation is to delete an old kernel as soon as the new one has been installed and before the system has been rebooted using the new kernel.

Changing the default behaviour with the multiversion kernel feature

Since openSUSE 12.1 a new and highly configurable feature is available - called multiversion kernel - that can be enabled and configured in the file /etc/zypp/zypp.conf.

By enabling and configuring this feature the default behaviour can be changed and configured to

  • delete an old kernel only after the system has been rebooted successfully with the new kernel
  • keep a specified number of older kernels as spares
  • keep a specific kernel version

After the reboot following the installation of a new kernel version the systemd service purge-kernels.service will compare the list of installed kernels with the settings in /etc/zypp/zypp.conf and delete those that are no longer needed.


Enable the multiversion kernel feature

Log on as root and open the file /etc/zypp/zypp.conf with an editor and look for the following two lines:

#multiversion = provides:multiversion(kernel)

and

#multiversion.kernels = latest,running

The first line tells the system to keep multiple kernel versions and the second line configures the way these kernel versions are handled by the system.

Uncomment both lines by removing the leading # then save the file.

Note that, when you just uncomment the first line, the system will keep all kernels and will not delete them. This is not a desirable behaviour as it will fill up your Harddisk with old kernel versions over time. To prevent this both lines have to be uncommented or you would have to delete older kernel versions manually.

Configure the multiversion kernel feature

There are several options mentioned in /etc/zypp/zypp.conf as how to configure the multiversion kernel feature:

## Comma separated list of kernel packages to keep installed in parallel, if  the
## above multiversion variable is set. Packages can be specified as
## 2.6.32.12-0.7 - Exact version to keep
## latest        - Keep kernel with the highest version number
## latest-N      - Keep kernel with the Nth highest version number
## running       - Keep the running kernel
## oldest        - Keep kernel with the lowest version number (the GA kernel)
## oldest+N      - Keep kernel with the Nth lowest version number
##
## Default: Do not delete any kernels if multiversion = provides:multiversion(kernel) is set

Their usage is explained in detail below.

Delete an old kernel after reboot only

Use Case: You want to make sure that an old kernel will only be deleted after the system has rebooted successfully of the new kernel.

Configuration: Uncomment the two lines in /etc/zypp/zypp.conf as stated in step 3 above which will leave you with with the following:

multiversion = provides:multiversion(kernel)
multiversion.kernels = latest,running

Ensure purge-kernels.service is enabled.

Explanation: The parameters latest,running tell the system to keep the latest kernel and the running one if they differ.

To be on the safe side here, you probably want to configure your system to always keep the latest and the running kernel.

If you reboot your system with the new kernel - as it is supposed to be the case - then, after the new kernel has booted successfully, the kernel to keep is

  • the latest kernel = the new one
  • the running kernel = the new kernel also

The latest and the running kernel do not differ because they are identical so all other kernels, in this case your previous one, will be removed.

If you reboot your system with the old kernel instead, the kernel to keep is

  • the running kernel = the old kernel you are rebooting your system of
  • the latest kernel = the new kernel

In this case both, the latest and the running kernel do differ and thus both will be kept and none will be removed.

Keep older kernels as spares

Use Case: You want to keep one or more older kernel versions to have one or more spare kernels. This is useful if you, for example want to install unstable kernels for testing reasons. In case something goes wrong with a new unstable kernel, e.g. your machine does not boot, you still have one or more previous kernel versions installed which are known to be good, that you can boot your machine of.

Configuration: Add and configure one or more latest-N parameters to the multiversion kernel line in /etc/zypp/zypp.conf. The example line below will always keep the last two previous kernel versions on your system:

multiversion.kernels = latest,latest-1,latest-2,running

Explanation: When you reboot your system after the installation of a new kernel, the system will keep

  • the new and running kernel as configured with latest,running
  • the previous kernel version to the new kernel as configured with latest-1
  • the predecessor of the previous kernel version as configured with latest-2

and remove all older kernel versions.

To keep the numbers of kernel versions you want, simply add and configure another latest-N statement to the multiversion kernels line. If you would like to keep four additional kernel versions, for example, then the line would look like this:

multiversion.kernels = latest,latest-1,latest-2,latest-3,latest-4,running

which would leave you with five installed kernels: The new one and the four previous versions.

The opposite can be done when using the parameters oldest and oldest+N. A multiversion kernels line like this

multiversion.kernels = latest,oldest,oldest+1,running

would leave you with

  • the latest and running kernel version as configured with latest,running
  • the oldest kernel version as configured with oldest
  • the successor of the oldest kernel version as configured with oldest+1

Keep a specific kernel version

Use Case: You make regular system updates and let YaST or Zypper install new kernel versions. But you are also compiling your own special kernel for various reasons and want to make sure, that the system will keep it.

Configuration: Add the version number of your self-compiled kernel to the multiversion kernels line in /etc/zypp/zypp.conf. If you name your kernel 3.1.0-46-<your_username>, for example, then the line should look like this:

multiversion.kernels = latest,3.1.0-46-<your_username>,running

Explanation: When you reboot your system after the installation of a new kernel, the system will keep

  • the new and running kernel as configured with latest,running
  • your self-compiled kernel as configured with 3.1.0-46-<your_username>

Using all configuration options

Use Case: You have a freshly installed system that you update frequently and you want to keep

  • the kernel that came with the installation media and its successor
  • the newest kernel and its predecessor
  • your own, self-compiled kernel named 3.1.0-46-<your_username>

Configuration: Change the multiversion kernels line in /etc/zypp/zypp.conf to the following:

multiversion.kernels = latest,latest-1,oldest,oldest+1,3.1.0-46-<your_username>,running

Explanation: When you reboot your system after the installation of a new kernel, the system will keep

  • the new and running kernel as configured with latest,running
  • the predecessor of the new and running kernel as configured with latest-1
  • your self-compiled kernel as configured with 3.1.0-46-<your_username>
  • the kernel that came with the installation media as configured with oldest
  • the successor of the kernel from the installation media as configured with oldest+1

External links

--Freigeist A 08:09, 25 December 2011 (MST)