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.

Giuseppe
  • 203

2 Answers2

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.

fkraiem
  • 12,813
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
    
user.dz
  • 49,176