Difference between revisions of "GRUB"

From ArchWiki
Jump to: navigation, search
(Introduction)
(Tips and tricks: add background/bitmap font to tips/tricks)
Line 129: Line 129:
  
 
==Tips and tricks==
 
==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 unicode.pf2, or, as only ascii characters under the name ascii.pf2. 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
 +
  fi
 +
fi
 +
insmod tga
 +
background_image /boot/grub/archlinux.tga
  
 
===Menu Colors===
 
===Menu Colors===

Revision as of 16:14, 11 May 2009

Template:Article summary start Template:Article summary text

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

Introduction

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"

http://grub.enbug.org/CommandList

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

# DEVICE NAME CONVERSIONS
#
#  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
}

Installing or Restoring GRUB to the Master Boot Record

GRUB 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 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:

/boot/grub/grub.cfg

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

For UUID entries:

# blkid

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.

Dual booting 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).

Dual booting with other linux distros

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)
}

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 unicode.pf2, or, as only ascii characters under the name ascii.pf2. 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
  fi
fi
insmod tga
background_image /boot/grub/archlinux.tga

Menu Colors

To change the colors in GRUB2 you would specify two options 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 are undocumented as of yet, but they probably match GRUB-legacy's colors.

Troubleshooting

Any troubleshooting should be added here.

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 too 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