Académique Documents
Professionnel Documents
Culture Documents
Grub 2
Contents
1. GRUB 2 Testing
2. Installing / Upgrading
1. Installing (Ubuntu 9.10 and newer)
2. Installing (Ubuntu 9.04+)
3. Grub 2 Files & Folders
1. grub.cfg (/boot/grub/grub.cfg)
2. grub (/etc/default/grub)
3. /etc/grub.d/ (folder)
4. Automatic Entries
5. User-defined Entries
6. Removing Entries from Grub 2
4. Theming
1. Splash Images
2. Background Colors/Image
1. Copy/Edit Default Colors
2. Create a new theme file
5. Commands
6. Recover Grub 2 via LiveCD
1. Restore GRUB2 - Recovering from a Windows XP / Vista / 7
Reinstallation
7. Errors
1. Where did my Grub2 boot menu go!?!?!
2. Dual-booting
3. --no-floppy
4. unknown command 'initrd'
5. sleep 'invalid number 0.1'
6. Error 11
1. After upgrading from GRUB Legacy
7. Error 15 - File not found
8. Links
NOTE: A more recent version of the information on this page can be found on
https://help.ubuntu.com/community/Grub2 .
GRand Unified Bootloader, version 2 (Grub 2) is the second version of GNU GRUB. It is
the software responsible for loading and transferring control to the operating system kernel
during the initial boot. Grub 2 is compatible with standard POSIX (GNU/Linux, *BSD, Mac
OS, etc) and can also connect to systems incompatible with standard POSIX (Portable
https://wiki.ubuntu.com/Grub2#Dual-b… 1/18
9/4/2010 Grub 2 - Ubuntu Wiki
Operating System Interface for Unix).
GRUB 2 is a complete rewriting of the Grub interface. Based on the research project PUPA,
GRUB 2 is more modular and portable than its predecessor. Some of the GRUB 2
scheduled improvements include:
GRUB 2 Testing
Grub 2 is currently at version 1.96 so users still have time to contribute to its development.
Follow this link and please help out with GRUB 2 Testing.
Installing / Upgrading
Open a Terminal
NOTE: This is only temporary, you must make the changes permanent by doing this...
Type, in a terminal
$ sudo upgrade-from-grub-legacy
https://wiki.ubuntu.com/Grub2#Dual-b… 2/18
9/4/2010 Grub 2 - Ubuntu Wiki
NB! You have to use the spacebar to mark the choice here. DO NOT go on without doing
this. It WILL result in your system showing error 15 and being unable to even show a boot
menu. If you are running a dual boot system with WindowsXP or Vista, you might have to do
additional fixes after upgrading to get it to work.
If this has already happened to you you can fix this by following the directions in the Error 15
section on this page.
On my test system it displayed (hd0) /dev/sda but this might differ on your system. If this is
incorrect, you must edit /boot/grub/device.map to match your system and then run
GRUB 2 should be fully installed, with GRUB legacy removed, and it's configuration files
backed up. GRUB legacy configuration files are located in /boot/grub and are named
menu.lst*
You can confirm the version you are installing at any time with:
grub-install -v
The program name "update-grub2" is provided for compatibility with older versions
of the grub2 packaging, but from now on this document will only use the name "update-
grub".
Many of the files in /boot/grub will not be familiar to users of Grub Legacy. Especially
noticeable are the multitude of *.mod files in the /boot/grub folder. Grub 2 is modular and the
*.mod files are loaded as necessary by grub. Despite the addition of these files, the total size
of the /boot/grub contents is fairly close to that of Grub Legacy and should not require a
larger /boot partition.
grub.cfg (/boot/grub/grub.cfg)
DO NOT EDIT THIS FILE This is the main Grub 2 file. It "replaces" Grub Legacy's
https://wiki.ubuntu.com/Grub2#Dual-b… 3/18
9/4/2010 Grub 2 - Ubuntu Wiki
/boot/grub/menu.lst. This file contains the Grub menu instructions. Unlike Grub Legacy's
menu.lst file, grub.cfg is NOT MEANT TO BE EDITED!!!
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/update-grub using templates
# from /etc/grub.d and settings from /etc/default/grub
#
https://wiki.ubuntu.com/Grub2#Dual-b… 4/18
9/4/2010 Grub 2 - Ubuntu Wiki
menuentry "Ubuntu, linux 2.6.28-13-generic" {
linux /boot/vmlinuz-2.6.28-13-generic root=UUID=b02e1934-12dd-
418a ro quiet splash vga800
initrd /boot/initrd.img-2.6.28-13-generic
}
menuentry "Ubuntu, linux 2.6.28-13-generic (single-user mode)" {
linux /boot/vmlinuz-2.6.28-13-generic root=UUID=b02e1934-12dd-
418a ro single
initrd /boot/initrd.img-2.6.28-13-generic
}
menuentry "Ubuntu, linux 2.6.28-11-generic" {
linux /boot/vmlinuz-2.6.28-11-generic root=UUID=b02e1934-12dd-
418a ro quiet splash vga800
initrd /boot/initrd.img-2.6.28-11-generic
}
menuentry "Ubuntu, linux 2.6.28-11-generic (single-user mode)" {
linux /boot/vmlinuz-2.6.28-11-generic root=UUID=b02e1934-12dd-
418a ro single
initrd /boot/initrd.img-2.6.28-11-generic
}
### END /etc/grub.d/10_linux ###
https://wiki.ubuntu.com/Grub2#Dual-b… 5/18
9/4/2010 Grub 2 - Ubuntu Wiki
### END /etc/grub.d/41_srcd ###
grub (/etc/default/grub)
This file contains information previously found in the upper section of /boot/grub/menu.lst. It
contains settings primarily affecting Grub's menu display. This file can be edited by root to
make changes to these settings; they will be imported into grub.cfg when "update-
grub" is executed.
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=""
GRUB_DEFAULT=0
Sets the default and pre-selected menu entry. Entries may be numeric or saved
GRUB_DEFAULT=0
https://wiki.ubuntu.com/Grub2#Dual-b… 6/18
9/4/2010 Grub 2 - Ubuntu Wiki
Sets the default menu entry by menu position. As with Grub Legacy, the
first "menuentry" in grub.cfg is 0, the second is 1, etc.
GRUB_DEFAULT="Windows XP Professional (on /dev/sda1)"
Sets the default menu entry by name.
GRUB_DEFAULT=saved
Sets the default menu entry with either whatever was selected on the last
boot (if GRUB_SAVEDEFAULT=true is set and the entry itself contains
savedefault), whatever the last grub-set-default command saved or the
first entry if nothing has ever been saved or the saved entry can't be
found. If the menu is displayed during boot, the previously selected
option will be highlighted. If no action is taken, this is selection which will
be booted at the end of the timeout, or if the menu is hidden.
GRUB_TIMEOUT=10
No change from Grub Legacy. This is the number of seconds before the default
entry is automatically booted.
Setting a value of -1 will display the menu until the user makes a selection (no
timeout).
GRUB_HIDDEN_TIMEOUT=0
The hidden timeout option is available to single-OS computers - if
multiple OS's are known to Grub 2, this option is bypassed.
On single-OS systems, the menu will be hidden unless a # symbol is present at
the beginning of this line. ( # GRUB_HIDDEN_TIMEOUT=0 )
The default setting initially depends on the presence of other operating systems.
Another OS Detected: The menu will be displayed. ( The line will begin
with a # symbol. )
No other OS Detected: This setting is not used, as determined by the
For integers greater than 0, the system will pause, but not display the menu, for
the entered number of seconds.
0 The menu will not be displayed. There will be no delay.
The user may force displaying the menu as the computer boots by holding
down the SHIFT key (single-OS computers only).
During boot, the system will check the SHIFT key status. If it
cannot determine the key status, a short delay will enable the user
to display the menu by pressing the ESC key.
If enabled, the splash screen designated in 05_debian_theme will
be displayed even if the hidden menu feature is selected.
GRUB_HIDDEN_TIMEOUT_QUIET=true
true - No countdown is displayed. The screen will be blank.
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
Determines the descriptive name in the menu entry. (Ubuntu, Xubuntu, Debian,
etc.)
https://wiki.ubuntu.com/Grub2#Dual-b… 7/18
9/4/2010 Grub 2 - Ubuntu Wiki
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. If you want a black screen with
scrolling boot messages, remove "quiet splash". If you want a grub splash screen
with limited messages underneath the Ubuntu logo, use only "splash". < This
[only "splash"]will not work in Karmic during boot as the xsplash does
not display the messages , but the messages at shutdown will be displayed.
#GRUB_TERMINAL=console
Uncomment to disable graphical terminal (grub-pc only).
#GRUB_GFXMODE=640x480
Uncomment (remove '#' from beginning of the line) to change (increase)
resolution of your boot loader. Use one of classic (4:3 rate):
GRUB_GFXMODE=640x480 (is used if isn't here a proper value)
GRUB_GFXMODE=800x600
GRUB_GFXMODE=1024x768
GRUB_GFXMODE=1600×1200
or make experiments with some others nonstandards like widescreen (16:10
ratio in my case), here is list of most of commonly use Display resolution:
GRUB_GFXMODE=640x400
GRUB_GFXMODE=800x500
GRUB_GFXMODE=1024x640
GRUB_GFXMODE=1280x800
GRUB_GFXMODE=1680x1050
If you don't know what modes are supported by your graphics card, go to the
grub command line and run 'vbeinfo'. It will list all available modes. (You might
need to run 'insmod vbe' first if the vbe module isn't loaded yet)
GRUB_GFXPAYLOAD_LINUX=640x480x8 [grub2 >= 1.98-1 (Lucid)]
Use this setting to set the framebuffer resolution (replaces the vga= kernel
option). It uses the GFXMODE values with additional color depth. Use
'vbeinfo' from the grub command line to list what modes are available to you.
#GRUB_DISABLE_LINUX_UUID=true
Uncomment this line if you don't want GRUB to pass "root=UUID=xxx"
parameter to Linux.
GRUB_DISABLE_LINUX_RECOVERY=true
Add or uncomment this line to prevent "Recovery" mode kernel options from
appearing in the menu.
GRUB_DISABLE_OS_PROBER=true
Enables/disables the os-prober check of other partitions for operating systems,
including Windows, Linux, OSX and Hurd.
https://wiki.ubuntu.com/Grub2#Dual-b… 8/18
9/4/2010 Grub 2 - Ubuntu Wiki
/etc/grub.d/ (folder)
The files in this folder are read during execution of '"update-grub"'command. The
scripts in these files write the information they gather into /boot/grub/grub.cfg.
The files are run in sequential order - numbered files are run in numerical order, followed by
files whose name begins with a letter. The order in which the files are executed determines the
location of items in the grub menu.
Any file created must be executable in order to be included in the grub.cfg file during the
"update-grub" command. This can be accomplished from the terminal with
"sudo chmod u+x /etc/grub.d/filename". The following is a very brief
look at what the files do. Examples given indicate output from the scripts.
00_header
Loads settings from /etc/default/grub, including visual presentations, timeout,
and terminal options.
05_debian_theme
Sets background, text colors, and themes.
If you wish to change text colors, print:
set color_normal=$foreground/$background
set
color_highlight=$foreground_color/$background_color
background_image
`make_system_path_relative_to_its_root ${bg}`
Automatic Entries
When "update-grub" is executed, Grub 2 will read /etc/default/grub and the
files in contained in the /etc/grub.d folder. This combination will set the visual
parameters of the grub menu (/etc/default/grub) and search for linux kernels, other
operating systems, and items designated in user-created scripts in /etc/grub.d. The
script files in /etc/grub.d perform the following tasks:
10_linux searches for installed linux kernels.
30_os-prober searches for other operating systems.
40_custom and any other user-created files in the /etc/grub.d folder add menu
items designated in the script files created by users.
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 any higher-numbered
entries.
Any user-created file must be made executable. This can be done as root by running
User-defined Entries
Users with "root" privileges can create scripts in the /etc/grub.d/ folder which will be
incorporated into the grub.cfg file when update-grub is run.
The filename should normally take the format XX_name, with XX being a number
followed by an underscore and name.
The order the entry appears on the grub menu is based on numerical ordering of the
files in /etc/grub.d. Executable files in the /etc/grub.d folder beginning with an
alphabetic character are placed in order following numerical entries.
The file must be made executable by typing in a terminal
A sample custom entry. This file creates menu items for running a SystemRescueCD
installation on sdb10 and a custom kernel on sda1.
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". The fifth partition on sda is
sda5).
https://wiki.ubuntu.com/Grub2#Dual-b… 10/18
9/4/2010 Grub 2 - Ubuntu Wiki
4e84-bdbb-91b83f018f98 ro
initrd /boot/initrd.img-2.6.28-11-generic
}
The line "echo "Adding SystemRescueCD" >&2" is not required. Including it in the
file allows this line to be seen in the terminal when "update-grub" is executed. It
provides visual feedback that the entry has been found and entered. The entry, if in the
correct format, will be inserted in grub.cfg whether or not this line is included in the
file.
Note: This file is returned to 'read-only' status and user inputs are overwritten
anytime the "update-grub" command is run.
Automatically.
Kernels removed by Synaptic will automatically update grub.cfg and no user
action is required.
Other operating systems which have been removed from the computer will also
be removed from the menu once "update-grub" is run as root.
Manually.
To prevent a file in /etc/grub.d from adding items to the menu, remove the
executable bit or remove the applicable file.
memtest86+: If you don't want to have memtest86+ displayed in your menu,
run sudo chmod -x /etc/grub.d/20_memtest86+. The file
will remain but will not be acted upon by update-grub.
Recovery mode: If you don't want Recovery mode entries for your linux
kernels, edit /etc/default/grub and add this line:
GRUB_DISABLE_LINUX_RECOVERY=true
https://wiki.ubuntu.com/Grub2#Dual-b… 11/18
9/4/2010 Grub 2 - Ubuntu Wiki
Theming
As of version 1.96 of GRUB 2, theme support is not enabled
The GRUB graphical menu supports themes that can customize the layout and appearance of
the GRUB boot menu. The theme is configured through a plain text file that specifies the
layout of the various GUI components (including the boot menu, timeout progress bar, and
text messages) as well as the appearance using colors, fonts, and images.
This is Colin Bennett's Google Summer of Code project. The GRUB 2 graphical menu
project aims to create a highly customizable graphical menu system for the GNU GRUB
bootloader.
Splash Images
Take a look at this thread on Grub 2 Splash Images
Background Colors/Image
Background colors and images are configured in a script located in /etc/grub.d/ if you look in
there you will find a file called 05_debian_theme which is the default color scheme for
GRUB 2. Now to create your own color scheme you have a few options, you can copy and
edit the default 05_debian_theme or create your own script.
All the files in /etc/grub.d/ are run in order, so if you have 2 theme files, 05_debian_theme
and 06_mytheme, the latter (06_mytheme) will be run last, which will be the background you
see.
$ sudo cp /etc/grub.d/05_debian_theme
/etc/grub.d/05_debian_theme.BACKUP
https://wiki.ubuntu.com/Grub2#Dual-b… 12/18
9/4/2010 Grub 2 - Ubuntu Wiki
$ sudo nano /etc/grub.d/05_debian_theme
Commands
As GRUB 2 has been totally re-written, there are now some commands you might be used to
in GRUB legacy that don't exist in GRUB 2. Take a look at the Grub 2 Command's List.
SHIFT now allows you to interrupt 'sleep --interruptible', for consistency with the quick-
boot scheme.
$ sudo fdisk -l
Now, you need to remember which device listed is your linux distribution, for
reference, /dev/sda1 will be used. Now we need to mount the filesystem to /mnt
If you have /boot on a separate partition, that need's to be mounted aswell. For
reference, /dev/sda2 will be used.
If you have /var on a separate partition, that need's to be mounted aswell. For
reference, /dev/sda3 will be used.
$ sudo mount /dev/sda3 /mnt/var Make sure you don't mix these up, pay
attention to the output of FDISK
Now mount the rest of your devices and some other things needed in the chroot
https://wiki.ubuntu.com/Grub2#Dual-b… 13/18
9/4/2010 Grub 2 - Ubuntu Wiki
$ sudo mount --bind /sys /mnt/sys
You should be chroot'd into your system as root, you can now run commands as root,
without the need for sudo.
Now you need to edit the /etc/default/grub file to fit your system
$ nano /etc/default/grub
When that is done you need to run update-grub to create the configuration file. If you
have a separate /boot partition you need to mount it first!
$ update-grub
To install GRUB 2 to the MBR, next you need to run grub-install /dev/sda
$ grub-install /dev/sda
Now you can unmount the root system. (But if you have a separate boot partition
which you mounted earlier, you have to unmount this first, or you will get a "device
busy" error message.)
And you should be free to restart your system right into GRUB 2 and then into your
system installation.
If you had alternate OS entries, update-grub might say "Cannot find list of partitions!".
Ignore it and continue - once you can boot into your linux installation, do so and then rerun
update-grub and grub-install /dev/sda as root.
Credits to
http://mundogeek.net/archivos/2009/12/08/recuperar-grub-2/ for the enlightening post &
http://www.webupd8.org/2009/12/how-to-recover-grub2-linux.html for the awesome
translation.
Errors
#GRUB_HIDDEN_TIMEOUT=3
GRUB_TIMEOUT=XXX <---Make sure you put in a timeout value
here.
$ sudo update-grub
Dual-booting
Following this thread on the forums, users have seemed to come up with a Karmic work
around for fixing your dual-boot problems...
--no-floppy
https://wiki.ubuntu.com/Grub2#Dual-b… 15/18
9/4/2010 Grub 2 - Ubuntu Wiki
It seems after an update yesterday Monday June 22, 2009 that some users are experiencing
a --no-floppy error. There is a simple workaround to this. Check out this thread
Once you get into your system you need to re-install grub to your device, mine was sda
Floating sleeps was built in, but not configured in the newest version of busybox, here's the
fix.
https://wiki.ubuntu.com/Grub2#Dual-b… 16/18
9/4/2010 Grub 2 - Ubuntu Wiki
$ sudo apt-get update && sudo apt-get upgrade
Update initramfs
Error 11
First, obtain a copy of the latest Ubuntu LiveCD and boot it. Please note that the
Live CD must be the same as the system you are fixing - either 32-bit or 64-bit
(if not then the chroot will fail).
Open a terminal and type
$ sudo fdisk -l
Now, you need to remember which device listed is your linux distribution, for
reference, /dev/sda1 will be used. Now we need to mount the filesystem to /mnt
If you have /boot on a separate partition, that need's to be mounted aswell. For
reference, /dev/sda2 will be used.
If you have /var on a separate partition, that need's to be mounted aswell. For
reference, /dev/sda3 will be used.
https://wiki.ubuntu.com/Grub2#Dual-b… 17/18
9/4/2010 Grub 2 - Ubuntu Wiki
$ sudo mount /dev/sda3 /mnt/var
Make sure you don't mix these up, pay attention to the output of FDISK
Now mount the rest of your devices and some other things needed in the chroot
You should be chroot'd into your system as root, you can now run commands as root,
without the need for sudo.
Tell grub what drive it should install itself to (press space bar to select a drive and don't
continue without selecting one)
$ dpkg-reconfigure grub-pc
And you should be free to restart your system right into GRUB 2 and then into your
system installation.
Links
Grub2 (Community Documentation)
HomePage of GRUB project
Wiki list of test suitable hardware
CategoryBootAndPartition CategoryDocumentation
https://wiki.ubuntu.com/Grub2#Dual-b… 18/18
9/4/2010 Grub 2 - Ubuntu Wiki
$ sudo umount /mnt/sys
$ sudo umount /mnt
And you should be free to restart your system right into GRUB 2 and then into your
system installation.
Links
Grub2 (Community Documentation)
HomePage of GRUB project
Wiki list of test suitable hardware
CategoryBootAndPartition CategoryDocumentation
https://wiki.ubuntu.com/Grub2#Dual-b… 19/18