5

How do I prevent Ubuntu from attempting to upgrade the kernel?

The underlying OpenVZ architecture of my host provides this kernel:

$ uname -r
2.6.32-042stab116.2

And my understanding is this is outside of my control. Yet, every time I do:

$ sudo aptitude update && sudo aptitude safe-upgrade

I see that Ubuntu tries (and fails) to upgrade. I now have several packages in a partially installed state:

$ dpkg -l |grep linux

ii  libselinux1:i386                     2.2.2-1ubuntu0.1                     i386         SELinux runtime shared libraries
ii  linux-firmware                       1.127.22                             all          Firmware for Linux kernel drivers
iU  linux-generic                        3.13.0.101.109                       i386         Complete Generic Linux kernel and headers
ii  linux-headers-3.13.0-100             3.13.0-100.147                       all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-100-generic     3.13.0-100.147                       i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
ii  linux-headers-3.13.0-101             3.13.0-101.148                       all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-101-generic     3.13.0-101.148                       i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
ii  linux-headers-3.13.0-91              3.13.0-91.138                        all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-91-generic      3.13.0-91.138                        i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
ii  linux-headers-3.13.0-92              3.13.0-92.139                        all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-92-generic      3.13.0-92.139                        i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
ii  linux-headers-3.13.0-93              3.13.0-93.140                        all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-93-generic      3.13.0-93.140                        i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
ii  linux-headers-3.13.0-96              3.13.0-96.143                        all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-96-generic      3.13.0-96.143                        i386         Linux kernel headers for version 3.13.0 on 32 bit x86 SMP
ii  linux-headers-generic                3.13.0.101.109                       i386         Generic Linux kernel headers
iF  linux-image-3.13.0-100-generic       3.13.0-100.147                       i386         Linux kernel image for version 3.13.0 on 32 bit x86 SMP
iF  linux-image-3.13.0-101-generic       3.13.0-101.148                       i386         Linux kernel image for version 3.13.0 on 32 bit x86 SMP
iF  linux-image-3.13.0-92-generic        3.13.0-92.139                        i386         Linux kernel image for version 3.13.0 on 32 bit x86 SMP
iF  linux-image-3.13.0-93-generic        3.13.0-93.140                        i386         Linux kernel image for version 3.13.0 on 32 bit x86 SMP
iF  linux-image-3.13.0-96-generic        3.13.0-96.143                        i386         Linux kernel image for version 3.13.0 on 32 bit x86 SMP
iU  linux-image-extra-3.13.0-100-generic 3.13.0-100.147                       i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
iU  linux-image-extra-3.13.0-101-generic 3.13.0-101.148                       i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
iU  linux-image-extra-3.13.0-92-generic  3.13.0-92.139                        i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
iU  linux-image-extra-3.13.0-93-generic  3.13.0-93.140                        i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
iU  linux-image-extra-3.13.0-96-generic  3.13.0-96.143                        i386         Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
iU  linux-image-generic                  3.13.0.101.109                       i386         Generic Linux kernel image
ii  linux-libc-dev:i386                  3.13.0-101.148                       i386         Linux Kernel Headers for development
ii  syslinux                             3:4.05+dfsg-6+deb8u1                 i386         collection of boot loaders
ii  syslinux-common                      3:4.05+dfsg-6+deb8u1                 all          collection of boot loaders (common files)
ii  util-linux                           2.20.1-5.1ubuntu20.7                 i386         Miscellaneous system utilities

For completeness, I am running a very similar OpenVZ container (same hosting) which does not show the same problem:

$ uname -r
2.6.32-042stab116.2

$ dpkg -l |grep linux
ii  libselinux1:i386                  2.2.2-1ubuntu0.1                     i386         SELinux runtime shared libraries
ii  libv4l-0:i386                     1.0.1-1                              i386         Collection of video4linux support libraries
ii  libv4lconvert0:i386               1.0.1-1                              i386         Video4linux frame format conversion library
ii  linux-libc-dev:i386               3.13.0-101.148                       i386         Linux Kernel Headers for development
ii  syslinux                          3:4.05+dfsg-6+deb8u1                 i386         collection of boot loaders
ii  syslinux-common                   3:4.05+dfsg-6+deb8u1                 all          collection of boot loaders (common files)
ii  util-linux                        2.20.1-5.1ubuntu20.7                 i386         Miscellaneous system utilities

As you can see, the actual kernel is not listed by dpkg on either machine, but only the former has been bringing in these newer, unwanted kernels. Upgrades on the latter have been working smoothly.

UPDATE

In order to remove the half-installed packages, see this question.

  • I'm operating a number of Ubuntu OpenVZ containers, and I've never seen that happening. Did you try the "original" apt-get or apt (the latter is available since apt 1.0) instead of aptitude? – Henning Kockerbeck Nov 26 '16 at 15:27
  • Please provide the output of dpkg -l | grep linux (as opposed to linux-headers) so it will show kernel image packages as well as headers. – fkraiem Nov 26 '16 at 17:59
  • @fkraiem I have updated the question as you suggest, thanks in advance for your help! – Giuseppe Nov 26 '16 at 18:05
  • @HenningKockerbeck, I am running a very similar Ubuntu OpenVZ container, which does NOT try to upgrade the kernel, and all is well there... What would you suggest that I do with apt-get or apt? – Giuseppe Nov 26 '16 at 18:12
  • As I said, I'm using apt-get or apt to handle the upgrades (apt update, apt full-upgrade and so on), and I've never seen such problems. You seem to use aptitude, so I wanted to check whether that difference maybe has something to do with your problem. – Henning Kockerbeck Nov 27 '16 at 0:07
2
  • fkraiem's answer has already explained why the running kernel can't be updated from the guest container.

  • To prevent kernel update, you have to uninstall its meta packages

    sudo apt-get purge linux-generic linux-image-generic linux-headers-generic
    
2

You have some kernel image packages installed (the packages starting with linux-image), and like all other packages, the package manager wants to upgrade them when a newer version is available in the repositories.

However, in your case the kernel is provided by the host, and the installed kernel packages are completely disregarded. In such cases it is natural to uninstall them; the package manager may complain that you will be left with no kernel package installed since it is normally undesirable, but in your case it is perfectly fine.

Alternatively, keeping them installed and upgraded will do no harm (other than taking up disk space) since they are not used anyway.

  • I don't see how this relates to the question which is about how to prevent kernel upgrades and how (not if) to remove kernel headers packages. – David Foerster Nov 26 '16 at 16:22
  • @DavidFoerster I had read the question too quickly, but OP probably also has some linux-image package, which should be uninstalled too. Obviously, if they are not installed the system will not want to upgrade them. – fkraiem Nov 26 '16 at 17:58
  • @fkraiem, I will try to uninstall all those 3.13 images and headers. Any idea of what may have triggered the newer kernel install? (see also my edits) – Giuseppe Nov 26 '16 at 18:28
  • @Giuseppe Maybe they were just installed by default on this system? You have a lot of them, so you have already upgraded them everal times. – fkraiem Nov 26 '16 at 18:34
  • @fkraiem, uninstalling the unwanted images, as you suggest, is now my focus. I have posted a separate question on the topic: askubuntu.com/questions/854162/… – Giuseppe Nov 27 '16 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.