The Grub 2 Guide

Post your How to's here


The Grub 2 Guide

Postby Admin-Amir » Mon May 10, 2010 2:29 pm

The Grub 2 Guide
(formerly Grub 2 Basics)



Important Note to Wubi (Windows Ubuntu) Users:
Grub2 updates in the spring of 2010 triggered a bug in the ntfs module causing Wubi boot failures. The solution to this boot problem was posted by Agostino Russo and is found in this Lucid Lynx LaunchPad Bug Report #477169, Post 210. The module causing the errors has been fixed and replacing the "wubildr" file in Windows permanently solves this problem. See the bug report for details.

Note: Most of this information has been incorporated, with a few graphics, into a page in the Ubuntu Help site. I will try to keep this post up-to-date and users are free to continue to post comments here. The help page is located here: https://help.ubuntu.com/community/Grub2


1. Introduction
2. First Look Differences
3. Improvements
4. Booting Grub
5. Grub 2 Files & Options
6. Adding Entries to Grub 2
7. Removing Entries from Grub 2
8. Grub 2 Splash Images & Theming
9. Changing Menu Resolution
10. Password Protection
11. Booting to Recovery Mode w/o Menu Option
12. Uninstalling GRUB 2 > GRUB
13. Reinstalling GRUB 2 from the LiveCD
14. Booting to LiveCD ISO
15. Booting from the Rescue Mode
16. Restoring GRUB2 / XP / Vista / Win 7 Bootloaders
17. Selected Problems & Bugs
18. Links

1. Introduction
I've written this guide to present some basic information about Grub 2. It is meant for users who may be familiar with basic editing of the original Grub (Grub Legacy) menu.lst and wonder how it carries over to Grub 2. The actual version of Grub 2 used in Ubuntu 9.10, Karmic Koala is 1.97~beta4; 1.98 is the Ubuntu 10.04, Lucid Lynx version. In keeping with Ubuntu's "stable release" philosophy, 1.97~beta4 will remain the official version in 9.10/Karmic and will not be updated to 1.98. In this guide, any reference to Grub 2 will refer to the 10.04 Lucid Lynx 1.98 version, with major differences noted.

Grub 2 will be the default in Ubuntu 9.10, Karmic Koala but the plan is not to convert over previous Grub legacy installations to Grub 2.


StartUp-Manager supports Grub 2, but not all options are available. The two most-used items, however, are: setting the default kernel/OS and setting the menu timeout delay. There are plans for a StartUp-Manager 2 that works only for Grub 2 but it is still under development according to its creator. To view a guide on installing and running StartUpManager, view the StartUpManager community doc or the forum post on which it was based: http://ubuntuforums.org/showthread.php?t=818177

Official documentation at this point is still being created, which is partly the reason for this post. More comprehensive and complete documentation will hopefully be forthcoming from the developers and volunteers. Of the existing documentation, I have have provided several links to the better sources at the end of this post.

For troubleshooting and modifying the Grub menu, it is important to know which version you are using (Grub legacy, 0.97; Grub 2 in Karmic 1.97~beta4; Grub 2 in Lucid 1.9. To confirm the version of Grub used in your system, run this command:

Code: Select all
grub-install -v


Which should produce something like this:

drs305@mycomputer:~$ grub-install -v
grub-install (GNU GRUB 1.97~beta4)


# First Look Differences: GRUB vs GRUB 2
At first boot, there will not be much difference in what the user sees on the boot menu. The one exception is a clean install of Ubuntu 9.10 with no other installed operating system. In this case, GRUB 2 will boot directly to the login prompt or Desktop without displaying a menu. Other major differences:

* No ''/boot/grub/menu.lst''. It has been replaced by ''/boot/grub/grub.cfg''.
* Hold down SHIFT to display the hidden menu during boot (formerly ESC is GRUB legacy).
* There is no "find /boot/grub/stage1" at the grub prompt. Stage 1.5 has also been eliminated.
* The main menu file, ''/boot/grub/grub.cfg'' is not meant to be edited, even by 'root'.
* ''grub.cfg'' is overwritten anytime there is a update, a kernel is added/removed or the user runs `update-grub` *
* The user can use a custom file, ''/etc/grub.d/40_custom'', in which the user can place his own entries. This file will not be overwritten.
* The primary configuration file for changing menu display settings is ''/etc/default/grub''.
* There are multiple files for configuring the the menu - ''/etc/default/grub'' mentioned above, and all the scripts in /etc/grub.d/ folder.
* Other operating systems, such as Windows, should automatically be recognized and added to the menu.
* No changes made in the configuration files will take effect until the `update-grub` command is also run.



* To update the GRUB 2 menu, the command sudo update-grub will be used throughout this guide. update-grub actually runs the command "grub-mkconfig -o /boot/grub/grub.cfg" This runs several scripts and incorporates the results into /boot/grub/grub.cfg which detemines what is seen on the screen during boot. Since the GRUB 2 developers do not intend to remove the update-grub 'stub', it will be used for simplicity and ease of use.

# Improvements
GRUB 2's major improvements over the original GRUB include:

* New configuration file structure
* Scripting support including conditional statements and functions
* Dynamic module loading
* Rescue mode
* Themes - under development
* Graphical boot menu support and improved splash capability
* Boot Ubuntu LiveCD and some other ISO images directly from hard drive
* Non-X86 platform support (such as PowerPC)
* Universal support for UUIDs (not just Ubuntu)
* Improved internationalization, including support for non-ASCII characters


# Booting Grub
Grub 2 loads before the operating system. It's modular components are loaded on an as-needed basis. Menu display behavior is generally determined by settings in /etc/default/grub. Review the "Grub 2 Files & Options" section for specific entry and formatting guidance.

The main options for displaying the menu are:

* Initial Default
o Grub 2 will boot straight into the default operating system if no other operating system is detected. No menu will be displayed. If another operating system is detected, the Grub 2 menu will display.
* Timed display.
o The default delay is 10 seconds. If no user input is made Grub 2 boots to the default entry.
o The countdown can be stopped by pressing any key. The user must then make a selection manually.
o The booted entry is determined by the DEFAULT= setting in /etc/default/grub, The first "menuentry" is 0.
* Hidden
o The user can interrupt the boot process and display the menu by holding down the SHIFT key until the menu displays. Grub 2 searches for a depressed SHIFT key signal during boot. If the key is pressed or Grub 2 cannot determine the status of the key, the menu is displayed. Note: The "SHIFT" keystatus check is currently in a conditional statement within /etc/grub.d/30_os-prober and may not work under certain circumstances.
o The time the screen remains blank but available for display is determined by a setting in /etc/default/grub.
o To provide visual feedback during while the countdown continues, a countdown display can be shown on the screen.
o At the end of the timeout, the default entry determined in /etc/default/grub will be selected.
* Saved
o If the default option is set to "saved", the last kernel/system successfully booted will be selected and run if no input is made.
o Unlike GRUB, GRUB 2 stores the "saved" entry as a string, not as a menu position number. In GRUB 2, the result is applied more consistently. Example: If the first entry (kernel -15) becomes the second entry due to a kernel update, it will still be the "saved" entry even though it's position on the menu has changed.


# Grub 2 Files & Options
Many of the files in /boot/grub will not be recognizable by users of Grub Legacy. Especially noticeable are the multitude of *.mod files. Grub 2 is modular and these files are loaded as necessary by the grub bootloader.

The Grub 2 user-configurable settings are contained mainly in /etc/default/grub and the files in /etc/grub.d. When update-grub is executed the results are input into the /boot/grub/grub.cfg file.

* /boot/grub/grub.cfg
o This is the main Grub 2 file. It "replaces" Grub Legacy's /boot/grub/menu.lst This file contains the Grub menu information but unlike Grub Legacy's menu.lst file, grub.cfg is not meant to be edited.
+ grub.cfg is automatcially generated when "update-grub" is executed:
+ Each section (### BEGIN) is clearly delineated and references the file in the /etc/grub.d folder from which the information was generated.
+ grub.cfg is updated by running the "update-grub" or "update-grub" command as root.
+ By default, and whenever the "update-grub" command is executed, this file is made "read-only". This is in keeping with the intent that the file should not be edited manually. If you must edit this file, instructions are provided in Section 2.
o Sample grub.cfg including Windows and one manual entry (41_srcd):

Code: Select all
#
# 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 $prefix/grubenv ]; then
  load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
  set saved_entry=${prev_saved_entry}
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z ${boot_once} ]; then
    saved_entry=${chosen}
    save_env saved_entry
  fi
}

