2

I have just updated Ubuntu to 16.04 version and when I boot, grub shows the kernels from the previous Ubuntu version. How can I delete them? (not only in the grub list but to actually free that space in the disc).

Please, this is not duplicated from How do I remove old kernel versions to clean up the boot menu? The answers there do not work when you change Ubuntu version. dpkg is not a solution!

System: Dell Studio 1557, i7-720QM@1.60GHz, 4 GB RAM. Legacy boot.

When I do sudo update-grub I get:

Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.0-22-generic
Found initrd image: /boot/initrd.img-4.4.0-22-generic
Found linux image: /boot/vmlinuz-4.4.0-21-generic
Found initrd image: /boot/initrd.img-4.4.0-21-generic
Found linux image: /boot/vmlinuz-3.13.0-86-generic
Found initrd image: /boot/initrd.img-3.13.0-86-generic
Found linux image: /boot/vmlinuz-3.13.0-85-generic
Found initrd image: /boot/initrd.img-3.13.0-85-generic
Found linux image: /boot/vmlinuz-3.13.0-83-generic
Found initrd image: /boot/initrd.img-3.13.0-83-generic
Found linux image: /boot/vmlinuz-3.13.0-79-generic
Found initrd image: /boot/initrd.img-3.13.0-79-generic
Found linux image: /boot/vmlinuz-3.13.0-77-generic
Found initrd image: /boot/initrd.img-3.13.0-77-generic
Found linux image: /boot/vmlinuz-3.13.0-76-generic
Found initrd image: /boot/initrd.img-3.13.0-76-generic
Found linux image: /boot/vmlinuz-3.13.0-74-generic
Found initrd image: /boot/initrd.img-3.13.0-74-generic
Found linux image: /boot/vmlinuz-3.13.0-73-generic
Found initrd image: /boot/initrd.img-3.13.0-73-generic
Found linux image: /boot/vmlinuz-3.11.0-26-generic
Found initrd image: /boot/initrd.img-3.11.0-26-generic
Found linux image: /boot/vmlinuz-3.11.0-24-generic
Found initrd image: /boot/initrd.img-3.11.0-24-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 7 (loader) on /dev/sda3
done

But when I do dpkg -l | grep linux-image I only get:

ii  linux-image-4.4.0-21-generic                4.4.0-21.37                                         amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.4.0-22-generic                4.4.0-22.39                                         amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-extra-4.4.0-21-generic          4.4.0-21.37                                         amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-extra-4.4.0-22-generic          4.4.0-22.39                                         amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-generic                         4.4.0.22.23                                         amd64        Generic Linux kernel image

and all the one-liner code I found in other threads to solve this rely on dpkg, they do not work.

The content of boot is:

abi-3.11.0-24-generic
abi-3.11.0-26-generic
abi-3.13.0-73-generic
abi-3.13.0-74-generic
abi-3.13.0-76-generic
abi-3.13.0-77-generic
abi-3.13.0-79-generic
abi-3.13.0-83-generic
abi-3.13.0-85-generic
abi-3.13.0-86-generic
abi-4.4.0-21-generic
abi-4.4.0-22-generic
config-3.11.0-24-generic
config-3.11.0-26-generic
config-3.13.0-73-generic
config-3.13.0-74-generic
config-3.13.0-76-generic
config-3.13.0-77-generic
config-3.13.0-79-generic
config-3.13.0-83-generic
config-3.13.0-85-generic
config-3.13.0-86-generic
config-4.4.0-21-generic
config-4.4.0-22-generic
grub
initrd.img-3.11.0-24-generic
initrd.img-3.11.0-26-generic
initrd.img-3.13.0-73-generic
initrd.img-3.13.0-74-generic
initrd.img-3.13.0-76-generic
initrd.img-3.13.0-77-generic
initrd.img-3.13.0-79-generic
initrd.img-3.13.0-83-generic
initrd.img-3.13.0-85-generic
initrd.img-3.13.0-86-generic
initrd.img-4.4.0-21-generic
initrd.img-4.4.0-22-generic
memtest86+.bin
memtest86+.elf
memtest86+_multiboot.bin
System.map-3.11.0-24-generic
System.map-3.11.0-26-generic
System.map-3.13.0-73-generic
System.map-3.13.0-74-generic
System.map-3.13.0-76-generic
System.map-3.13.0-77-generic
System.map-3.13.0-79-generic
System.map-3.13.0-83-generic
System.map-3.13.0-85-generic
System.map-3.13.0-86-generic
System.map-4.4.0-21-generic
System.map-4.4.0-22-generic
vmlinuz-3.11.0-24-generic
vmlinuz-3.11.0-26-generic
vmlinuz-3.13.0-73-generic
vmlinuz-3.13.0-74-generic
vmlinuz-3.13.0-76-generic
vmlinuz-3.13.0-77-generic
vmlinuz-3.13.0-79-generic
vmlinuz-3.13.0-83-generic
vmlinuz-3.13.0-85-generic
vmlinuz-3.13.0-86-generic
vmlinuz-4.4.0-21-generic
vmlinuz-4.4.0-22-generic

