How-To Geek

Clean Up the New Ubuntu Grub2 Boot Menu

Ubuntu adopted the new version of the Grub boot manager in version 9.10, getting rid of the old problematic menu.lst. Today we look at how to change the boot menu options in Grub2.

Grub2 is a step forward in a lot of ways, and most of the annoying menu.lst issues from the past are gone. Still, if you’re not vigilant with removing old versions of the kernel, the boot list can still end up being longer than it needs to be.


Note: You may have to hold the SHIFT button on your keyboard while booting up to get this menu to show. If only one operating system is installed on your computer, it may load it automatically without displaying this menu.

Remove Old Kernel Entries

The most common clean up task for the boot menu is to remove old kernel versions lying around on your machine.

In our case we want to remove the 2.6.32-21-generic boot menu entries. In the past, this meant opening up /boot/grub/menu.lst…but with Grub2, if we remove the kernel package from our computer, Grub automatically removes those options.

To remove old kernel versions, open up Synaptic Package Manager, found in the System > Administration menu.

When it opens up, type the kernel version that you want to remove in the Quick search text field. The first few numbers should suffice.


For each of the entries associated with the old kernel (e.g. linux-headers-2.6.32-21 and linux-image-2.6.32-21-generic), right-click and choose Mark for Complete Removal.


Click the Apply button in the toolbar and then Apply in the summary window that pops up. Close Synaptic Package Manager.

The next time you boot up your computer, the Grub menu will not contain the entries associated with the removed kernel version.


Remove Any Option by Editing /etc/grub.d

If you need more fine-grained control, or want to remove entries that are not kernel versions, you must change the files located in /etc/grub.d.


/etc/grub.d contains files that hold the menu entries that used to be contained in /boot/grub/menu.lst. If you want to add new boot menu entries, you would create a new file in this folder, making sure to mark it as executable.

If you want to remove boot menu entries, as we do, you would edit files in this folder.

If we wanted to remove all of the memtest86+ entries, we could just make the 20_memtest86+ file non-executable, with the terminal command

sudo chmod –x 20_memtest86+


Followed by the terminal command

sudo update-grub


Note that memtest86+ was not found by update-grub because it will only consider executable files.

However, instead, we’re going to remove the Serial console 115200 entry for memtest86+…

Open a terminal window Applications > Accessories > Terminal. In the terminal window, type in the command:

gksudo gedit /etc/grub.d/20_memtest86+

The menu entries are found at the bottom of this file.


Delete the menu entry for serial console 115200.

Note: Commenting out the menu entry will not work — it must be deleted. Copy it to a different file if you’re worried you might need it later.


Save and close this file. In the terminal window you opened, enter in the command

sudo update-grub

Note: If you don’t run update-grub, the boot menu options will not change!


Now, the next time you boot up, that strange entry will be gone, and you’re left with a simple and clean boot menu.



While changing Grub2’s boot menu may seem overly complicated to legacy Grub masters, for normal users, Grub2 means that you won’t have to change the boot menu that often. Fortunately, if you do have to do it, the process is still pretty easy.

For more detailed information about how to change entries in Grub2, this Ubuntu forum thread is a great resource. If you’re using an older version of Ubuntu, check out our article on how to clean up Ubuntu grub boot menu after upgrades.

Trevor is our resident Linux geek, but always keeps his eyes open for neat Windows tricks too.

  • Published 05/21/10