function recordfail {
  set recordfail=1
  if [ -n ${have_grubenv} ]; then if [ -z ${boot_once} ]; then save_env recordfail; fi; fi
}
insmod ext2
set root='(hd0,1)'
search --no-floppy --fs-uuid --set 444539ba-ab9e-4028-94f5-c1a86b5ec7c1
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
insmod ext2
set root='(hd0,1)'
search --no-floppy --fs-uuid --set 444539ba-ab9e-4028-94f5-c1a86b5ec7c1
set locale_dir=($root)/boot/grub/locale
set lang=en
insmod gettext
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 ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Ubuntu, with Linux 2.6.32-16-generic' --class ubuntu --class gnu-linux --class gnu --class os {
   recordfail
   insmod ext2
   set root='(hd0,1)'
   search --no-floppy --fs-uuid --set 444539ba-ab9e-4028-94f5-c1a86b5ec7c1
   linux   /boot/vmlinuz-2.6.32-16-generic root=UUID=444539ba-ab9e-4028-94f5-c1a86b5ec7c1 ro   quiet splash
   initrd   /boot/initrd.img-2.6.32-16-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-16-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
   recordfail
   insmod ext2
   set root='(hd0,1)'
   search --no-floppy --fs-uuid --set 444539ba-ab9e-4028-94f5-c1a86b5ec7c1
   echo   'Loading Linux 2.6.32-16-generic ...'
   linux   /boot/vmlinuz-2.6.32-16-generic root=UUID=444539ba-ab9e-4028-94f5-c1a86b5ec7c1 ro single
   echo   'Loading initial ramdisk ...'
   initrd   /boot/initrd.img-2.6.32-16-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-14-generic' --class ubuntu --class gnu-linux --class gnu --class os {
   recordfail
   insmod ext2
   set root='(hd0,1)'
   search --no-floppy --fs-uuid --set 444539ba-ab9e-4028-94f5-c1a86b5ec7c1
   linux   /boot/vmlinuz-2.6.32-14-generic root=UUID=444539ba-ab9e-4028-94f5-c1a86b5ec7c1 ro   quiet splash
   initrd   /boot/initrd.img-2.6.32-14-generic
}
menuentry 'Ubuntu, with Linux 2.6.32-14-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
   recordfail
   insmod ext2
   set root='(hd0,1)'
   search --no-floppy --fs-uuid --set 444539ba-ab9e-4028-94f5-c1a86b5ec7c1
   echo   'Loading Linux 2.6.32-14-generic ...'
   linux   /boot/vmlinuz-2.6.32-14-generic root=UUID=444539ba-ab9e-4028-94f5-c1a86b5ec7c1 ro single
   echo   'Loading initial ramdisk ...'
   initrd   /boot/initrd.img-2.6.32-14-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
   insmod ext2
   set root='(hd0,1)'
   search --no-floppy --fs-uuid --set 444539ba-ab9e-4028-94f5-c1a86b5ec7c1
   linux16   /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
   insmod ext2
   set root='(hd0,1)'
   search --no-floppy --fs-uuid --set 444539ba-ab9e-4028-94f5-c1a86b5ec7c1
   linux16   /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Microsoft Windows XP Home Edition (on /dev/sda1)" {
    set root=(hd0,1)
    chainloader +1
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
menuentry "Jaunty 2.6.28-15-custom" {
    saved_entry=${chosen}
    save_env saved_entry
    set root=(hd0,8)
    linux    /boot/vmlinuz-2.6.28-15-custom root=UUID=48e03255-22b3-488b-ae7e-9dbe4e2beac7 ro  quiet splash
    initrd    /boot/initrd.img-2.6.28-15-custom
}
menuentry "SystemRescue" {
    saved_entry=${chosen}
    save_env saved_entry
        set root=(hd0,6)
        linux   /sysrcd/rescuecd subdir=sysrcd setkmap=us
        initrd  /sysrcd/initram.igz
}
### END /etc/grub.d/40_custom ###


/etc/default/grub

* This file contains information formerly contained in the upper section of Grub Legacy's menu.lst and items contained on the end of the kernel line. The items in this file can be edited by a user with administrator (root) privileges.
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.

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

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


# GRUB_DEFAULT - Sets the default menu entry. Entries may be numeric or "saved"

* GRUB_DEFAULT=0 - Sets the default menu entry by menu position. As Grub Legacy, the first "menuentry" in grub.cfg is 0, the second is 1, etc.
* GRUB_DEFAULT=saved - (Grub 1.98) Enables the "grub-reboot" and "grub-set-default" commands.
o This setting allows the use of the following commands to set a default OS. The default OS will not be set merely by an interactive selection of an OS from the menu.
o grub-set-default. Sets the default boot entry until changed.
+ The format is "sudo grub-set-default X, with X being the menuentry position (starting with 0 as the first entry) or the exact menu string. Examples: sudo grub-set-default 3 or sudo grub-set-default "Ubuntu, Linux 2.6.32-15-generic"
+ To obtain the existing menuentry choice number (starting from 0) or the menuentry "string", run "grep menuentry /boot/grub/grub.cfg"
o grub-reboot. This command sets the default boot entry for the next boot only. The format of the command is the same as for "grub-set-default" (see above).
o For an example of how to enable the "saved" option with a custom menu, see the "Custom User Entries" section.
* GRUB_DEFAULT="xxxx" - An exact menu entry, including the quotation symbols, may also be used. In this case, location in the menu will not matter. Example: GRUB_DEFAULT="Ubuntu, Linux 2.6.31-9-generic"

