Removing old kernel entries in GRUB boot loader menu

James Gray james at grayonline.id.au
Fri Jul 14 07:09:21 UTC 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

yager wrote:
> Use your favorite editor to edit the /boot/grub/menu.lst file.  I use
> gedit and type the following command.
> 
> sudo gedit /boot/grub/menu.lst
> 
> Remove all of the entries that you no longer need from the list.
> 
> After you have removed the entries, you can go back and remove the
> vinitrd and vmlinuz files from the boot directory that you no longer
> need.

That will cause dpkg headaches when you remove the package the kernel
was originally part of - besides, you forgot to delete the bulk of the
kernel in /lib/modules/<kernel-ver>.  Remove the *package* the old
kernel belongs to, and as part of the removal process, the grub entries
will be removed too.  Simple.

To see what kernels are installed, try this:

export COLUMNS=150; dpkg -l '*image*' | grep ^ii

The "COLUMNS" environment variable is used by dpkg to draw the output.
Unfortunately it's often too small to see the FULL package name with all
the version numbers a fru-fru associated with kernel images.  So by
explicitly setting "COLUMNS" you can trick dpkg into displaying more
info, although it will probably wrap around, so watch out for that.  If
you still can't see the full package name, increase 150 to something
else (180? 200?  who cares?! :P)

Now that you have the package name;

apt-get --purge remove <name-of-kernel-package>

WARNING: DO NOT REMOVE THE RUNNING KERNEL!!!
         Not unless:
         1. you know what you're doing
         2. you have a backup plan (rescue CD - and know how to use it)
         3. you know for sure you didn't screw up the "apt-get" command

Best option is to find the correct meta-package for whatever kernel you
want to run (386/686/k7/k8/smp/etc), install the meta package.  Then
when new kernels come out it removes the old one as part of the
meta-package upgrade process.  You still need to manually remove the old
kernels that were installed PRIOR to the meta-package.

No need to break out the text editor or go removing "package-managed"
files.  That's what dpkg was designed to avoid :)

Cheers,

James
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEt0MgwBHpdJO7b9ERAuSHAJ94ThyK05iEYwDo69NsMl13GCfVfQCgjNBB
Z1iaQt5E6YVSSrIiQia+WM0=
=bsnC
-----END PGP SIGNATURE-----





More information about the ubuntu-users mailing list