GRUB2 menu entries increasing with kernel updates

Asked by Angela C. Murphy

I recently installed Ubuntu 10.04 LTS. No problem there. My problem is with the GRUB2 boot menu. I don't know how to edit it. I have and want a triple boot with Ubuntu, Windows XP and Xandros 4.5. The boot menu, however, also has 2 entries for Xandros 3 (for the original kernel and its update). I don't want to boot to this old installation any longer, just mine it for some files and settings. Yesterday, Ubuntu issued a kernel update for Lucid, which I installed. Now the boot menu has 2 more entries, for the new kernel and the recovery boot.
How can I edit the GRUB2 boot menu so that I only see the installations I want to boot to? Start Up Manager is no help here. I am not very experienced in using the command line so I would need step by step instructions. I'm afraid that with more kernel updates the boot menu will become very unwieldy.
Thanks in advance for any help.
murphyac5

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
actionparsnip
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

Run:

uname -a; dpkg -l | grep linux-image

The first output is your current kernel and the others are the installed kernels. If you remove the other kernels, not only will it be removed from the grub2 menu but also will save 120Mb per kernel.

Revision history for this message
Soul-Sing (soulzing) said :
#2

Please always leave two kernels in the grub menu in case of troubles.

Revision history for this message
Angela C. Murphy (murphyac5) said :
#3

 Thanks for the advice. I did run the command and I am pasting the output in this message:

~$ uname -a; dpkg -l | grep linux-image
Linux MurphysDell 2.6.32-22-generic #33-Ubuntu SMP Wed Apr 28 13:27:30 UTC 2010 i686 GNU/Linux
ii linux-image-2.6.32-21-generic 2.6.32-21.32 Linux kernel image for version 2.6.32 on x86
ii linux-image-2.6.32-22-generic 2.6.32-22.33 Linux kernel image for version 2.6.32 on x86
ii linux-image-generic 2.6.32.22.23 Generic Linux kernel image

This lists only the Ubuntu kernels. I am assuming that the only one I can safely remove is 2.6.32-21.32. How do I do that? What about the 2 Xandros kernels - 2.6.9 -x1 and 2.6.11 -x1? I have found the folders in Ubuntu and Xandros where the kernel files are stored - boot. Do I just go in there and move those files to the trash? Do I then have to use grub-update or will it happen automatically? As you can see, I am pretty much a newbie at this. I have used linux, but I've never removed a kernel before. I want to be sure I know what I'm doing before I perform such a drastic action. And what about the config file that goes with each kernel - does that have to be removed also?
Sorry if my questions sound silly.
Thanks for any help.
Angela C. Murphy

-----Original Message-----
From: actionparsnip <email address hidden>
To: <email address hidden>
Sent: Fri, May 7, 2010 6:08 pm
Subject: Re: [Question #110085]: GRUB2 menu entries increasing with kernel updates

Your question #110085 on Ubuntu changed:
https://answers.launchpad.net/ubuntu/+question/110085

    Status: Open => Answered

actionparsnip proposed the following answer:
Run:

uname -a; dpkg -l | grep linux-image

The first output is your current kernel and the others are the installed
kernels. If you remove the other kernels, not only will it be removed
from the grub2 menu but also will save 120Mb per kernel.

--
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/ubuntu/+question/110085/+confirm?answer_id=0

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/ubuntu/+question/110085

You received this question notification because you are a direct
subscriber of the question.

Revision history for this message
Vu Do Quynh (vu-do-quynh) said :
#4

Hi,

You can only remove ubuntu kernels from Ubuntu;
You can only remove xandros kernels after booting to xandros.

To remove unused kernels, you can use synaptic, search for the string linux-image and uncheck the installed kernels that you want to remove. You must not remove the actual running kernel or you'll get big troubles (you'll be warned by synaptic).

It is a safe practice to always leave two kernels, the one you're using and the one before, like leoquant said. Thus in your case you would not yet need to remove kernels as you have only two kernel entries for each distribution, ubuntu and xandros.