# GRUB_SAVEDEFAULT= - If set to true this setting will automatically set the last selected OS from the menu as the default OS on the next boot. No commands need be run to set the default OS.
# GRUB_TIMEOUT=5 - No change from Grub Legacy. This is the number of seconds before the default entry is automatically booted.

* Setting this value to -1 will cause the menu to display until the user makes a selection.
* To display the menu on each boot use a value of 1 or higher.
* This command defers to the GRUB_HIDDEN_TIMEOUT command. If the GRUB_HIDDEN_TIMEOUT option is interrupted by pressing the SHIFT key, the GRUB_TIMEOUT counter begins its countdown.
* Caution: Holding down the "SHIFT" key will not display the menu if "GRUB_TIMEOUT=" is set to "0" . To always have this interrupt capability, the keystatus check in /etc/grub.d/30_os-prober can be copied to /etc/grub.d/40_custom or to another script in the same folder. The keystatus check introduces a short timeout interruptible by the ESC key if the key status cannot be determined.
* In addition to editing the file as root, you can also run the following commands the check and change the default timeout value. The first checks the existing timeout, the second replaces the value. Replace T with the new value.

Code: Select all
cat /etc/default/grub | grep 'GRUB_TIMEOUT='   # Checks current TIMEOUT value.
sudo sed 's/GRUB_TIMEOUT=5/GRUB_TIMEOUT=T/g' -i /etc/default/grub  # Change TIMEOUT value. Replace T with new value.


#

* GRUB_HIDDEN_TIMEOUT=0
o The hidden timeout option allows a screen to be displayed without the Grub 2 menu, awaiting input from the user for a given number of seconds. It is available to single-OS computers - if multiple OS's are known to Grub 2, this option is bypassed.
On single-OS computers:
+ The menu will be hidden unless the user adds a # symbol to the beginning of this line ( # GRUB_HIDDEN_TIMEOUT=0 ) and the GRUB_TIMEOUT value is greater than 0.
+ If a background image is designated in 05_debian_theme it will be displayed rather than a blank screen during a hidden menu timeout.
+ For integers greater than 0:
# The system will pause without displaying a menu for the designated number of seconds. If the user does not press the SHIFT key during the timeout the system will then boot the default OS/kernel.
# If the user presses the SHIFT key to display the menu, the menu will be displayed for the number of seconds designated by the GRUB_TIMEOUT value unless the user again intervenes.
+ With a value of 0:
# Unless the user intervenes, the system will boot the default OS/kernel with only a slight delay. No menu will be displayed.
# The user may force displaying the menu as the computer boots by holding down the SHIFT key.