But the old kernels do not appear in Synaptic, so please do not suggest that, and booting with the old kernels does not make them appear in synaptic nor available for dpkg.

sudo apt-get autoremove also does nothing:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

The same for sudo apt-get autoremove linux-headers-3.11.0-24-generic

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package linux-headers-3.11.0-24-generic
E: Couldn't find any package by glob 'linux-headers-3.11.0-24-generic'
E: Couldn't find any package by regex 'linux-headers-3.11.0-24-generic'

sudo apt-get remove linux-image-3.11.0-24-generic also does nothing:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package linux-image-3.11.0-24-generic
E: Couldn't find any package by glob 'linux-image-3.11.0-24-generic'
E: Couldn't find any package by regex 'linux-image-3.11.0-24-generic'

sudo apt-get purge linux-image-3.11.0-24-generic also does nothing:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package linux-image-3.11.0-24-generic
E: Couldn't find any package by glob 'linux-image-3.11.0-24-generic'
E: Couldn't find any package by regex 'linux-image-3.11.0-24-generic'

Please do not suggest me to use "ubuntu-tweak", the links take you to a weird site in Chinese.

sudo apt-get autoclean and sudo apt-get clean also do nothing.

As you can see I am not an expert, I tried everything I found, should I delete those files straight away? is there something else I should delete? The old kernels do not show up in /lib/firmware/ or /lib/modules/.

  • You can download tweak-ubuntu from Ubuntu repository itself. – 7_R3X May 14 '16 at 21:36
  • Thanks for your answer, I tried to do it through the repositories but it did not work: sudo add-apt-repository ppa:tualatrix/ppa sudo apt-get update sudo apt-get install ubuntu-tweak Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package ubuntu-tweak Everybody talks about the oficial site ubuntu-tweak.com but it redirects you to a Chinese written site. – hbond May 15 '16 at 0:29
  • @hbond It sounds to me a GRUB problem. I think updating them can help. Please, see looserof7's proposal here for me with two Ubuntu systems askubuntu.com/q/772224/25388 for the process with Live Ubuntu: ...; sudo grub-install /dev/[sd...]; .... It may be related. Can you please add your System info in the beginning of the body. Is your boot legacy or EFI? – Léo Léopold Hertz 준영 May 15 '16 at 8:49
  • 1
    Thanks @Masi, I added the system info. I also read your thread but grub seems to be working fine, it boots and everything. My hypothesis as a total noob is that the old kernels are not suitable for Ubuntu 16.04, so the programmers did not include them in synaptics, then they are not showed when i do dpkg -l | grep linux-image, so I cannot uninstall them. In other Ubuntu updates in the past I was able to uninstall old kernels. – hbond May 15 '16 at 15:10
  • Part of why I prefer clean installs. We almost never suggest using rm command, as it can be dangerous. And if you do delete something that is in dpkg it will get system confused & require repairs. But your case on upgrade, dpkg does not have previous installs files. In /boot any old version file will have to be manually deleted. You should have been housecleaning before upgrade, so only a couple old ones left. You also want to check /usr/src/* and /var/cache/apt/archives to see if old versions also there. – oldfred May 15 '16 at 15:36
0

Since none of the kernels are recognized as installed by apt/dpkg you can safely delete them as @oldfred states. In case you havent already, issue:

  1. mount /boot && cd /boot
  2. rm -v abi-* && rm -v config-* && rm -v initrd* && rm -v System* && rm -v vmlinuz*
  3. sudo apt-get install linux-image
  4. sudo update-grub
  5. Reboot
  • Isn't step 2 a little risky because it will also remove the image he uses? What if something happens and steps 3/4 don't finish properly? (Unlikely I know.) – Karsus Jun 12 '16 at 0:38
  • @Karsus Step 2 is risky, but step 3 replaces the images we just deleted... I did it this way for 2 reasons 1) I didnt know what image was currently being used, and 2) There are so many unneeded itms that its faster to delete and replace than it is to pick and choose – eyoung100 Jun 12 '16 at 3:22

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.