From ArchWiki
Revision as of 18:53, 12 November 2009 by MindTooth (talk | contribs) (→‎Troubleshooting: -> Added a point.)
Jump to navigation Jump to search

Template:Article summary start Template:Article summary text

Template:Article summary heading Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:Article summary end


Warning: The next generation of the GRand Unified Bootloader (GRUB2) is still under development and therefore all usual points apply. GRUB2 may fry your computer, burn your house, make you breakfast or eat your cat. You've been warned! For most people, except those with more exotic configurations, GRUB2 should just work.

Commands – changes between GRUB and GRUB2. You may want to familiarise yourself with these before proceeding. E.g.: "find" has been replaced with "search"

Installing GRUB2 during Arch Linux installation

You need the network configured. Skip de Install Bootloader step and exit. Then

# mount -o bind /dev /mnt/dev
# chroot /mnt bash

And follow the Installing GRUB2 package and Installing or Restoring GRUB to the Master Boot Record below.

Installing GRUB2 package

First install GRUB2 with pacman:

# pacman -Sy grub2

Edit the GRUB2 configuration file with your settings. The 'old' Template:Filename is replaced by a new file called Template:Filename:

# nano /boot/grub/grub.cfg
Note: Use Template:Filename for IDE and Template:Filename for SCSI and SATA.

Here is an example of a simple configuration file:

# Config file for GRUB2 - The GNU GRand Unified Bootloader
# /boot/grub/grub.cfg

#  Linux           Grub
# -------------------------
#  /dev/fd0        (fd0)
#  /dev/sda        (hd0)
#  /dev/sdb2       (hd1,2)
#  /dev/sda3       (hd0,3)

# Timeout for menu
set timeout=5

# Set default boot entry as Entry 0
set default=0