On computers on which Grub 2 recognizes multiple OS's:
+ This entry is ignored.
+ The menu will be displayed for the value designated in GRUB_TIMEOUT.
+ The hidden menu timeout option is not available, as it is bypassed by a conditional in /etc/grub.d/30_os-prober.
+ The system can still boot without displaying a menu by setting the GRUB_TIMEOUT value to 0, however a timeout delay with a blank screen is not available.
+ The keystatus check for SHIFT key usage is bypassed by the scripts. Holding down the SHIFT key during boot will not display the menu.
+ If the user of a multi-OS computer wishes to hide the menu while incorporating a blank screen timeout the scripts in /etc/grub.d/30_os-prober can be modified. Please refer to Grub 2 Title Tweaks.
* GRUB_HIDDEN_TIMEOUT_QUIET=true
o true - No countdown is displayed. The screen will be blank.
o false - A counter will display on a blank screen for the duration of the GRUB_HIDDEN_TIMEOUT value.
* GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
o Determines the descriptive name in the menu entry. (Ubuntu, Xubuntu, Debian, etc.)
* GRUB_CMDLINE_LINUX
If it exists, this line imports any entries to the end of the 'linux' command line (Grub Legacy's "kernel" line) for both normal and recovery modes. This is similar to the "altoptions" line in menu.lst
* GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
This line imports any entries to the end of the 'linux' line (Grub Legacy's "kernel" line). The entries are appended to the end of the normal mode only. This is similar to the "defoptions" line in menu.lst. For a black screen with boot processes displayed in text, remove "quiet splash". To see the grub splash image plus a condensed text output, use "splash". This line is where other instructions, such as "acpi=off" are placed.
* #GRUB_TERMINAL=console
Uncomment to disable graphical terminal (grub-pc only). This can be useful if the user plans on spending a lot of time in the GRUB 2 command line mode. Scrolling and screen responsiveness will be greatly speeded up.
* #GRUB_DISABLE_LINUX_UUID=true
Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
Update: A bug requires quotation symbols be added for this option to be enabled. Change true to "true" and uncomment the line to eliminate UUIDs for linux entries.
* #GRUB_GFXMODE=640x480
You can add this line and remove the # symbol to make it active. This entry sets the resolution of the graphical menu (the menu text size). It provides resolutions supported by the user's graphics card (e.g. 640x480, 800x600, 1280x1024, etc). The setting applies only to the boot menu text.
* From the GRUB 2 menu you can display available resolutions by typing "c" and then at the "grub>" prompt type "vbeinfo"
* GRUB_DISABLE_LINUX_RECOVERY=true
Add or uncomment this line to prevent "Recovery" mode kernel options from appearing in the menu. If you want a "Recovery" option for only one kernel, make a special entry in /etc/grub/40_custom.
* GRUB_DISABLE_OS_PROBER="true" - Enables/disables the os-prober check of other partitions for operating systems, including Windows, Linux, OSX and Hurd.
* GRUB_INIT_TUNE="480 440 1"
o Introduced in Grub 1.98 (Lucid)
o When uncommented, plays a single beep just prior to the Grub 2 menu display.
o The format unless a file is named is: "tempo [pitch1 duration1] [pitch2 duration2] ..."
o The duration is based on the tempo. A tempo of 60 gives the duration a value of 1 second, 120 is .5, 240 is .25, 480 is .125, etc. The length of the tone can be changed by modifying either the tempo (all tones) or duration (individual tone).
+ Just a bit of fun:
# Warning: The menu will not be displayed until the tone is finished
# Close Encounters/5 Tone: GRUB_INIT_TUNE="480 900 2 1000 2 800 2 400 2 600 3"
# Fur Elise (note long): GRUB_INIT_TUNE="480 420 1 400 1 420 1 400 1 420 1 315 1 370 1 335 1 282 3 180 1 215 1 282 1 315 3 213 1 262 1 315 1 335 3 213 1 420 1 400 1 420 1 400 1 420 1 315 1 370 1 335 1 282 3 180 1 215 1 282 1 315 3 213 1 330 1 315 1 282 3"
o Online documentation is available by typing "info grub --index-search play" in a terminal.
* /etc/grub.d/
o The files in this folder are read during execution of "update-grub" or "update-grub" commands. The contents are imported into /boot/grub/grub.cfg

The order of the entries in the grub menu is based on the order of the file names. File named with a starting numeral are run before those beginning with a letter. The order the files are run determines the menu order in grub.cfg.
Custom entries can be added to the "40_custom" file or in a newly created file.

Any file created must be executable in order to be included in the grub.cfg file during the "update-grub" command.
+ 00_header
+ 05_debian_theme: Set background and text colors, themes
+ 10_hurd Locates Hurd kernels
+ 10_linux Locates Linux kernels based on results of the "lsb_release" command.
+ 20_memtest86+: If the file /boot/memtest86+.bin exists, it is included as a menu item.
+ 30_os-prober: Searches for Linux and OS's on other partitions and includes them in the menu.
+ 40_custom: A template for adding custom menu entries which will be inserted into grub.cfg upon execution of the "update-grub" command. This and any other custom file must be made executable to allow importation into grub.cfg.


# Adding Entries to Grub 2
Menu entries can be added to grub.cfg automatically or manually.

* Automatically.
o When "update-grub" or "update-grub" is executed, Grub 2 will search for linux kernels and other Operating Systems. What and where is looks is based on the files contained in /etc/grub.d folder.
+ 10_linux searches for installed linux kernels on the same partition.
+ 30_os-prober searches for other operating systems.
* Custom User Entries (/etc/grub.d/40_custom).
o Entries to grub.cfg can be manually inserted by creating a file in the /etc/grub.d folder.
+ The name of the file determines the order in the menu. 30_os-prober entries will be placed before 40_custom entries, which will be placed before 50_my-sample entries.
+ Any created file must be made executable. This can be done as root by running "sudo chmod +x /etc/grub.d/filename".
+ The files in the /etc/grub.d folder will be read and the contents included in grub.cfg when the "update-grub" command is executed as root.
o A sample entry. This file creates a menu item for running the SystemRescueCD (previously installed) from a partition created on sda10. Folders and files must have been copied to the correct location in accordance with the SystemRescueCD if you wish to actually use this entry. Note this entry will not work for a SystemRescue ISO. See Section 14 for instructions on how to add an entry to boot ISO images.
#!/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.

menuentry "System Rescue CD" {
set root=(hd0,10)
linux /sysrcd/rescuecd subdir=sysrcd setkmap=us
initrd /sysrcd/initram.igz
}


# Note the new partition naming convention. Devices start counting from "0" as done previously. sda is designated as "hd0", sdb is "hd1", etc. However the first partition is now designated as sda1. Counting partitions does not start with "0". sda5 is "5".
# If the user wishes to get visual confirmation in the terminal that the 40_custom file contents are being added when "update-grub" is executed, the following line can be added to the /etc/grub.d/40_custom file:

echo "Adding 40_custom menu entries." >&2


#

*
o Place this line immediately after the first line - "#!/bin/bash" - and before the "exec tail -n +3 $0" line.

# Tip: If you want to have your custom entries at the top of the menu (say you want custom titles), create a new file and name it "07_xxxx". Since the files in /etc/grub.d/ are read sequentially, those in "07_custom" will be placed before those of "10_linux". I recommend not naming a custom menu file lower than 06 so that any theme run from 05_debian_theme is allowed to run before any custom menu is created. After creating the file, run sudo update-grub and then check the value of "DEFAULT" in /etc/default/grub. If it doesn't point to the correct menuentry, change the value of DEFAULT to the correct menuentry value.
# Omitting memtest86+: To prevent "memtest86+" entries in your Grub 2 menu, remove the "executable" bit from /etc/grub.d/20_memtest86+. You can do this via a file browser by selecting "Properties (right click), Permissions", or via the command line:

Code: Select all
sudo chmod -x /etc/grub.d/20_memtest86+


Omitting Recovery Mode entries: The file /etc/grub.d/10_linux was recently updated to include a check for recovery mode options. Edit /etc/default/grub and add or change this line:

GRUB_DISABLE_LINUX_RECOVERY=true


If you have an older version of /etc/grub.d/10_linux and the above does not work after updating grub, you can prevent "Recovery mode" entries in your Grub 2 menu, by editing /etc/grub.d/10_linux. If there are no conditional "if" statements concerning the recovery mode, place a comment symbol (#) in front of the following lines (at approximately line 146) of the old file:

# linux_entry "${OS}, Linux ${version} (recovery mode)" \
# "single ${GRUB_CMDLINE_LINUX}"


# retain one "Recovery mode" entry for insurance, you can add an entry to /etc/grub.d/40_custom which will appear at the bottom of your grub menu.
# Building a Totally Customized Menu: Ok, admit you are a control freak and you want to see only what you build yourself - customized titles, no "memtest86+" and no extra kernels. Here is how you do it:

* Run sudo update-grub to get the current available kernels.
* Copy the desired "menuentry" listings from /boot/grub/grub.cfg to /etc/grub.d/40_custom The entry begins with the line starting with "menuentry" and ends with a line containing "}".
* Add any other "menuentry" items you wish to see on the boot menu.
* Edit the titles of the "menuentry" line if desired (between the quotation symbols). Do not change the lines following the "menuentry" line. Each entry should start with a "menuentry" line and end with a "}" on the last line.
* Remove the executable bit from /etc/grub.d/10_linux, /etc/grub.d/20_memtest86+ and /etc/grub.d/30_os-prober
Removing the executable bit from any file in /etc/grub.d will exclude the file from being included in grub updates.

Code: Select all
sudo chmod -x /etc/grub.d/10_linux /etc/grub.d/20_memtest86+ /etc/grub.d/30_os-prober


#

* Run "sudo update-grub"
* The updated /boot/grub/grub.cfg file should now contain only sections for "00_header", "05_debian_theme" and "40_custom".
* The grub.cfg file will not be updated with the addition of a new kernel. To add a new kernel, make "10_linux" executable, run "sudo update-grub" to refresh the available kernels, and repeat these instructions.

# Incorporating the DEFAULT=save Option: In order to enable the "saved default" option with which Grub 2 preselects the last successfully-used option at boot, the "DEFAULT=save" option must be entered in /etc/default/grub and the 40_custom file must be modified. An example of a 40_custom file follows:
#! /bin/sh -e

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
. ${libdir}/grub/grub-mkconfig_lib


menuentry "Jaunty 2.6.28-15-custom" {
save_default_entry | sed -e "s/^/\t/"
set root=(hd0,7)
linux /boot/vmlinuz-2.6.28-15-custom root=UUID=12c55255-27b3-488b-hje7e-9dbe4e2esfg5 ro quiet splash
initrd /boot/initrd.img-2.6.28-15-custom
}

menuentry "SystemRescue" {
save_default_entry | sed -e "s/^/\t/"
set root=(hd0,6)
linux /sysrcd/rescuecd subdir=sysrcd setkmap=us
initrd /sysrcd/initram.igz
}


Manual Windows Entry (with /etc/grub.d/30_os-prober made unexecutable)
#! /bin/sh -e

menuentry "Windows Vista 43_custom" {
insmod chain
insmod ntfs
search --fs-uuid --set CFFCFF9EECFF7F49
chainloader +1
}


#

* Don't forget to run "sudo update-grub" after making any changes to your /etc/grub.d files.


# Manual Editing of grub.cfg (Not encouraged)
Manual editing of /boot/grub/grub.cfg is not encouraged. Think of grub.cfg as a result, not as an initiator. The files that should be edited are contained in the /etc/grub.d folders and the /etc/default/grub file.

In order to discourage its editing, grub.cfg is read-only. Even attempting to open, edit and save this file using root privileges cannot be done until the 'read-only' status is changed. If you must edit this file:

Code: Select all
sudo chmod +w /boot/grub/grub.cfg
gksudo gedit /boot/grub/grub.cfg


#

* Note: This file is returned to 'read-only' status anytime the update-grub command is run.


# Removing Entries from Grub 2
Entries should be removed by editing or removing files in the /etc/grub.d folder. The /boot/grub/grub.cfg file is read-only and should not normally require editing.

* Automatically.
o Too Many Kernels? Kernels removed via Synaptic or with "apt-get remove" will automatically update grub.cfg and no user action is required.
+ In Synaptic, type the kernel number in the search window at the upper right (for example - 2.6.28-11).
+ Find the "linux-image" and "linux-headers" files for the applicable kernel (example - linux-image-2.6.26-11 or "linux-image-2.6.26-11-generic).
+ Right click and select "Mark for Complete Removal" and then press the Apply main menu button.
+ The kernels will be removed from your system and from the Grub menu.
+ If you are not sure of the kernel you are currently using, in a terminal type "uname -r".
+ Many users keep one previous kernel on the machine which previously ran without problems.
o Other Operating Systems which have been removed from the computer will also be removed from the menu once "update-grub" is run as root.
o To prevent one of the /etc/init.d files from running, remove the "executable" bit.
+ Example: If you don't want to see the "Memtest86+" entries, run this command:

Code: Select all
sudo chmod -x /etc/grub.d/20_memtest86+


#

*
o
+ Run the update-grub command to allow the changes to be incorporated in grub.cfg


User-Created Entries.
o To remove a user-created menu entry, remove the applicable file from the /etc/grub.d folder.
o If a custom file contains multiple entries, individual items may be removed and others retained.
o Once the file has been removed or edited, run "update-grub" to update grub.cfg.


# Grub 2 Splash Images & Theming
Why reinvent the wheel? Visit this site for an excellent presentation on creating Grub 2 images:
http://members.iinet.net/~herman546/p20 ... mages.html

However, if encrypted disks are not an issue, here are the basics:

* Manually copy grub splash images into the /usr/share/images/grub folder or install the default grub2 splash images via Synaptic or:

Code: Select all
sudo apt-get install grub2-splashimages


The grub2's splash images are controlled by /etc/grub.d/05_debian_theme. Open this file for editing:

Code: Select all
gksudo gedit /etc/grub.d/05_debian_theme


Grub 1.97~beta4
Find the following line and edit the highlighted area, replacing it with the grub splash image you wish to use (and located in /usr/share/images/grub):

for i in {/boot/grub,/usr/share/images/grub}/moreblue-orbit-grub.{png,tga} ; do


# Note: There is a period ( . ) following the filename.

* At one point Grub 2 splash images were downloaded and stored in /usr/share/images/desktop.base If this is where your grub images are stored, change the address in the previous command accordingly ( ... /usr/share/images/desktop-base} ... ).

# Grub 1.97 (non-beta) & later)
It's a little easier to understand in Grub 1.97 (non-beta) and later versions of Grub. Find the following line and edit the highlighted area, replacing it with the path and grub splash image you wish to use:

WALLPAPER="/<path-to-image>/<your-image-name-here-including-extension>"


#

* Example: WALLPAPER="/home/my_username/grub_images/my_grubimage.png"
o At one point Grub 2 splash images were downloaded and stored in /usr/share/images/desktop.base If this is where your grub images are stored, change the address in the previous command accordingly ( ... /usr/share/images/desktop-base} ... ).

# Save the file, then update grub2:

Code: Select all
sudo update-grub


#


A Note About Grub 2 Theming
Theming is still under development in Grub 2. There are several different approaches being taken and users of Lucid have had success incorporating theming into their bootlaoder menus. For those interested in trying out the experimental theming possibilities, here are some references:
GRUB2 theming for lucid? This thread has an excellent discussion about the state of theming in in bootloaders, as well as instructions on how to set it up as you get further into the thread. Both BURG and Grub 2 experimental are discussed.
Grub 2 Experimental:
http://grub.gibibit.com/ One method of introducing theming, when combined with this Launcpad PPA for Grub 2 experimental, Felix Zielcke's PPA
BURG:
https://help.ubuntu.com/community/Burg and https://help.ubuntu.com/community/Burg

# Changing Menu Resolutions
If the user wishes to change the resolution of the GRUB 2 screen while using a splash image follow these steps:

1. Set the desired resolution in /etc/default/grub
* Change the value of GRUB_GFXMODE= (Example: GRUB_GFXMODE=800x600)
o If unsure of what resolutions are available to GRUB 2 they can be displayed by typing vbeinfo in the GRUB 2 command line. The command line is accessed by typing "c" when the main GRUB 2 menu screen is displayed.
2. Select an image of the same size and make the change in /etc/grub.d/05_debian_theme
* The image name is located in the line beginning with " for i in {/boot"
* If an image of the correct size is not used, the menu will not be positioned correctly.
* Use the image editor of your choice to create/resize an image to the correct size.
* The user may be able to view the image size via Properties in a file browser (check the Properties Image tab in Nautilus).
3. Run update-grub as root to add the new settings to /boot/grub/grub.cfg


# Basic Password Protection

Note: To reduce the size of this entry, a separate post with information on establishing Grub 2 password protection is located on the Ubuntu forums at: Grub 2 Password Protection and in the links at the bottom of this post.

Grub 2 currently supports unencrypted password protection. Encrypted password protection using PBKDF2, as well as password scripting, is currently under development.

Some of the major points regarding Grub 2 password protection:

* Grub 2 has the ability to set password protection on individual menuentries and/or for specific users. Examples: Password protect Windows Recovery; prevent user2 from opening the Recovery mode.
* If password protection is enabled, the superuser username and password are required to gain access to the Grub 2 command line and menu editing modes.
* The username and/or password do not have to be the same as the Ubuntu logon name/password.
* This is basic password security. The name/password are unencrypted; anyone having physical access to the machine and more than an elementary knowledge of how Linux works will be able to access the configuration files and bypass this feature.
* Grub 2 password protection is still being developed. Encryption is available in experimental versions only. If password protection is used, recheck your scripts for changes whenever a new Grub 2 update is released. In 1.97~beta4, passwords must be assigned to each desired menu item. In Lucid Lynx, expect Grub 1.97 to password protect the entire Grub 2 menu if a superuser is designated.


# How to Boot to the Recovery Mode w/o a Menu Option

1. If you have Grub 2 set to boot without displaying the menu at all, hold the SHIFT key down until the menu displays. (In Grub it was the ESC key.)
2. Press any key once the menu is displayed to 'freeze' it. Then arrow to the kernel you want to boot.
3. Press "e"
4. Scroll to the end of the "linux /boot/vmlinuz...." line. If displayed, remove "quiet" and/or "splash". Add the word "single" to the end of the line.
5. Press CTRL-X to boot to the Recovery menu.


# Uninstalling GRUB 2
The command line produces a cleaner uninstall and reinstallation. While adding and removing the packages can be accomplished with Synaptic, certain steps must be accomplished in a terminal.

* Open a terminal: Applications, Accessories, Terminal.
* Make backup copies of the main GRUB 2 folders & files

Code: Select all
sudo cp /etc/default/grub /etc/default/grub.old
sudo cp -R /etc/grub.d /etc/grub.d.old
sudo cp -R /boot/grub /boot/grub.old


Remove GRUB 2

* Ensure you have an Internet connection and reliable power source. An interruption of either could leave your system in an unbootable condition.

Code: Select all
sudo apt-get purge grub-common grub-pc


#

* The user will be warned the system will be unbootable without installing another bootloader.
* Once the packages are removed, many files will still remain in '/boot/grub'

# Install GRUB 2

Code: Select all
sudo apt-get install grub-common grub-pc


* The user will be asked for any special commands to add to the default "linux" line. If you aren't sure, leave it blank, press the TAB key to highlight "OK" and press ENTER.
* Select the appropriate drive on which to install Grub2 (sda, sdb, etc) by highlighting the entry and pressing the space bar. Normally a partition (sda1, etc) should not be selected.

Code: Select all
sudo update-grub


#

*
o Reboot


# Reinstalling GRUB 2 from LiveCD
If you cannot boot from GRUB 2 and need to reinstall it, here is the simple method. For more details or for advanced options, refer to the Ubuntu community documentation here: Grub2 - Reinstalling GRUB 2:

* Boot the Karmic or Lucid LiveCD (Try without installing).
* From the Desktop, open a terminal - Applications, Accessories, Terminal.
* Determine your normal system partition - `sudo fdisk -l` (That is a lowercase L)
* If you aren't sure, run `df -Th`. Look for the correct disk size and ext3 or ext4 format.
* Mount your normal system partition:

Code: Select all
sudo mount /dev/sdXY /mnt


#

* Example: sudo mount /dev/sda1 /mnt
* Note: The partition to mount is normally the partition on which Ubuntu was installed: sda1, sdb5, etc. If you have a separate /boot partition, use the device on which the /boot partition is located. Grub 2 works best when installed in the MBR of the drive to which BIOS boots. Also remember that you mount the partition (including the number) in this step, but you do not include the partition number when you run the "sudo grub-install" command later.
* Note: GRUB 2 counts the first drive (X) as "0", but the first partition (Y) as "1"

# Only if you have a separate boot partition:

Code: Select all
sudo mount /dev/sdXY /mnt/boot


#

* with sdXY being your /boot partition designation.

# Reinstall GRUB 2:

Code: Select all
sudo grub-install --root-directory=/mnt /dev/sdX


#

* Example: sudo grub-install --root-directory=/mnt /dev/sda
* Note: Substitute the device on which Ubuntu was installed - sda, sdb, etc. Do not specify a partition number.

# Unmount the partition:

Code: Select all
sudo umount /mnt


#

* Reboot.


# Booting LiveCD and Other ISOs
Grub 2 provides the capability to boot certain .iso images. These image files (ISO's) include the Ubuntu LiveCDs, SystemrescueCD and the Parted Magic CD.

The following examples assume the ISO image is located on the user "drs305"'s Desktop on sda1. The address of the file, named test.iso would be /home/drs305/Desktop/test.iso. Grub 2 uses the convention (hd0,1) to designate sda1. The user must change the path and filenames in the following examples to match the location of the ISO image on their system.

In order to incorporate an ISO boot option into the Grub2 menu, take the following steps:

* Open the /etc/grub.d/40_custom file for editing as root, or create another custom file in the same folder.
* Create a menuentry. Leave the existing first 5 lines of the file alone. Any entries should be made below the pre-existing lines.
* Make sure the partition, path and filename are correct for the image you will be using.
* Ensure there are no spaces at the end of any lines.
* Save the file, run "sudo update-grub", and then check the contents of /boot/grub/grub.cfg to make sure the contents of the 40_custom file are included. The user will not see the custom file listed in the terminal during the running of the update-grub command.


The following are examples of an Ubuntu LiveCD, the SystemRescueCD, and the Parted Magic CD. In the examples, the ISO images are stored on user "drs305"'s Desktop on sda1. These entries would be added to the /etc/grub.d/40_custom file.
Notes:

* For the SystemRescue CD, replace "rescuecd with "rescue64" on 64-bit systems.
* The "quiet" option has been omitted from the "linux" line in order for the user to see progress during boot. Even so, there may be periods where the boot appears to halt. Let it continue unless an error message is visible.

Code: Select all
menuentry "Lucid ISO on /dev/sda1" {
loopback loop (hd0,1)/home/drs305/Desktop/ubuntu-10.04-beta2-desktop-amd64.iso
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/home/drs305/Desktop/ubuntu-10.04-beta2-desktop-amd64.iso noprompt
initrd (loop)/casper/initrd.lz
}

menuentry "  SystemRescue-ISO on /dev/sda1" {
loopback loop (hd1,5)/home/drs305/Desktop/systemrescuecd-x86-1.5.1.iso
linux (loop)/isolinux/rescuecd setkmap=us isoloop=/home/drs305Desktop/systemrescuecd-x86-1.5.1.iso
initrd (loop)/isolinux/initram.igz
}

menuentry "Test Parted Magic ISO on /dev/sda1" {
set root=(hd0,1)
loopback loop (hd0,1)/home/drs305/Desktop/pmagic-4.10.iso
linux (loop)/pmagic/bzImage iso_filename=/home/drs305/Desktop/pmagic-4.10.iso boot=live load_ramdisk=1 prompt_ramdisk=0 noeject noprompt
initrd (loop)/pmagic/initramfs
}


# Booting from the Rescue Mode
At the grub rescue> prompt, accomplish the following actions to attempt to boot to the latest kernel:

* ls This will display the known devices and partitions. From this information, the user must determine the device and partition on which the system is installed.
* search -f /vmlinuz This should find linux kernels located in the partitions located by "ls".
* set Check the current settings. Note the prefix listing. If it is not pointing to the correct location:
o set prefix=(hdX,Y)/boot/grub Examples: sda1 is (hd0,1), sdb5 is (hd1,5)
* set root=(hdX,Y) X is the device/drive, starting with 0. Y is the partition, starting with 1. (Example: (hd0,1) is sda1. (hd3,5) is sdc5.
o For Wubi installs, use: set root=(loop0)
* ls /boot Inspect the contents. The user should see varioius kernels, initrd images and the grub folder. If not, use the ls command to inspect the device and attempt to find these files and folders. If necessary, set another device as root.
* insmod /boot/grub/linux.mod Load the linux module. Without this module loaded, the user will receive an "Unknown command linux" message when trying to load the kernel.
* linux /vmlinuz root=/dev/sdXY ro Load the linux kernel, substituting the correct designations for "X" and "Y" (example: sda1). The user will see a message showing the kernel has been loaded. (See graphic above)
o Note: For Wubi installs within Windows, use this code: linux /vmlinuz root=/dev/sdXY loop=/ubuntu/disks/root.disk ro
* initrd /initrd.img Load the initrd image. When pressing enter, the user may or may not see a message in the terminal. (See highlighted graphic above)
* boot

More command line recovery options are available in the "Command Line & Rescue Mode" section of the Ubuntu Grub 2 community doc.

# Restoring GRUB2 / XP / Vista / Win 7 Bootloaders
talsemgeest has written an excellent guide on how to restore the bootloaders of various operating systems following the installation of another one. Make sure you reference the section for "9.10 and Beyond", which is for GRUB 2.

Rather than duplicate his efforts in this post, here is the link to the original:
http://ubuntuforums.org/showthread.php?t=1014708

Restoring Windows MBR without a Windows CD
If you want to boot directly to Windows but Grub has overwritten the MBR, the normal procdeure is to use the Windows CD to restore things. If you do not have access to the Windows CD, the following commands will rewrite the MBR, removing Grub and allowing the system to boot directly into Windows.

Boot the Ubuntu LiveCD, open a terminal (Applications, Accessories, Terminal) and enter the following commands. Make sure you correctly identify the Windows device (normally sda):

Code: Select all
sudo apt-get install lilo
sudo lilo -M /dev/sda mbr


Selected Problems & Bugs

meierfra has been busily building pages which detail how to solve many of the common problems users are experiencing with Grub 2. His SourceForge web page should be one of the first stops for those seeking answers to Grub 2 issues.


Lose Ubuntu/Windows After Installing the Other
If you have lost the ability to boot into Windows or Ubuntu following the installation/reinstallation of the other OS it could be an overwritten MBR issue. If the OS was previously working, there is an excellent guide written by talsemgeest that may very well restore the lost OS. Here is the link:
How to restore the Ubuntu/XP/Vista/7 bootloader (Updated for Ubuntu 9.10)


No Menu On Initial Boot
If you are already on the Ubuntu Desktop, run "sudo update-grub". This may detect additional operating systems, which may allow the Grub menu to be displayed on the next boot. Otherwise:
Open /etc/default/grub:

Code: Select all
gksu /etc/default/grub


Disable the "GRUB_HIDDEN_TIMEOUT=" line by placing a # symbol at the beginning of the line.
Set "GRUB_TIMEOUT=" to a positive integer (number of seconds to display the menu before automatic selection) or "-1" to wait for the user to press ENTER (no timeout). The entry will look like this:

#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT="10"


Save the file, update grub ("sudo update-grub") and reboot.


External Drive Installs - Bug bug/496435
Installs of Ubuntu on external drives can cause problems as grub-install uses device names (e.g. sda, sdb) rather than UUIDs in certain circumstances. If connected to another machine when an update of grub-pc is made, the upgrade may be written to the incorrect device and make the computer unbootable.

A workaround is posted on the bug link above.


External Drive Installs and MBR - Bug bug/414996
When installing Ubuntu to a USB drive, the potential exists for GRUB 2 to write to the hard drive's MBR or split the installation between the hard drive and the USB drive (rather than completely on the USB device). This can render the main drive unbootable.

Workaround: During the final stages of the install there is an "Advanced" button which allows the user to select the install location.


HP Machines Fails to Load Grub after Using Windows - Bug [URL="https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/441941"]bug/441941/URL]
After installing Grub 2 on a HP machine, the system boots normally until the first time it's booted into Windows. On the next boot, the system hangs at "Grub loading".

Workaround: HP protection tools are rewriting to the MBR when Windows is run. The protecttools app must be removed/disabled. Refer to post #10 in the Bug Report.


"VGA Deprecated" Message on Boot
Symptom: A blank screen appears with a message concerning VGA being deprecated after the menu item is selected (manually or by default). The message will be a variation of: "VGA=792 is deprecated. Use set GFX payload=1024x768x24, 1024x768 using the linux command instead."

The message probably is informing the user that there is a vga entry on either the "GRUB_CMDLINE_LINUX_DEFAULT=" or "GRUB_CMDLINE_LINUX=" line of /etc/default/grub. "Deprecated" means that there is a newer, preferred way to convey this instruction in GRUB 2. (Note the "vga=" method will still work, despite the message. It is advisory only.)

In the example above, the line would probably look something like:

GRUB_CMDLINE_LINUX_DEFAULT=quiet splash vga=792"
GRUB_CMDLINE_LINUX=""


To conform to the desired format and eliminate the message, change the above lines in /etc/default/grub to look like the following, using the "vga" value, and translated value, found in your current default file:

GRUB_GFXMODE=1024x768
GRUB_CMDLINE_LINUX_DEFAULT=quiet splash"
GRUB_CMDLINE_LINUX=""


Save the file and run "sudo update-grub" for the changes to be incorporated in the menu.
There is a vga conversion table located at: http://wiki.archlinux.org/index.php/Gensplash From the GRUB 2 command line, you can run "vbeinfo" to see resolutions supported by your system.


File Not Found (From a Grub 2 prompt)
Not to be confused with the Grub Legacy "File Not Found - Error 15" (See next).
When this message appears in Grub 2, it means that G2 cannot find one or more of the files required to accomplish the task. If this occurs, the user can use the "ls" command to find out what drives/partitions G2 sees. The output normally is something like (hd0) (hd0,1) (hd0,2) (hd0,5) (hd1) (hd0,1), etc. Remember the first drive (X) is "0", the first partition (Y) is "1". You can then inspect the contents, checking for the proper files with /boot, with "ls (hdX,Y)/boot", for instance.

Often in this case the user must reset "root" and/or "prefix". You can see the current settings from the G2 command line with the command "set". If you know the device/partition you want to boot, from the Grub 2 terminal run the following. You will get no feedback if there isn't an error. You can check the results by running "set" again.

Code: Select all
set root=(hdX,Y)                    # Example:  set root=(hd0,5)
set prefix=(hdX,Y)/boot/grub        # Example for a normal Ubuntu install on sda1: set prefix=(hd0,1)/boot/grub


error: no such device: 86d32ee3-aec6-490b-8dab-e5cfff9c7af9
This error is the result of a failure of the GRUB 2 search function. There are various bugs associated with the search function. To boot into your system, highlight the OS you want to boot. Press "e" to edit the menuentry. Delete the entire "search ..." line, then CTRL-x to boot.

Once you have booted into the system, you will modify the /usr/lib/grub/grub-mkconfig_lib file in accordance with this link:
Boot Problems:search


File Not Found (Error 15)
This error is the result of a GRUB 2 installation to /boot but a Master Boot Record ( MBR ) which still contains Grub legacy. This can happen if you don't select your drive when running sudo update-from-grub-legacy. Shortly after starting this command the user will be asked to select the device (sda, sdb, etc). Highlight the drive and press the space bar to select it when presented with this screen. Failure to select a drive will result in an Error 15.

To recover from this error, GRUB 2 must be reinstalled. Go to the community documentation File Not Found (Error 15) for instructions.

If you find you need to remove the following lines manually to get Grub to boot properly:

recordfail=1
save_env recordfail


Open /etc/grub.d/10_linux with admin rights:

Code: Select all
gksu gedit /etc/grub.d/10_linux


Look for this section and comment the lines in bold;

inux_entry ()
{
menuentry "$1" {
recordfail=1
save_env recordfail


Change it to:

- linux_entry ()
{
menuentry "$1" {
# recordfail=1
# save_env recordfail


Save the file, then run

Code: Select all
sudo update-grub


The two lines should no longer appear when you press E to view the selection in the Grub 2 menu. You will see a "save_env save_entry" line but this should not cause the failure if you successfully booted the previous time.

Grub 2 Hangs 10-30 Seconds between Grub 2 Loading and Menu Display.
This is a known bug that can be caused by GRUB 2 and /boot being loaded on different partitions. To fix the problem, run

Code: Select all
sudo dpkg-reconfigure grub-pc


# elect to load Grub 2 on the same device as the /boot partition. In your system BIOS, change the drive to boot from first to the drive with the /boot partition.


Wubi Installs within Windows Won't Boot.
This bug has been fixed in Ubuntu 10.04. For prior versions, the user is greeted with "Try (hd0,0) : NTFS5: " This is a known bug as well as others that may cause Wubi boot failures. Refer to meierfra's Boot_Problems:Wubi_9.10 page.


"Grub loading. The symbol ' ' not found. Aborted." on Dell machines..
On Dell computers with Dell DataSafe Local Backup (DDSLB) installed, the above message is displayed with a series of characters within the ' ' section. This is a reported bug,
bug #482757. Thanks to merry_meercat's post which details how to fix the problem.



Grub "error: out of disk" or "failed to boot default entries".
This error message is sometimes generated when Grub 2 cannot properly write to the file /boot/grub/grubenv. Refer to meierfra's Boot_Problems:Write page.


"Grub loading. The symbol ' ' not found. Aborted." on Dell machines..
On Dell computers with Dell DataSafe Local Backup (DDSLB) installed, the above message is displayed with a series of characters within the ' ' section. This is a reported bug,
bug #482757. Thanks to merry_meercat's post which details how to fix the problem.


# Links

Grub2 (help.ubuntu.com)
https://help.ubuntu.com/community/Grub2
Grub 2 Title Tweaks
http://ubuntuforums.org/showthread.php?t=1287602
GRUB 2 - 5 Common Tasks
http://ubuntuforums.org/showthread.php?t=1302743
Grub 2 Introduction
http://ubuntuforums.org/showthread.php? ... ost8072444
Grub 2: A Guide for Users (from Kubuntu
Forums)
http://kubuntuforums.net/forums/index.p ... =3106368.0
https://wiki.ubuntu.com/KernelTeam/Grub2Testing
GNU Grub 2 Manual Links
https://wiki.ubuntu.com/KernelTeam/Grub2Testing
GNU Grub 2 Manual (in development)
http://grub.enbug.org/Manual
http://www.gnu.org/software/grub/manual/
Grub 2 Wiki
http://www.gnu.org/software/grub/grub-2.en.html
Herman's Grub 2 Site Comprehensive.
http://members.iinet.net/~herman546/p20.html
Herman's Grub 2 Scripts Useful scripts for many Grub 2 tasks.
http://ubuntuforums.org/showthread.php?t=1014708
http://grub.gibibit.com/ Grub 2 Theming (currently for Ubuntu G2 experimental)
How to restore the Ubuntu/XP/Vista/7 bootloader
http://sourceforge.net/apps/mediawik...itle=Main_Page meierfra's Grub 2 Solutions Page
How-to Install 9.10 karmic on fakeraid by gilson585
http://ubuntuforums.org/showthread.php?t=1360445
How to create a Grub 2 Floppy See post 283 of this thread. Thank you peter b
http://ubuntuforums.org/showpost.php?p= ... tcount=283
Admin-Amir
 



Re: The Grub 2 Guide

Postby billhedrick » Mon May 10, 2010 2:41 pm

This is amazing work! Thanks a lot!
Image
User avatar
billhedrick
Site Admin
 
Posts: 1244
Joined: Tue Jun 16, 2009 4:15 pm
Location: Saint Paul, MN. USA
Age: 65
Operating System: Ultimate Edition 3.2 32 BIT



Re: The Grub 2 Guide

Postby kiwinsn » Sat Nov 26, 2011 1:49 pm

This post just got spammed so I am locking it.

Cheers
Image
System:
Specs to come.
Registered Linux user number: 542342
Image
User avatar
kiwinsn
Moderator
 
Posts: 449
Joined: Thu Jan 03, 2008 6:56 pm
Location: Nelson, New Zealand
Age: 53
Operating System: Ultimate Edition Beta Tester


Return to How To's (Do not post questions please)

Who is online

Users browsing this forum: No registered users and 2 guests