Go back to previous page
Go back to home page
How to get rid of useless
kernels
under Ubuntu
Introduction
Recipe
Links
About the author
Introduction
Lots of kernel updates come along with the regular updates of the
distribution. In order to avoid disk saturation, it is a good rule of
thumb to get rid of the oldest version.
Recipe
Get the version of the current running kernel:
$ uname -r
2.6.22-14-generic
List the installed linux images (the current versions are in red):
$ dpkg -l | grep
linux-image
ii
linux-image-2.6.17-10-generic
2.6.17.1-10.34
Linux
kernel
image
for
version
2.6.17
on
x86/x86_64
ii
linux-image-2.6.17-11-generic
2.6.17.1-11.38
Linux
kernel
image
for
version
2.6.17
on
x86/x86_64
ii
linux-image-2.6.17-12-generic
2.6.17.1-12.41
Linux
kernel
image
for
version
2.6.17
on
x86/x86_64
ii
linux-image-2.6.20-16-generic
2.6.20-16.32
Linux
kernel
image
for
version
2.6.20
on
x86/x86_64
ii
linux-image-2.6.22-14-generic
2.6.22-14.47
Linux
kernel
image
for
version
2.6.22
on
x86/x86_64
ii
linux-image-generic
2.6.22.14.21
Generic
Linux
kernel
image
This corresponds to lots of kernels stored in /boot:
$ cd /boot
$ ls -l
total 64872
-rw-r--r-- 1 root
root 285721 2006-12-05 23:47 abi-2.6.17-10-generic
-rw-r--r-- 1 root
root 285721 2007-05-19 01:57 abi-2.6.17-11-generic
-rw-r--r-- 1 root
root 285721 2007-09-24 01:14 abi-2.6.17-12-generic
-rw-r--r-- 1 root
root 414274 2007-09-23 22:28 abi-2.6.20-16-generic
-rw-r--r-- 1 root
root 424317 2007-12-18 11:36 abi-2.6.22-14-generic
-rw-r--r-- 1 root
root 74707 2006-12-05 22:20 config-2.6.17-10-generic
-rw-r--r-- 1 root
root 74707 2007-05-19 00:31 config-2.6.17-11-generic
-rw-r--r-- 1 root
root 74707 2007-09-23 23:49 config-2.6.17-12-generic
-rw-r--r-- 1 root
root 83217 2007-09-23 19:47 config-2.6.20-16-generic
-rw-r--r-- 1 root
root 75311 2007-12-18 11:36 config-2.6.22-14-generic
drwxr-xr-x 2 root
root 4096 2007-12-22 17:51 grub
-rw-r--r-- 1 root
root 5413807 2007-02-10 12:36 initrd.img-2.6.17-10-generic
-rw-r--r-- 1 root
root 5413595 2007-06-20 18:33 initrd.img-2.6.17-11-generic
-rw-r--r-- 1 root
root 6894907 2007-10-30 00:28 initrd.img-2.6.17-12-generic
-rw-r--r-- 1 root
root 5497254 2007-10-30 00:06 initrd.img-2.6.17-12-generic.bak
-rw-r--r-- 1 root
root 6909795 2007-10-30 00:31 initrd.img-2.6.20-16-generic
-rw-r--r-- 1 root
root 6906472 2007-10-30 00:29 initrd.img-2.6.20-16-generic.bak
-rw-r--r-- 1 root
root 7359207 2007-12-22 17:51 initrd.img-2.6.22-14-generic
-rw-r--r-- 1 root
root 7358740 2007-10-30 23:07 initrd.img-2.6.22-14-generic.bak
-rw-r--r-- 1 root
root 103204 2007-09-28 12:06 memtest86+.bin
-rw-r--r-- 1 root
root 728778 2006-12-05 23:47 System.map-2.6.17-10-generic
-rw-r--r-- 1 root
root 729932 2007-05-19 01:57 System.map-2.6.17-11-generic
-rw-r--r-- 1 root
root 730033 2007-09-24 01:14 System.map-2.6.17-12-generic
-rw-r--r-- 1 root
root 807071 2007-09-23 22:30 System.map-2.6.20-16-generic
-rw-r--r-- 1 root
root 823535 2007-12-18 11:36 System.map-2.6.22-14-generic
-rw-r--r-- 1 root
root 1636700 2006-12-05 23:47 vmlinuz-2.6.17-10-generic
-rw-r--r-- 1 root
root 1636016 2007-05-19 01:57 vmlinuz-2.6.17-11-generic
-rw-r--r-- 1 root
root 1636083 2007-09-24 01:14 vmlinuz-2.6.17-12-generic
-rw-r--r-- 1 root
root 1747372 2007-09-23 22:28 vmlinuz-2.6.20-16-generic
-rw-r--r-- 1 root
root 1764440 2007-12-18 11:36 vmlinuz-2.6.22-14-generic
Remove the useless versions (this updates the grub menu /boot/grub/menu.lst):
$ sudo apt-get
--purge remove linux-image-2.6.20-16-generic
Lecture des listes
de paquets... Fait
Construction de
l'arbre des
dépendances
Lecture des
informations d'état... Fait
Les paquets suivants
seront ENLEVÉS :
linux-image-2.6.20-16-generic*
linux-restricted-modules-2.6.20-16-generic*
0 mis à jour, 0
nouvellement installés, 2 à enlever et 0 non mis à
jour.
Il est nécessaire de
prendre 0o dans les archives.
Après dépaquetage, 114Mo d'espace disque seront
libérés.
Souhaitez-vous
continuer [O/n] ? O
(Lecture de la base
de données... 156625 fichiers et répertoires
déjà installés.)
Suppression de
linux-restricted-modules-2.6.20-16-generic ...
Purge des fichiers
de configuration de linux-restricted-modules-2.6.20-16-generic ...
Suppression de
linux-image-2.6.20-16-generic ...
Running postrm hook
script /sbin/update-grub.
Your
/etc/kernel-img.conf needs to be updated. Read grub's NEWS.Debian[1]
file and follow its
instructions.
1.
/usr/share/doc/grub/NEWS.Debian.gz
Searching for GRUB
installation directory ... found: /boot/grub
Searching for
default file ... found: /boot/grub/default
Testing for an
existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash
image ... none found, skipping ...
Found kernel:
/boot/vmlinuz-2.6.22-14-generic
Found kernel:
/boot/vmlinuz-2.6.17-12-generic
Found kernel:
/boot/vmlinuz-2.6.17-11-generic
Found kernel:
/boot/vmlinuz-2.6.17-10-generic
Found kernel:
/boot/memtest86+.bin
Updating
/boot/grub/menu.lst ... done
The link
/vmlinuz.old is a damaged link
Removing symbolic
link vmlinuz.old
Unless you used the
optional flag in lilo,
you may
need to re-run your boot loader[lilo]
The link
/initrd.img.old is a damaged link
Removing symbolic
link initrd.img.old
Unless you used the
optional flag in lilo,
you may
need to re-run your boot loader[lilo]
Purge des fichiers
de configuration de linux-image-2.6.20-16-generic ...
Running postrm hook
script /sbin/update-grub.
Your
/etc/kernel-img.conf needs to be updated. Read grub's NEWS.Debian[1]
file and follow its
instructions.
1.
/usr/share/doc/grub/NEWS.Debian.gz
Searching for GRUB
installation directory ... found: /boot/grub
Searching for
default file ... found: /boot/grub/default
Testing for an
existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash
image ... none found, skipping ...
Found kernel:
/boot/vmlinuz-2.6.22-14-generic
Found kernel:
/boot/vmlinuz-2.6.17-12-generic
Found kernel:
/boot/vmlinuz-2.6.17-11-generic
Found kernel:
/boot/vmlinuz-2.6.17-10-generic
Found kernel:
/boot/memtest86+.bin
Updating
/boot/grub/menu.lst ... done
$
We can check the cleanup of the packages:
$ dpkg -l | grep
linux-image
ii
linux-image-2.6.22-14-generic
2.6.22-14.47
Linux
kernel
image
for
version
2.6.22
on
x86/x86_64
ii
linux-image-generic
2.6.22.14.21
Generic
Linux
kernel
image
The /boot
directory has been cleaned up as well:
$ cd /boot
$ ls
-l
total 22936
-rw-r--r-- 1 root
root 424317 2007-12-18 11:36 abi-2.6.22-14-generic
-rw-r--r-- 1 root
root 75311 2007-12-18 11:36 config-2.6.22-14-generic
drwxr-xr-x 2 root
root 4096 2008-02-01 10:50 grub
-rw-r--r-- 1 root
root 5497254 2007-10-30 00:06 initrd.img-2.6.17-12-generic.bak
-rw-r--r-- 1 root
root 7359207 2007-12-22 17:51 initrd.img-2.6.22-14-generic
-rw-r--r-- 1 root
root 7358740 2007-10-30 23:07 initrd.img-2.6.22-14-generic.bak
-rw-r--r-- 1 root
root 103204 2007-09-28 12:06 memtest86+.bin
-rw-r--r-- 1 root
root 823535 2007-12-18 11:36 System.map-2.6.22-14-generic
-rw-r--r-- 1 root
root 1764440 2007-12-18 11:36 vmlinuz-2.6.22-14-generic
We can verify that /boot/grub/menu.lst
has been updated:
$ more
/boot/grub/menu.lst
[...]
title
Ubuntu 7.10, kernel 2.6.22-14-generic
root
(hd0,0)
kernel
/boot/vmlinuz-2.6.22-14-generic
root=UUID=40e71a91-f1fc-4e08-a8ac-ddf0497dbc44
ro
quiet
splash
initrd
/boot/initrd.img-2.6.22-14-generic
quiet
title
Ubuntu
7.10,
kernel
2.6.22-14-generic
(recovery
mode)
root
(hd0,0)
kernel
/boot/vmlinuz-2.6.22-14-generic
root=UUID=40e71a91-f1fc-4e08-a8ac-ddf0497dbc44
ro
single
initrd
/boot/initrd.img-2.6.22-14-generic
title
Ubuntu
7.10,
memtest86+
root
(hd0,0)
kernel
/boot/memtest86+.bin
quiet
[...]
Links
About the
author
The author is an engineer in computer sciences located in France. He
can be contacted here or
you can have
a look at his WEB
home page.