For Ubuntu, once the kernels removed, you can run in a terminal as root

sudo update-grub

(which will modify /etc/default/grub)

More info here:
https://wiki.ubuntu.com/Grub2

Regards

Revision history for this message
Best actionparsnip (andrew-woodhead666) said :
#5

Ok you can run:

sudo apt-get --purge remove linux-image-2.6.32-21; sudo apt-get --purge autoremove

You will then gain 120Mb space as well as the removal of the entry in grub.

Revision history for this message
Angela C. Murphy (murphyac5) said :
#6

 Dear actionparsnip,
        Thank you so much for your replies to my questions. I will use your suggestions, but not just yet. I will wait for the next kernel update before removing 2.6.32-21. I reread the GRUB2 information page and forum posting. There it was advised that one working kernel be kept behind the current one (in case something goes wrong, perhaps). That made a lot of sense to me, as it avoids having a whole string of entries in GRUB2, which is what I was afraid of, but still gives a fallback in case of emergencies. You have given me the means to get rid of outdated Ubuntu kernels, so they won't appear in GRUB and I will retrieve 120 Mb of disk space.
        Now if I can just figure out how to get rid of or hide my 2 old Xandros 3 kernels, without booting into Xandros 3, I'll be in good shape. Time to revisit the Xandros user forums I guess.
        Thanks again for all your help. I will mark this question as solved.
Angela C. Murphy

-----Original Message-----
From: actionparsnip <email address hidden>
To: <email address hidden>
Sent: Sun, May 9, 2010 1:01 pm
Subject: Re: [Question #110085]: GRUB2 menu entries increasing with kernel updates

Your question #110085 on Ubuntu changed:
https://answers.edge.launchpad.net/ubuntu/+question/110085

actionparsnip proposed the following answer:
Ok you can run:

sudo apt-get --purge remove linux-image-2.6.32-21; sudo apt-get --purge
autoremove

You will then gain 120Mb space as well as the removal of the entry in
grub.

--
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.edge.launchpad.net/ubuntu/+question/110085/+confirm?answer_id=4

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.edge.launchpad.net/ubuntu/+question/110085

You received this question notification because you are a direct
subscriber of the question.

=

Revision history for this message
Angela C. Murphy (murphyac5) said :
#7

I replied that I will follow those instructions after the next kernel update, since the GRUB2 information page and forum posting advise keeping one working kernel behind the current one. I will keep following those instructions after each subsequent kernel update.
Many thanks to actionparsnip.
Angela C. Murphy

Revision history for this message
Angela C. Murphy (murphyac5) said :
#8

Thanks also to Vu Do Quynh for suggesting the use of Synaptic. This gives me an insight on how to get rid of my old Xandros 3 kernels. I really don't want to boot into Xandros 3 any more, since it uses LILO as boot manager and messes up the entire boot by going back to it when you log out. All I want is Xandros 4.5 which uses 2.6.24 and GRUB.
Thanks to leoquant for the warning to leave two kernels in Ubuntu.

Revision history for this message
Angela C. Murphy (murphyac5) said :
#9

I am posting this because I found an answer to my old Xandros 3 kernels appearing in GRUB2 and it might help someone else. I booted into Xandros 4.5 and logged in as root. I tried Synaptic, but it didn't even see the Xandros 3 kernels. In desperation, I went to /xandrosdisks, where Xandros 3 now resides. I created a new folder called "old". I then moved all the files from /xandrosdisks/boot to /xandrosdisks/old. I logged out of Xandros 4.5, restarted, and booted into Ubuntu. As root, I ran

sudo update-grub

I logged out, restarted, and voila!, only the Ubuntu kernels, Windows XP and Xandros 4.5 are listed in the GRUB2 boot menu. I can still mine Xandros 3 for files and settings, but now there is no danger of booting into it.

I hope this is helpful.
Angela C. Murphy