LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How do I edit boot menu for Grub 2? (https://www.linuxquestions.org/questions/linux-software-2/how-do-i-edit-boot-menu-for-grub-2-a-866665/)

JosephS 03-05-2011 05:21 PM

How do I edit boot menu for Grub 2?
 
I just installed Debian squeeze. I installed grub to the MBR. It uses Grub 2. Apparently I'm not supposed to edit /boot/grub/grub.cnf, but /etc/default/grub and /etc/grub.d.
I looked at these and read The Readme as well as a tutorial at http://www.dedoimedo.com/computers/grub-2.html
I'm still not sure of what to do. When I boot up I get 4 choices: 2 for Squeeze and two for another linux distro. I would like to edit the print out I get when I boot up, as well as add the partition for XP which wasn't included.

This is /etc/default/grub:
Quote:

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

GRUB_DEFAULT=2
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# 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 entries
#GRUB_DISABLE_LINUX_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

This is /etc/grub.d
Quote:

00_header
05_debian_theme
10_linux
20_linux_xen
30_os-prober
40_custom
41_custom
README

bigrigdriver 03-06-2011 06:11 AM

WinXP should have been detected and added to the grub2 menu. There is a script in /etc/grub.d (30_os-prober) whose job it is to detect installed OSs and add them to the menu. Since that didn't happen, you have to add the menu entry manually.

To add an entry for xp to the grub2 menu, edit file /etc/grub.d/40_custom to add the entry. Here's how:
Quote:

This assumes that your Windows partition is sda3.
# (2) Windows XP
menuentry "Windows XP" {
set root=(hd0,3)
chainloader (hd0,3)+1
}

If the windows bootloader is on an entirely different harddrive than grub, it may be neccessary to trick windows into believing that it is in fact the first harddrive. This was possible in the old grub with map and is now done with drivemap. Assume grub is on hd0 and windows on hd2, you need to add the following after set root
drivemap -s hd0 hd2
which I found in the ArchWIKI.

I haven't found clear-cut instructions in the grub2 manual on how to remove a menu entry. After a few minutes of searching via www.google.com/linux, I found a method to do it.

Disable /etc/grub.d/30_os-prober my making it non-executable: sudo chmod -x /etc/grub.d/30_os-prober. If you run grub_mkconfig at this point, you will have NO MENU ENTRIES. So, it's necessary to add the menu entries you do want to see to the /etc/grub.d/40_custom file BEFORE you run grub_mkconfig. Just copy the menu entries you want from /boot/grub/grub.cfg and paste them into /etc/grub.d/40_custom in the order you want to see them when you boot your machine.

JosephS 03-06-2011 09:54 AM

Thanks for the help. I ran grub-update and it detected the XP partition.

If I want to edit the menu entries that print out at boot from the bios:
eg. Debian... (on /dev/sda2) to Lenny or Debian...(on /dev/sda6) to Squeeze I need to make my own custom scripts and then disable the other scripts; I can't edit the titles otherwise. Am I understanding this correct?

Thanks

bigrigdriver 03-06-2011 12:41 PM

Quote:

If I want to edit the menu entries that print out at boot from the bios:
eg. Debian... (on /dev/sda2) to Lenny or Debian...(on /dev/sda6) to Squeeze I need to make my own custom scripts and then disable the other scripts; I can't edit the titles otherwise. Am I understanding this correct?
The menu entries are not in the BIOS. The are in the bootloader configuration. And, you don't need to disable all the other scripts in /etc/grub.d. You only disable one script: /etc/grub.d/30_os-prober.

Please re-read the last paragraph I wrote. You need to disable the file that generates menu entries, and make entries in the 40_custom file. You do not have to write a script. Here is the comment from the 40_custom file.
Quote:

# 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
As you can see from the comment, you only need to add the menu entries; you don't need to write a script.

At any time in the future, you can enable 30_os-prober and delete the entries in 40_custom to return the menu to it's normal state by running grub-mkconfig.


All times are GMT -5. The time now is 05:06 PM.