Comments (57)

  1. Mario

    How or can I can delete all the files in the Windows 7 search folders. I would like to clean them up but also would like to know how to keep them clean.

    Thank you in advance for any Help

  2. Trevor Bekolay


    Please ask your question on the forum so that someone who’s already done this can help you (I’m not sure, myself).

  3. rzlmlchm09

    Thanks for the tip. I’ve been a bit annoyed at how many boot options pile up after updating Ubuntu, especially with a dual boot system.

  4. Neil

    If you are using the Ubuntu server version and working from the command line what is the best way to proceed with the cleanup?

    I am playing around with it and curious, thanks.

  5. Trevor Bekolay


    For the server version, the best method would be to edit the files in /etc/grub.d with a command-line text editor (I use nano, but that’s me), making sure to run “sudo update-grub” after you’re done with your changes.

    The files in /etc/grub.d aren’t as straightforward as menu.lst was, but you should still be able to play with them and achieve the results you’re looking for. For more detailed help, check out the forum thread I linked at the end of the article.

  6. leftyfb

    I love how your window control buttons are on the right-hand side :)

  7. Trevor Bekolay


    I practice what I preach! ;)

  8. Steve

    Thanks for the clear explanation.

  9. SantAnna

    To remove old kernel entries I agree with you but the others entries no.
    Memtest86+, I never see anyone use it.
    So you can do : # chmod -x /etc/grub.d/20_memtest86+

    Recovery mode, other thing not usable.

    # gedit /etc/default/grub
    uncomment the line
    Save the file
    Do not forget the “update-grub” after the changes.


  10. Aziz Raharjo

    Or, you can delete those kernel using Ubuntu Tweak, it’s GUI, so simple… Tho you can,t do the “fine-grain control” method with that program…

  11. Paul Burns

    Well, I followed this guide and removed my old Ubuntu kernels as well as memtest on console 115200, and all went well with those changes regarding cleaning up my Grub2 menu, BUT for some reason now my Windows 7 installation is no longer listed in my Grub2 menu even though the 30_os-prober file has not been edited and remains executable, and running the “update-grub” fins my Windows partitions and operating system. Any ideas why this might be? Or should I just head over to the Ubuntu forums for help?

  12. Indian-Art

    Thanks, for this useful article.

    This will help me clear the clutter.

  13. A.H.

    I like having fewer GRUB entries. This helped me find the file I wasn’t seeing to remove the 2.6.32-21 entry. However, when I moved on in the tutorial and #’d out the serial console 115200 entry, it made all the entries after it not appear, though update-grub seemed to see them.

    Before I had
    2.6.32-22 recovery
    memtest serial console 115200
    Windows Vista (loader) // I have Windows 7 now, no idea what this is, and I’m afraid to select it
    Windows 7 (loader)

    But after I only had the first 3 entries, like it stopped looking or something.

  14. Kev

    I tried the above in 10.04 got entries for old kernels showing up at boot [grub] but they are not installed in Synaptic. The only way I could clean up grub was by removing config, initrd etc from /boot then running sudo grub-mkconfig to rebuild menu. Not the best way to go about it I am sure.

  15. GhostLyrics

    what about sudo apt-get autoremove on ubuntu? I think that should also remove older kernels.

  16. Kev

    Sorry I meant update-grub my bad!

  17. bud

    try this:
    sudo nano /boot/grub/grub.cfg
    yeah, ignore: dont edit this file, remark or del the lines that you don’t want, that’s if you are sure that the new kernel is doing fine.

  18. Kinchu

    Can do it automatically using Ubuntu Tweak.
    Applications > Package Cleaner … (Button) Clean Kernels.

  19. Trevor Bekolay

    @ Paul Burns & A.H.

    Rather than commenting out the lines in 20_memtest86+, try deleting them and see if that resolves the problem. If no, can you take a look at /boot/grub/grub.cfg and tell me if the following lines exist:
    ### BEGIN /etc/grub.d/30_os-prober ###

    ### END /etc/grub.d/30_os-prober ###

    with some stuff inside?

    @ bud

    The message not to edit that file should really be followed: mainly because any edits that you make to this file will be forgotten the next time ‘update-grub’ is called, which happens any time the kernel is updated, and in a few other situations. Everything that’s in /boot/grub/grub.cfg can be changed through editing /etc/default/grub or the files in /etc/grub.d, and those changes will stick around when ‘update-grub’ is called.

  20. Pete

    Finally!!! I’ve been waiting for something like this for months, too bad Ubuntu people couldn’t make something like this as soon as Ubuntu 9.10 came out, it was a very frustatring time for me seaching for a fix, they just changed the way to do this and didn´t told us how to remove those useless entries.


  21. edouardp

    Like other commenters, doing this deleted my Windows 7 entry as well …

  22. dagwood

    deleted my Win7 entries as well. makes a dual boot useless if the other OS is out of reach. Please change this blog to avoid this trap. I came here from Lifehacker (like many others, I am sure) and now I have to either figure this out myself of reinstall Ubuntu to correct the problem.

  23. dagwood

    found it.

    remove the # marks on 20_memtest86+ to bring back Win7 entries.

    Not worth the trouble. Grub is the my biggest gripe about Ubuntu 10.04. Grub2 added no features and took away options. bad job Ubuntu. Either fix it or go back to grub 1. How about a beautiful and managed app that gives you control options on the boot screen. That would be nice.

  24. Trevor Bekolay

    To anyone who had the issue with commenting out the serial console entry deleting later entries: delete all of the lines that you commented out in /etc/grub.d/20_memtest86+, run sudo update-grub, and you’ll get them back.

    I’m not sure why commenting out the lines had that effect, but I’ve confirmed that deleting the lines works properly, conserving all future entries.

    I’ve updated the post to reflect this. Sorry to anyone inconvenienced with this issue!


    Removing the # marks also works, but the serial console entry will remain. Delete the lines, as mentioned above, to get the desired effect.

    I agree, there really should be a graphical front-end for editing the boot menu… I have no idea why one hasn’t been made yet. That said, I think Grub2 is a step forward in a lot of ways — just not quite all of them.

  25. Kai

    “Remove Old Kernel Entries”

    Instead of marking “completely remove”, I only “remove” them. Now the grub list is still messy but I don’t know what I can do next. I would apreciate any help.

  26. Louis

    I have an embedded solution and want to prevent this screen from coming up after a power outage. The controller must simply boot back into the main OS. Will this do it for me?

  27. Jithin

    Thanks BUddy. Your article is simple and to teh point. Helped me fix my issues with grub 2.

  28. Kenny

    I have a dual boot with XP and am using grub 1.97 beta 4 and I followed the directions – I removed linux header packages from synaptic package manager, etc., and still see all the options in my grub menu. I did update-grub too and it still did nothing. My menu.lst file in /boot/grub/ shows only a few options, but my actual grub menu lists tons of versions. What can I do?

  29. Lukas

    i have a similar problem to Kenny, and i think his might be for similar reasons.

    I tried the ubuntu 10.10 netbook alpha2 and it did decidedly NOT work out, so i just installed easypeasy 1.6 over it.

    Now there is a 2.6.35 leftover on top of my grub boot menu, which leads nowwhere, and the working 2.6.32 underneath. and no update-grub has helped.

    any idea where i can find that entry and how to delete it?

  30. Edwin J Welch

    I attempted to remove the generic and recovery in synaptic as you recommend but they are not installed so will not remove. They show in my grub loader on boot, how can I get them out easily. Please do not use Evolution to answer I do not use. I use Firefox exclusively. Using latest Thanks Mr. Welch

  31. 1Life

    Thanks for the tip. I needed to know this.

  32. João Henriques

    Nothing beats editing the /boot/grub/grub.cfg file by hand.

    sudo chmod +w /boot/grub/grub.cfg ; then comment the desired lines with good old emacs.

  33. DRO

    I am using Ubuntu, so sudo gedit grub.cfg works great. Scroll down and delete unnecessary kernels.

  34. Steve Cornall

    Hi there, I could not remove the old entries of my kernel using synaptic package manager because they did not exist. In the end I did the following: I realized that I no longer actually had the packages. To eliminate the listings from the grub2 menu I opened a terminal. Then typed cd /boot. Then ls to list the contents. From there I used rm to remove all related files eg. sudo rm /boot/vmlinuz-2.6.28-15-generic, sudo rm /boot/initrd.img-2.6.28-15-generic, sudo rm vmcoreinfo-2.6.31-15-generic, sudo rm, sudo rm config-2.6.28-15-generic, sudo rm abi-2.6.31-15-generic. I did this for each unwanted version. I don’t know if I had to remove all those files but since they referred to old unwanted versions I got rid of them anyways. I then typed sudo update-grub, crossed my fingers (a meaninless ritual) and did a reboot. Now all is well. I hope this answer helps someone out there…

  35. ptolemy

    ..Do you realize how many answers there are to this? Some of these solutions do not work and are entirely too complicated for what everyone is trying to do. Gee, wouldn’t it be easier to go back to Grub1? At least it worked.

  36. marossity

    I have a strange problem, following this article.
    The command “sudo chmod –x 20_memtest86+” doesn’t work.
    chmod: invalid mode: `–x’

  37. Trevor Bekolay

    @ marossity

    Did you copy / paste that line? If so, it might be the case that the minus sign isn’t actually a minus sign but some other character. Type the line in manually, -x is a valid mode for chmod.

  38. Pawel
  39. The guy

    Thanks for all that info.

    can you or anyone say how to remove a windows entry, or how to prevent grub from detecting one of windows entries. here is my situation.

    I have two hard disks, both have windows and linux version (because one was backup of the other), however, now I deleted one windows by deleting some of the files. so of course grub can detect it is installed, but in reality it is not. so now i have two entries for windows, I would like to hide one.

    also on the other hard disk, I couldn’t manage to make a grub version install and refer to the first hard. it seems as if grub installed on sda trying to find grub files on sda, while in fact all files on sdb which currently temporarily I set my computer to boot from sdb all the time. thanks

  40. Alan

    I deleted the current kernel by accident and now in the grub menu i only get the windows options (i have a dual boot win7 and lucid lynx) how can i recover it??

  41. John

    I have a dual boot laptop. Grub recognises the Acer PQSERVICE partition (sda1) as “Vista Loader” and W7 Loader on sda2. I want to remove the option of “Vista Loader” from grub since it is a restore default OS. If someone inadvertently selected that one I believe it would reformat my HD and restore the factory settings, and of course remove Ubuntu and all my data.

    I see a ‘piped’ line in grub-d 30 file for both \windows\vista | win7

    How do I fix this?

  42. neo_aryan

    what are the risks involved???

  43. Mike_tn

    I dual boot on 2 machines, one Ubuntu-W7 and one Ubuntu-XP, and both have the extra Windows entry. I’ve clicked the ones that boot into the recovery partitions and nothing happens, It’s pretty boring. I think on one machine I can Ctrl-Alt-Delete to reboot the false Windows OS entry when clicked but the other machine I have to hit the power button, which I don’t like. I’d like to remove the bogus extra Windows entry on both machines. I’ve been having a hard time trying to find out how and the Geek here doesn’t talk about it. I don’t care about the mem test, you won’t accidentally hit that. But the two windows menu entries from a dual boot GRUB install just differ by a single digit, 1 & 2 as in Windows….sda1 and Windows……sda2. THAT’S a problem.

  44. De Hong Yin

    Hi, everybody

    I met some promble need your help.
    I set up the Ubuntu-8.04-server via VMware on windows xp. I’am not be carefull shutdown the power. Then the Ubuntu cannot be start. It alert :
    SegMentation fault
    Gave up waiting for root device…….

    /dev/disk/by-uuid/b95073ef-2445-431c-944-9feb6494da37 does not exit.
    Dropping to a shell!

    Enter ‘help’ for a list of built-in COMMands.

    I’m first use linux system. Hope you can help me soon

  45. Alok Lal

    Thanks for detailed instruction. Great help!

  46. Michael Rasmussen

    I find it easier to use System->Administration->Computer Janitor.

    In the Computer Janitor window go View->Sort by Name.
    Uncheck all packages.
    Check all packages that start with linux-image-XXX and linux-headers-XXX.
    Click Do Selected Tasks.

    You may want to leave the linux-image-XXX with the highest version so you have a backup kernel you can revert to in case of problems with the current kernel.

  47. Hugues

    Just found out a way much easier…

    Check out:

    I don’t mean to offend anyone here.. just trying to help


  48. Trevor Bekolay

    @ Hugues

    Thanks for the link! This tool looks great!

  49. mariana

    i use ubuntu ,linux 10/10 ,i cannot open my pictures ,why ? what do u have to do ?? Plz help

  50. Prabhakar Tiwari IITK

    It is easy and safe to use Ubuntu Tweak.
    Applications >System Tools>Ubuntu Tweak .
    then use Package cleaner to clean Kernels

  51. Boris Angelovski

    If we wanted to remove all of the memtest86+ entries, we could just make the 20_memtest86+ file non-executable, with the terminal command:

    sudo chmod –x 20_memtest86+


    sudo chmod -x /etc/grub.d/20_memtest86+

  52. bonz

    how would one go about adding an alias so sumone can use grub on a machine with a faulty keyboard preventing me from arrowing down to other menu options.

  53. Felipe

    Hey Guys maybe you can help! So, this is the problem. I was upgrading ubuntu 10.10 into ubuntu 11.04. Right at the end of the installation my screen went blank. I waited 30 min and hard rebooted the machine. The new grub came out, I tried to load ubuntu 11.04 and it showed a blank screen. I rebooted, when to save mode, and it told me that something could not be mounted.

    I went to this link , followed all the instructions, then when I rebooted, I had another error. I retried following the instructions and now my machine would pass the BIOS into a blank screen, even when I try to load the Live CD

    The only way I could get past the Bios is if I load another live cd like gparted, or ubuntu live cd version 9 or less and I can see that my file systems are there… how could I access ubuntu.. by the way I forgot to mention that I have a windows vista partition. Any help would be really appreciated


  54. sam

    Great post. works perfectly

  55. RJBradlow

    To Clean up your Grub2 boot menu, you must also do a few other simple steps…
    Removing the kernels as outlined above is fine but you have not cleaned the kernel registry (so to speak) or TOC (if you prefer) that Grub pulls from; i.e., the listings in /boot.

    For those with a GUI mentality and to keep it simple for the CLI challenged:

    First install Gnome Commander -Or- for those using KDE install Krusader … (either or will work in either Desktop Environment – DE)

    These Apps are “two-pane” graphical file managers which aim to fulfill the demands of more advanced users who like to focus on file management, their work through special applications and running smart commands.

    One of the great features about these over the native File Managers of either DE is the ability to access root privileges with one click in the File menu; which is what we need to finish Cleaning our Grub2 menus.

    That Said, after installing the Commander of your choice, nav to the File menu and select: Start * Commander as Root.

    In either pane (makes no difference… defaults left); Double click the UP arrow in your toolbar to get to root: /.

    Now double click the ‘boot’ folder –
    – Next while holding down the ‘Ctrl’ key, start left clicking on each of the files that end with the same kernel numbers that you previously removed via the Synaptic Package Manger as outlined above.

    Once you have highlighted all the removed kernels, click the red circle-x in your toolbar to Delete those files.
    Now close your commander(s).

    Open the dreaded CLI Terminal window and Type or copy and paste this:

    sudo update-grub

    and press the Enter (or Return) key.

    That’s It, You’re Done. No More messy Grub Menu.


  56. Milos

    I installed ubuntu 11.04 over 10.10 but grub2 still shows me older version (2.6.35-22 to 24 with their recovery modes), and when I tried to clean it with synaptic package manager, I typed 2.6.35 in search menu, but nothing was found (probably when installed 2.38, it removed olders) but still have options in grub2 menu

    how can I clean it for real?

  57. Bobbie

    Thank you for this clear explanation.

    I’m amazed that the Linux community expects people to edit bash scripts, rather than providing an easy front-end (a GUI panel or an editable file like menu.lst). This is why Linux retains its reputation for not being as easy to use as Windows. Grub2 — a nice step forward for techies, and a giant step backward for actual users.

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!