LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-05-2011, 05:21 PM   #1
JosephS
Member
 
Registered: Jun 2007
Distribution: Debian Jessie, Bunsenlabs
Posts: 586

Rep: Reputation: 38
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

Last edited by JosephS; 03-05-2011 at 05:42 PM.
 
Old 03-06-2011, 06:11 AM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
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.
 
1 members found this post helpful.
Old 03-06-2011, 09:54 AM   #3
JosephS
Member
 
Registered: Jun 2007
Distribution: Debian Jessie, Bunsenlabs
Posts: 586

Original Poster
Rep: Reputation: 38
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

Last edited by JosephS; 03-06-2011 at 10:01 AM.
 
Old 03-06-2011, 12:41 PM   #4
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
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.

Last edited by bigrigdriver; 03-06-2011 at 12:45 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How come I can't edit /boot/grub/grub.conf or /boot/grub/menu.lst in Fedora 14? trien27 Fedora 4 01-22-2011 04:02 PM
Edit GRUB menu shown at boot? allele Linux - Newbie 3 06-24-2009 04:21 PM
Right way to edit /boot/grub/menu.lst ? eeried Linux - Software 2 02-07-2007 08:59 AM
How to edit /boot/grub/menu.lst of the host satimis Linux From Scratch 1 09-25-2005 07:21 AM
anyone know how to edit the /boot/grub/menu.lst? plzz help earth.hero Linux - Newbie 17 03-26-2005 10:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration