6

I used the script describe in this question to list the kernel installed on the computer :

How do I remove old kernel versions to clean up the boot menu?

In the 3.2.0, I have 33, 34, 35, 36, 37, 38, 39, 41, 43, 44, 45 and 48. I would expect to be running 3.2.0-48 after a reboot, but I am still running 3.2.0-32. Why the kernels installed by auto update are not used (and not offered in menu.lst)?

[I am running 12.04 LTS]

grep title /boot/grub/menu.lst result in :

title       Ubuntu 12.04.1 LTS, kernel 3.2.0-32-generic
title       Ubuntu 12.04.1 LTS, kernel 3.2.0-32-generic (recovery mode)
title       Ubuntu 12.04.1 LTS, kernel 2.6.32-45-generic
title       Ubuntu 12.04.1 LTS, kernel 2.6.32-45-generic (recovery mode)
title       Ubuntu 12.04.1 LTS, kernel 2.6.32-44-generic
title       Ubuntu 12.04.1 LTS, kernel 2.6.32-44-generic (recovery mode)
title       Ubuntu 12.04.1 LTS, kernel 2.6.32-43-generic
title       Ubuntu 12.04.1 LTS, kernel 2.6.32-43-generic (recovery mode)
title       Ubuntu 12.04.1 LTS, memtest86+

I would have expected the kernel between 3.2.0-33 to 3.2.0-48 to be in this file and the default to be latest. Why the kernel 3.2.0-33 to 48 are not added in this file?


When I ran sudo dpkg-reconfigure linux-image-3.2.0-48-generic, it found all the other kernels, and regenerated menu.lst, but in contains only the same 9 entries.

  • Could you link to the specific answer providing the script? The question has many many answers - I don't know which you've used. Either way, it seems broken. Don't use it - manage the kernels yourself or using sudo apt-get autoremove if you want to remove older kernel versions. – gertvdijk Jun 26 '13 at 09:27
  • I can't find linux-image-3.2.0-48-generic package : http://packages.ubuntu.com/search?keywords=linux-image-3.2.0 Have you try sudo dpkg-reconfigure linux-image-3.2.0-48-generic ? – Jérémie Lesage Jun 26 '13 at 09:21
  • 1
    linux-image-3.2.0-48-generic is a valid package, released as a security update - via security.ubuntu.com. It will be incorporated later in the regular sources in precise-updates. See https://launchpad.net/ubuntu/precise/+package/linux-image-3.2.0-48-generic – gertvdijk Jun 26 '13 at 09:25
  • @Jérémie Lesage - I did not use this website. Why is it relevant? I rely on "dpkg -l". – Guillaume Coté Jul 02 '13 at 16:31
  • @qertvdijk - I don't know to link to a specific answer, but the script is : dpkg -l '''linux-''' | sed '''/^ii/!d;/'''2.6.32-45'''/d;s/^[^ ] [^ ]* ([^ ])./\1/;/[0-9]/!d'' – Guillaume Coté Jul 02 '13 at 16:36
  • @Jérémie Lesage - I updated the question with the result of sudo dpkg-reconfigure linux-image-3.2.0-48-generic ? – Guillaume Coté Jul 03 '13 at 21:16

1 Answers1

0

You are asking two questions: Why did it happen, and how do I fix it?

What should happen

When the package manager installs a new kernel, the script at /etc/kernel/postinst.d/apt-auto-removal marks the previous kernel for deletion the next time the package manager runs. It does work properly for most users most of the time.

The script is rather conservative. It doesn't delete all old kernels, and it errs on the side of leaving kernels in place rather that erroneously delete your current kernel or previous kernel (in case you need to revert). It doesn't scan to see all the kernels you have installed - it just uses the version numbers of the new and current kernels.

Why it didn't happen

There could have been a bug in the script, a different package management problem could have prevented the marking, several user actions could have remarked the package to manually-installed before deletion. The exact cause is unknown and possibly unknowable. It's all a rich tapestry.

How to fix it

Fixing is very easy. You need two pieces of information:

  1. The current kernel (use the command: uname -r)
  2. The other kernels installed (use the command: ls /boot)

Example:

$ uname -r
3.11.0-15-generic

$ ls /boot
abi-3.11.0-14-generic         initrd.img-3.11.0-14-generic
abi-3.11.0-15-generic         initrd.img-3.11.0-15-generic
config-3.11.0-14-generic      System.map-3.11.0-14-generic
config-3.11.0-15-generic      System.map-3.11.0-15-generic
extlinux                      vmlinuz-3.11.0-14-generic
grub                          vmlinuz-3.11.0-15-generic

Ignore all the file names. Look at all the version numbers. You can see from the example the there are two kernel versions installed:

  • 3.11.0-14-generic (can be deleted)
  • 3.11.0-15-generic (the running kernel - do NOT delete!)

So we can delete the old kernel:

sudo apt-get remove linux-image-3.11.0-14-generic

When a kernel is removed, the package manager will automatically remove all those files from /boot and update the grub menu.

user535733
  • 62,253