Saturday, January 29, 2011

How to Clean Up Ubuntu Grub Boot Menu After Upgrades

Hi

Recently I have installed Ubuntu 9.10 - the Karmic Koala - released in October 2009 .I upgraded using update manager many times.So each time I update it is adding one menu in boot screen like recovery mode.I have windows OS also.Right now in booting time it is listing around 10 bootmenu's.Windows OS goes to last line of the menu .How to clear all the boot menu's except windows and ubuntu latest vesion.

Can anyone help me on this?

  • Go into the synaptic package manager, and scroll down until you find linux-image-*

    You can safely remove them all, except the one you booted from. (You can find that out by running 'uname -r' from the command line.

    Also running 'sudo apt-get autoremove --purge' from the command line may detect the 'old' ones and automatically remove them.

    BlackPanther : Thanks .Worked well.And also I am seeing one more boot menu like "Memory Test".Is it possible to remove that also?
    Aaron C. de Bruyn : That gets a bit more tricky, but all the info should be in the file /boot/grub/menu.lst. *Be Careful* with that file though. If you edit it incorrectly, you may not be able to boot anymore... ;)
  • If you're feeling especially adventurous, you could edit the source of the Grub bootmenu at

    /boot/grub/grub.cfg
    

    and delete the menu entries you don't need.

    You will have to deliberately ignore the message at the top of the file which says

    # DO NOT EDIT THIS FILE
    

    You'll need to be root, and the the danger of making the system unbootable is high.

    Make a copy of the file, eg grub.cfg0,

    Study grub.cfg carefully, and make sure you understand what you're deleting before you do it. If you're NOT confident, don't do it.

    The section relating to Memory Test is as follows in my Ubuntu 9.10

    ### BEGIN /etc/grub.d/20_memtest86+ ###
    menuentry "Memory test (memtest86+)" {
            linux16 /boot/memtest86+.bin
    }
    menuentry "Memory test (memtest86+, serial console 115200)" {
            linux16 /boot/memtest86+.bin console=ttyS0,115200n8
    }
    ### END /etc/grub.d/20_memtest86+ ###
    
    alfplayer : Not a good idea because /boot/grub/grub.cfg is overwritten anytime there is a update, a kernel is added/removed or the user runs update-grub.
    From pavium
  • When update-grub is run, whether by you or by a kernel package installation, it generates /boot/grub/grub.cfg by running, in order, the executable scripts in /etc/grub.d. If you want to change your boot menu order, just change the order of the scripts in /etc/grub.d.


    If you want your Windows boot entry first, run this to have that boot entry generated before the Linux kernel entries are generated (in the 10_linux script):

    sudo mv /etc/grub.d/30_os-prober /etc/grub.d/09_os-prober
    

    Once you're done, run sudo update-grub to generate a new /boot/grub/grub.cfg.


    The Memtest86 boot entries are created by the /etc/grub.d scripts 20_memtest86 and 21_memtest86+. If you don't want the Memtest86 boot menu entries, the easiest and most permanent way to get rid of them (short of uninstalling the memtest86 and memtest86+ packages) is to run these commands:

    # unset executable bit for grub menu configuration script
    sudo chmod -x /etc/grub.d/*memtest86*
    

    The chmod disables the Memtest86 boot entries, and running sudo update-grub will now create a /boot/grub/grub.cfg that doesn't include the Memtest86/+ entries.

    To undo that change, simply add the executable bit back to the script, and re-run update-grub.

    # reset 
    sudo chmod +x /etc/grub.d/*memtest86*
    

0 comments:

Post a Comment