PDA

View Full Version : [ubuntu] How to edit GRUB Menu ?



syeef
December 8th, 2009, 08:49 PM
Hello EveryOne...

I am using ubuntu 9.10 and Windows XP in dual booting in one HDD. After fresh install of ubuntu my GRUB Menu was like below-



Ubuntu, Linux 2.6.31-14-generic
Ubuntu, Linux 2.6.31-14-generic (recovery mode)
Memorytest (memtest86+)
Memorytest (memtest86+, (serial console 115200)
Windows Vista (loader) (on /dev/sda1)


I choose the first option for using ubuntu and the last one for Windows XP.
After somedays of use and update ubuntu. My GRUB Menu was like below-


Ubuntu, Linux 2.6.31-15-generic
Ubuntu, Linux 2.6.31-15-generic (recovery mode)
Ubuntu, Linux 2.6.31-14-generic
Ubuntu, Linux 2.6.31-14-generic (recovery mode)
Memorytest (memtest86+)
Memorytest (memtest86+, (serial console 115200)
Windows Vista (loader) (on /dev/sda1)

First two option was added. again i choose the first option for using ubuntu and the last one for Windows XP. Again after somedays of use and update ubuntu. My GRUB Menu was like below-


Ubuntu, Linux 2.6.31-16-generic
Ubuntu, Linux 2.6.31-16-generic (recovery mode)
Ubuntu, Linux 2.6.31-15-generic
Ubuntu, Linux 2.6.31-15-generic (recovery mode)
Ubuntu, Linux 2.6.31-14-generic
Ubuntu, Linux 2.6.31-14-generic (recovery mode)
Memorytest (memtest86+)
Memorytest (memtest86+, (serial console 115200)
Windows Vista (loader) (on /dev/sda1)

Again first two option is added. :evil:

My question is any way to edit the GRUB Menu ? and can i make a munu like below-


Ubuntu, Linux 2.6.31-16-generic
Windows Vista (loader) (on /dev/sda1)

If it is possible.. Please help me, how to do that. Otherwise my 15" monitor become full with boot options. :cry:

argosreality
December 8th, 2009, 08:56 PM
You can edit your grub boot menu by running
sudo gedit /etc/default/grubfrom the terminal. After any edits you'll need to run
sudo update-grub but I'd really recommend reading the documentation first https://help.ubuntu.com/community/Grub2

The extra entries dont hurt anything (and its good to have atleast one older kernel listed so if the new one isnt so stable you can roll back to the old one) other than just more information to arrow through

rrcs
December 8th, 2009, 09:24 PM
I don't know how to edit the newfangled GRUB to get rid of old kernels, but you can always uninstall them via Synaptic (search for linux-image - make sure you don't uninstall the newest one. And some say to always keep an extra old one at hand in case something goes wrong with the newest one) - GRUB will then update itself.

holikz
December 8th, 2009, 10:25 PM
You can edit your grub boot menu by running
sudo gedit /etc/default/grubfrom the terminal. After any edits you'll need to run
sudo update-grub but I'd really recommend reading the documentation first https://help.ubuntu.com/community/Grub2

The extra entries dont hurt anything (and its good to have atleast one older kernel listed so if the new one isnt so stable you can roll back to the old one) other than just more information to arrow through

Can I use the same way to have Windows Vista to start first, then Ubuntu as second? I did notice a box pops up; is that were you edit the GRUB?

syeef
December 8th, 2009, 10:29 PM
@ argosreality:
Thanks You for the link and suggestion.

lostongps
December 8th, 2009, 10:49 PM
Great thread and thanks for the info, I was worried that my install had gotten mangled with all the new bits appearing in the boot menu after the updates.

argosreality
December 9th, 2009, 07:31 PM
Great thread and thanks for the info, I was worried that my install had gotten mangled with all the new bits appearing in the boot menu after the updates.New entries wouldn't bork anything. However, some SATA controllers have an annoying habit of reordering the hard drives (like mine) which can make for some very...fun boot experiences! :)

zaipai
December 10th, 2009, 04:37 PM
Seems to me (correct me if I am wrong) in Grub 2 you need to edit /boot/grub/grub.cfg that is where the menu options are set for OS's below is a copy of mine.. I really wish the folks at Ubuntu could find a way to allow updates to the Kernel yet not just keep adding to the menu list in grub, I have no problem editing it (for example making Windows default boot item or removing past kernel options) but my less geeky friends don't and it gets quite long with each kernel update.

Any way.. Here is grub.cfg and then grub from /etc/default/grub


#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s /boot/grub/grubenv ]; then
have_grubenv=true
load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
saved_entry=${prev_saved_entry}
save_env saved_entry
prev_saved_entry=
save_env prev_saved_entry
fi
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set e8aa1796-a7c6-4b1f-b8c8-b823a33209a0
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
if terminal_output gfxterm ; then true ; else
# For backward compatibility with versions of terminal.mod that don't
# understand terminal_output
terminal gfxterm
fi
fi
if [ ${recordfail} = 1 ]; then
set timeout=-1
else
set timeout=10
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set e8aa1796-a7c6-4b1f-b8c8-b823a33209a0
insmod tga
if background_image ; then
set color_normal=black/black
set color_highlight=magenta/black
else
set menu_color_normal=white/black
set menu_color_highlight=black/white
fi
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows 7 (loader) (on /dev/sda1)" {
insmod ntfs
set root=(hd0,1)
search --no-floppy --fs-uuid --set 7e5ac9cc5ac9817f
chainloader +1
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/10_linux ###
menuentry "Ubuntu, Linux 2.6.31-16-generic" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
set quiet=1
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set e8aa1796-a7c6-4b1f-b8c8-b823a33209a0
linux /boot/vmlinuz-2.6.31-16-generic root=UUID=e8aa1796-a7c6-4b1f-b8c8-b823a33209a0 ro Ipv6.disable=1 quiet splash
initrd /boot/initrd.img-2.6.31-16-generic
}
menuentry "Ubuntu, Linux 2.6.31-16-generic (recovery mode)" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
insmod ext2
set root=(hd0,5)
search --no-floppy --fs-uuid --set e8aa1796-a7c6-4b1f-b8c8-b823a33209a0
linux /boot/vmlinuz-2.6.31-16-generic root=UUID=e8aa1796-a7c6-4b1f-b8c8-b823a33209a0 ro single
initrd /boot/initrd.img-2.6.31-16-generic
}

