See question How to remove kernels from previous release? which is marked as duplicate. I ask this again, because the question is special case and not handled in the answers for the related question. I upgraded from 15.10 to 16.04 using an installation media. Kernels from 15.10 are there at /boot, but the package management system seems to be unaware of this after upgrade. Related bug report is here. I do not know, if this happens, if you choose to upgrade in Software Updater.
-
You could do it very easily in a graphical interface software called MintUpdate. But it's not (yet) available for Ubuntu 16. – ipse lute Jun 05 '16 at 16:18
1 Answers
If the kernels are not known to dpkg
, you can remove them by hand by deleting all their files (I do this to remove locally compiled kernels: How can I remove compiled kernel?)
First check which kernel is running with uname -r
DO NOT DELETE THE RUNNING KERNEL
Let's say you want to delete kernel release 3.19.0-56
from your system.
You can use the release string to locate all of its files and directories. locate -b -e 3.19.0-56
will find existing (-e
) files & directories with the string 3.19.0-56
without listing all the files in all the directories (-b
)
Having located them, you can append the command to remove them rm -r
with xargs
. Let's use the -p
flag to make xargs
interactive, so that we can see the targets and confirm before the command is executed. Here's the whole command:
locate -b -e 3.19.0-56 | xargs -p sudo rm -r
Then type y
to really execute rm -r
on the targets shown
(this throws some errors complaining that everything that is not a directory does not exist because you're attempting to delete it recursively with -r
, but it still works and the files are really gone - check again with sudo updatedb && locate -b -e 3.19.0-56
and nothing will be found)
Finally, to clean the boot menu, run
sudo update-grub
-
2
-
Linux version string in file names seems to be specific to files of the respective kernel packages and related packages. Assuming that you could find files to delete by
(version=4.2.0-35; locate "$version" | grep -o '.*'"$(printf '%s' "$version" | sed 's/[.[\*^$]/\\&/g')"'[^/]*' | sort -u)
in case of version 4.2.0-35. – jarno Jun 05 '16 at 15:43 -
Yes, but the command I gave produces a shorter list where not every file in the directories is listed. So it is enough to add those as arguments of
sudo rm -rf
. – jarno Jun 05 '16 at 16:01 -
It seems you could do the same more simply by
locate -b -e 4.2.0-35
. (Option -e guarantees it only lists existing files.) – jarno Jun 05 '16 at 16:23 -
-
I wonder if that
updatedb
is necessary. The files are there from the beginning of installation of the distribution. Or could they be files from another co-existing OS installation? – jarno Sep 11 '16 at 07:09