Ubuntu Old Kernel Package Managment
From DFWLPiki
Summary
Summary Statement
Too many kernels are installed on Ubuntu Desktop
Impact Statement
Too much space is consumed by kernels, over 2GB of space.
Analysis
Steps to Reproduce
root@tao:~# dpkg --list | grep linux-image rc linux-image-3.11.0-13-generic 3.11.0-13.20 amd64 Linux kernel image for version 3.11.0 on 64 bit x86 SMP rc linux-image-3.11.0-14-generic 3.11.0-14.21 amd64 Linux kernel image for version 3.11.0 on 64 bit x86 SMP rc linux-image-3.11.0-15-generic 3.11.0-15.25 amd64 Linux kernel image for version 3.11.0 on 64 bit x86 SMP rc linux-image-3.11.0-17-generic 3.11.0-17.31 amd64 Linux kernel image for version 3.11.0 on 64 bit x86 SMP rc linux-image-3.11.0-18-generic 3.11.0-18.32 amd64 Linux kernel image for version 3.11.0 on 64 bit x86 SMP iF linux-image-3.11.0-20-generic 3.11.0-20.35 amd64 Linux kernel image for version 3.11.0 on 64 bit x86 SMP iF linux-image-3.11.0-22-generic 3.11.0-22.38 amd64 Linux kernel image for version 3.11.0 on 64 bit x86 SMP rc linux-image-3.11.0-23-generic 3.11.0-23.40 amd64 Linux kernel image for version 3.11.0 on 64 bit x86 SMP ii linux-image-3.13.0-34-generic 3.13.0-34.60 amd64 Linux kernel image for version 3.13.0 on 64 bit x86 SMP ii linux-image-3.13.0-35-generic 3.13.0-35.62 amd64 Linux kernel image for version 3.13.0 on 64 bit x86 SMP rc linux-image-extra-3.11.0-13-generic 3.11.0-13.20 amd64 Linux kernel extra modules for version 3.11.0 on 64 bit x86 SMP rc linux-image-extra-3.11.0-14-generic 3.11.0-14.21 amd64 Linux kernel extra modules for version 3.11.0 on 64 bit x86 SMP rc linux-image-extra-3.11.0-15-generic 3.11.0-15.25 amd64 Linux kernel extra modules for version 3.11.0 on 64 bit x86 SMP rc linux-image-extra-3.11.0-17-generic 3.11.0-17.31 amd64 Linux kernel extra modules for version 3.11.0 on 64 bit x86 SMP rc linux-image-extra-3.11.0-18-generic 3.11.0-18.32 amd64 Linux kernel extra modules for version 3.11.0 on 64 bit x86 SMP iU linux-image-extra-3.11.0-20-generic 3.11.0-20.35 amd64 Linux kernel extra modules for version 3.11.0 on 64 bit x86 SMP iU linux-image-extra-3.11.0-22-generic 3.11.0-22.38 amd64 Linux kernel extra modules for version 3.11.0 on 64 bit x86 SMP rc linux-image-extra-3.11.0-23-generic 3.11.0-23.40 amd64 Linux kernel extra modules for version 3.11.0 on 64 bit x86 SMP ii linux-image-extra-3.13.0-34-generic 3.13.0-34.60 amd64 Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP ii linux-image-extra-3.13.0-35-generic 3.13.0-35.62 amd64 Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP ii linux-image-generic 3.13.0.35.42 amd64 Generic Linux kernel image
Return to Service
Run this command as root:
apt-get remove --purge $(dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')
or use apt-get to purge packages using package name/version numbers:
apt-get --purge remove linux-image-3.11.0-1*
(let it run to completion)
apt-get --purge remove linux-image-extra-3.11.0-1*
(let it run to completion)
root@tao:~# dpkg --list | grep linux-image ii linux-image-3.13.0-34-generic 3.13.0-34.60 amd64 Linux kernel image for version 3.13.0 on 64 bit x86 SMP ii linux-image-extra-3.13.0-34-generic 3.13.0-34.60 amd64 Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP root@tao:~# uname -a Linux tao 3.13.0-34-generic #60-Ubuntu SMP Wed Aug 13 15:45:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Dpkg should now output installed kernels, and it should match the version of the running kernel.