I have kernel 4.18 running now and I wanted to remove the old 4.15 kernel since it's not needed. What is the command to remove the old kernel.
I have kernel 4.18 running now and I wanted to remove the old 4.15 kernel since it's not needed. What is the command to remove the old kernel.
Run the command dpkg --get-selections | egrep '^linux' to see what kernel versions are installed.
Uninstall the ones you don't want with sudo apt remove package name1 package-name2... etc. You can also use apt purge instead of apt remove if you want to completely remove them. Also you'll probably find you have both linux-generic and linux-generic-hwe-18.04 installed. You can uninstall linux-generic in this case.
When I removed 4.15 a few days ago on one of my boxes, I removed these packages:
Depending on which versions you had installed, your package names may differ. You may also have additional packages if you installed source, headers, DKMS modules etc.Code:linux-generic linux-image-4.15.0-48-generic linux-modules-4.15.0-48-generic linux-modules-extra-4.15.0-48-generic linux-headers-4.15.0-51 linux-headers-4.15.0-51-generic linux-image-4.15.0-51-generic linux-modules-4.15.0-51-generic linux-modules-extra-4.15.0-51-generic
You may also want to do a sudo apt --purge autoremove afterward to remove any unneeded dependencies as well.
Last edited by kpatz; June 8th, 2019 at 05:03 PM.
Current 'buntu systems: multiple systems running Server or Desktop 22.04 LTS / Retired or Upgraded: 18.04.2 LTS, Mythbuntu 16.04 LTS, Ubuntu 16.04.1 LTS, 14.04 LTS, 10.04 LTS, 8.04 LTS
Been using ubuntu since 6.04 (16 years!)
Most of the time this is enough:
This command removes packages that were automatically installed to resolve a dependency, but are now no longer depended on. This includes old versions of linux-headers-* and linux-image-*. (It’s also smart about this process, leaving one spare version of the kernel around as a fallback!)Code:sudo apt autoremove
If that's not enough:
^^^^^^^^^^^^^^^^Code:uname -r
DO NOT REMOVE THIS KERNEL!
Next, type the command below to view/list all installed kernels on your system.
Find all the kernels that are lower versions than your current kernel. When you know which kernel to remove, continue below to remove it. Run the commands below to remove the kernel you selected.Code:dpkg --list 'linux-image-*'
Finally, run the commands below to update grub2Code:sudo apt purge linux-image-x.x.x-x-generic
Reboot your system.Code:sudo update-grub2
Ha! Ninja'd by kpatz
Last edited by 1fallen; June 8th, 2019 at 05:45 PM. Reason: to make sense
With realization of one's own potential and self-confidence in one's ability, one can build a better world.
Dalai Lama>>
Code Tags | System-info | Forum Guide lines | Arch Linux, Debian Unstable, FreeBSD
I found with the 4.15 (generic) and 4.18 (HWE) installed autoremove was leaving two 4.15 and two 4.18 kernels in place,and updates were installing kernel updates for both, so uninstalling the 4.15 packages solved this.
apt is pretty good about updating grub when installing/removing kernels so there's no need to run update-grub manually in most cases.
Current 'buntu systems: multiple systems running Server or Desktop 22.04 LTS / Retired or Upgraded: 18.04.2 LTS, Mythbuntu 16.04 LTS, Ubuntu 16.04.1 LTS, 14.04 LTS, 10.04 LTS, 8.04 LTS
Been using ubuntu since 6.04 (16 years!)
If you're running the 4.18 kernel series then you'd be running the linux-image-generic-hwe-18.04 kernel.
In which case do the suggested removals posted above and also remove the linux-image-generic package.
that is tied to the 4.15 kernels. Removing that will keep you from getting newer 4.15 kernels.
Do same for any headers.
basically keep
and removeCode:linux-image-generic-hwe-18.04 linux-headers-generic-hwe-18.04
(linux-generic would keep reinstalling both those image and headers generic packages, so double check that it is also not installed.)Code:linux-image-generic linux-headers-generic and if installed linux-generic
Last edited by deadflowr; June 8th, 2019 at 05:53 PM. Reason: words, can't spel 'em
Splat Double Splat Triple Splat
Earn Your Keep
Don't mind me, I'm only passing through.
Once in a blue moon, I'm actually helpful.
Thank you!
Bookmarks