### BEGIN /etc/grub.d/30_os-prober ###
## menuentry "Windows 7 (loader) (on /dev/sda1)" {
## insmod ntfs
## set root=(hd0,1)
## search --no-floppy --fs-uuid --set 7e5ac9cc5ac9817f
## chainloader +1
## }
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.


Here is the other one.

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="Ipv6.disable=1 quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entrys
#GRUB_DISABLE_LINUX_RECOVERY="true"

oldos2er
December 10th, 2009, 06:36 PM
"Seems to me (correct me if I am wrong) in Grub 2 you need to edit /boot/grub/grub.cfg"

That would be an exercise in futility. See https://help.ubuntu.com/community/Grub2

syeef
December 10th, 2009, 09:20 PM
i have got the link (http://ubuntuforums.org/showthread.php?t=1195275) for knowing about GRUB 2 Basics in this forum. it help me to solving my problem.
Thank you all for helping me.

joes7
December 10th, 2009, 09:25 PM
Use Star Up manager.

imwithid
December 12th, 2009, 10:15 AM
I've read the Grub2 guide and I need some clarification on the 40_custom section.

As the OP had stated, the menu system becomes somewhat cluttered. I don't mind sacrificing the option of a 'system restore' option. Two options will suffice for my dual boot system. Unless you're running a server, memory sensitive applications where data integrity is paramount, or one runs into an error repeatedly, memory tests aren't so important to run for my usage.

All I want are two options:

Boot order:

1. Windows XP x64
2. Ubuntu 10.04 (x|x={Alpha y, Beta z, RC, Null})

If I copy the following into the 40_custom file, will it achieve what I want above or will it make an additional option at boot up?



#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### BEGIN /etc/grub.d/10_linux ###
menuentry "Windows XP Professional x64 Edition (on /dev/sda1)" {
insmod ntfs
set root=(hd0,1)
search --no-floppy --fs-uuid --set ae38d19a38d161bf
drivemap -s (hd0) ${root}
chainloader +1
}
menuentry "Ubuntu, Linux 2.6.31-16-generic" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
set quiet=1
insmod ext2
set root=(hd0,2)
search --no-floppy --fs-uuid --set 3dc50cf5-d74b-49b7-8ca0-53fee9ea3825
linux /boot/vmlinuz-2.6.31-16-generic root=UUID=3dc50cf5-d74b-49b7-8ca0-53fee9ea3825 ro quiet splash
initrd /boot/initrd.img-2.6.31-16-generic
}
### END /etc/grub.d/30_os-prober ###

imwithid
December 12th, 2009, 11:00 AM
I took a chance, made the changes but to no effect. I almost had a hunch that it wouldn't as I assume that without the mention of the 40_custom file elsewhere that it would be ignored. I don't want to mess with removing lines from the grub.cfg file and then updating grub as this may cause problems when future updates take place (as well as having then to remove the files again.

It would be preferable if, upon future updates to the kernel, only the most recent kernel was made default. I've had enough for one night. I'll try again tomorrow.

e-nygma
December 24th, 2009, 09:14 PM
You can delete old kernel images through the Synaptic Package Manager. To do it just follow these steps:

System > Administration > Synaptic Package Manager , then search (don't use the quick search feature) for linux-image. Mark for "complete removal" the images you no longer want, click Apply and you're done.

Good luck and I hope this helps.

imwithid
January 3rd, 2010, 09:08 AM
You can delete old kernel images through the Synaptic Package Manager. To do it just follow these steps:

System > Administration > Synaptic Package Manager , then search (don't use the quick search feature) for linux-image. Mark for "complete removal" the images you no longer want, click Apply and you're done.

Good luck and I hope this helps.

That is what i did. Worked out well. I also got rid of the memory check using the following command:

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

I had never used it nor do I intend on using it. If I need it, I'll use it by running the live CD.

I did get some odd crashes shortly after removing the old kernels (massive .log files - >1GB - and random log outs until the next system updates - this was very annoying - especially losing unsaved documents three times!).

All is well now. Thanks.