# (0) Arch Linux
menuentry "Arch Linux" {
set root=(hd0,1)
linux /vmlinuz26 root=/dev/sda1 ro
initrd /kernel26.img

## (1) Windows
#menuentry "Windows" {
#set root=(hd0,3)
#chainloader +1

If you do not have a seperate boot-partition, Template:Codeline must be added to Template:Filename. Example:

# (0) Arch Linux
menuentry "Arch Linux" {
set root=(hd0,1)
linux /boot/vmlinuz26 root=/dev/sda1 ro
initrd /boot/kernel26.img

If you use LVM for your /boot add following before menuentries:

insmod lvm

and specify your root in menuentries as:

set root=(your_lvm_group_name-your_lvm_logical_boot_partition_name)


# (0) Arch Linux
menuentry "Arch Linux" {
insmod lvm
set root=(VolumeGroup-lv_root)
linux /vmlinuz26 root=/dev/mapper/VolumeGroup-lv_root ro
initrd /kernel26.img

Installing or Restoring GRUB2 to the Master Boot Record

GRUB2 may be installed from a live environment, or directly from a running Arch install.

In most cases, installing GRUB2 would be as easy as running the grub-install command as root:

# grub-install /dev/sda

where Template:Filename is the destination of the installation (in this case the MBR of the first SATA disc). If you use LVM for your /boot you can install GRUB2 on multiple physical disc.

If this fails with the error:

grub-probe: error: Cannot get the real path of `/dev/fd0'
Auto-detection of a filesystem module failed.
Please specify the module with the option `--modules' explicitly.

Try adding Template:Codeline to the arguments as follows:

# grub-install --recheck /dev/sda

Alternatively, you should be able to install GRUB2 by booting the system and running the grub command as root:

# grub
{this section is still incomplete, some steps should be added!!!}

(GRUB2 doesn't have an interactive prompt)

Boot loader configuration

The GRUB configuration is done in this file:


Be warned this section is incomplete, feel free to put all missing configuration options here!

For UUID entries:

# blkid

This gives you the UUID. We were doing the following command to set the root device:

# root=/dev/device
Instead, replace it with this:
# root=/dev/disk/by-uuid/bc285871-413 .... and so on, for your UUID.

Dual booting

These are the two most common ways of configuring the Template:Filename file. For more complex uses, feel free to add descriptions here.

With other GNU/Linux distributions

This is done exactly the same way that Arch linux is loaded. Here we assume that the other distro is on partition Template:Filename.

menuentry "Other Linux" {
set root=(hd0,2)
linux /boot/vmlinuz (add other options here as required)
initrd /boot/initrd.img (if the other kernel uses/needs one)

With Windows

Add this at the end of your Template:Filename. This assumes that your Windows partition is Template:Filename.

# (2) Windows XP
menuentry "Windows XP" {
set root=(hd0,3)
chainloader +1

Note, that although commonly believed to be the case, Windows 2000 and later versions do not need to be on the first partition to boot. If the Windows partition changes number (i.e. if you after install add a partition before the windows partition), you will need to edit the Windows boot.ini file to reflect the change (see this article for details on how to do that).

With Windows Vista, via EasyBCD and NeoGRUB

Since EasyBCD's NeoGRUB currently can't understand the GRUB v2 menu format, chain-load to it by replacing the contents of your "C:\NST\menu.lst" file with lines similar to the following:

default 0
timeout 1
title       Chainload into GRUB v2
root        (hd0,7)
kernel      /boot/grub/core.img

Tips and tricks

Background Image & Bitmap Fonts

GRUB2 comes with support for background images and bitmap fonts in pf2 format. The unifont font is included in the grub2 package under the filename Template:Filename, or, as only ascii characters under the name Template:Filename. Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware. A configuration sample setting a tga file as background is shown below.

if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode="1024x768x32"
  insmod gfxterm
  insmod vbe
  terminal_output gfxterm
  if terminal_output gfxterm; then true ; else
     terminal gfxterm
insmod tga
background_image /boot/grub/archlinux.tga

Menu Colors

To change the colors in GRUB2 you would specify one option in Template:Filename:

set menu_color_normal=light-blue/black
set menu_color_highlight=light-cyan/blue

These are the default colors for Arch's release of GRUB-legacy. The available colors for GRUB2 are at

Hidden menu

For hiding menu put that code in grub.cfg after picture initialization but before menuentries (e.g. background_image /boot/grub/archlinux.tga).

  set timeout=5
  echo -n "Press ESC to see the menu... "
if sleep --verbose --interruptible 5 ; then
  set timeout=0

Setting the Framebuffer Resolution

To change the framebuffer resolution in grub2, add a line similar to this to the linux line in grub.cfg:

video=vesafb:mode=1024x768-32 vga=790

In the preceeding statement, the format mode=<resolution>-<colordepth> vga=<fbresolution> is used where fbresolution follows the following scheme:

     | 640x480    800x600    1024x768   1280x1024
 256 | 0x301=769  0x303=771  0x305=773   0x307=775
 32K | 0x310=784  0x313=787  0x316=790   0x319=793
 64K | 0x311=785  0x314=788  0x317=791   0x31A=794
 16M | 0x312=786  0x315=789  0x318=792   0x31B=795

Make sure you add the following somewhere, (insmod statements are usually found at the top of the grub.cfg file):

insmod vbe


Any troubleshooting should be added here.

msdos-style Error Message

grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.
            However, blocklists are UNRELIABLE and its use is discouraged.
grub-setup: error: If you really want blocklists, use --force.

This error may occur when you try installing GRUB2 in a VMware container. Read more about it here. Hopefully a fix will be provided soon.


I couldn't figure out how to uninstall grub1, and install grub2 to the MBR, as it isn't being booted by default. It is still booting grub1. So, an easy work-around, is rename Template:Filename or whatever, to Template:Filename (in /boot/grub/) and for each menu entry that you would like to use grub2, at the end type Template:Codeline. This will tell grub1 to forward control to grub2. This is an ugly hack though, so I advise setting the Template:Filename's timout as 0, otherwise the total timeout would be grub1's time out + grub2's which, for me would equal more than 18 seconds, which is quite a bit.

P.S. hopefully someone figures out how to pry grub1's dead fingers off of my MBR, and place grub2 on it :) .

In my case it had to do with my boot partition. Say boot-partition is Template:Codeline and your root is Template:Codeline (grub2 naming). grub-setup searches for Template:Filename. Just because it's on Template:Filename, it is unable to find it. So I copied the grub-folder to my root partition and everything worked fine:

E.g. (as root:)

# mount /boot
# cp -a /boot/grub /
# umount /boot
# mv /grub /boot/
# grub-install /dev/sda

More Resources