[clug] Removing older kernels

Scott Ferguson scott.ferguson.clug at gmail.com
Sat Aug 15 01:48:45 UTC 2015


Are you running Ubuntu 14.04.3 (Trusty Tahr)?
lsb_release -d

If not ignore the following.

On 15/08/15 01:57, Bryan Kilgallin wrote:
> Thanks, Scott:
> 
>> Perhaps you are trying to solve a problem that does not exist?
> 
> On bootup, I saw a great long list of versions.
> 
>> What is the output of:-
>> dpkg --get-selections | grep 'linux-image\|linux-headers'
> 
<snipped>

> linux-headers-generic-lts-raring        install
> linux-headers-generic-lts-trusty        install

<snipped>

> linux-image-generic-lts-raring            install
> linux-image-generic-lts-trusty            install

Those are meta-packages - you 'can' safely remove them without removing
the actual packages they install (in this case, the 3.8 and 3.13
linux-images. Where removing a meta-package *will* cause a problem is if
you then run autoremove. The simplest way to solve the autoremove
problem is not to remove a meta-package (or avoid installing them in the
first place). There are less simple ways - but they are beyond the scope
of a mailing list.

Meta-packages are convenient. Lean and mean is the price you pay for
that convenience.

Minimal disk space usage, updates, and complexity, and, sub-10 second
boot are other prices of convenience. Determining what is best requires
a weighted decision matrix - something else that is beyond the scope of
a mailing list. For which reason the suggestions below retain the meta
package, and the subject of the original Subject (and thread tangent)
was removing unneeded kernels and headers rather than how to achieve a
4-second boot time.

> 
>> determined the kernel in use e.g.:-
>> uname -r
> 
> That reported "3.13.0-61-generic". 

That's the Ubuntu Linux kernel image for version 3.13.0 on 64 bit x86
SMP. It is a dependency of the linux-image-generic-lts-trusty meta-package.
It uses linux-headers-3.13.0-61-generic (Linux kernel headers for
version 3.13.0 on 64 bit x86 SMP) and linux-source-3.13.0 (Linux kernel
source for version 3.13.0 with Ubuntu patches). Make sure it supports
all the functions you require before removing other kernels.
It's possible you still have the original packages for the other kernels
and headers in /var/cache/apt/archives convenient for re-installation
anyway.

To remove other linux-images and headers, as root, run the following and
check for sanity:-
apt-get -s remove $(dpkg --get-selections|grep
'linux-image\|linux-headers'|grep -v '3.13\|lts-trust' | cut -f1) | more

*If* the results look sane, proceed with the removal:-
apt-get -y remove $(dpkg --get-selections|grep
'linux-image\|linux-headers'|grep -v '3.13\|lts-trust' | cut -f1)

NOTE: the result will not significantly speed up the boot, however it
will free up some disk space and trim your GRUB menu. If you have a
separate /boot partition (not the default for Ubuntu) then, depending on
it's size, it 'may' be a "compelling" reason to remove those kernels.
Likewise if you have limited space on your / partition.


Kind regards




More information about the linux mailing list