Difference between revisions of "GRUB Legacy"

From ArchWiki
Jump to navigation Jump to search
(Added Article summary template)
Line 1: Line 1:
[[Category:Boot process (English)]]
[[Category:Boot process (English)]]
[[Category:HOWTOs (English)]]
[[Category:HOWTOs (English)]]
{{Article summary start}}
{{Article summary text|Covers various aspects of Archlinux's default bootloader, GRand Unified Bootloader (GRUB).}}
{{Article summary heading|Available in languages}}
{{i18n_entry|עברית|GRUB (עברית)}}
{{i18n_entry|עברית|GRUB (עברית)}}
{{i18n_entry|Русский|GRUB (Русский)}}
{{i18n_entry|Русский|GRUB (Русский)}}
{{Article summary heading|Related articles}}
GRand Unified Bootloader (GRUB)
{{Article summary wiki|Reinstalling GRUB}}
{{Article summary wiki|Grub configure examples}}
{{Article summary end}}
== Installing Grub package ==
== Installing Grub package ==

Revision as of 15:52, 18 January 2008

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:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary end

Installing Grub package

First install grub with pacman

pacman -Sy grub

Edit the menu.lst with your settings

nano /boot/grub/menu.lst

Note: Use hd[a-z] for ide and sd[a-z] for scsi and sata

Here is mine for example:

# Config file for GRUB - The GNU GRand Unified Bootloader
# /boot/grub/menu.lst

#  Linux           Grub
# -------------------------
#  /dev/fd0        (fd0)
#  /dev/hda        (hd0)
#  /dev/hdb2       (hd1,1)
#  /dev/hda3       (hd0,2)

#     +-------------------------------------------------+
#          | 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
#     +-------------------------------------------------+

# general configuration:
timeout   5
default   1
color light-blue/black light-cyan/blue
# boot sections follow
# each is implicitly numbered from 1 in the order of appearance below
# TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line.

# (0) Arch Linux
title  Arch Linux  [cpio]
root   (hd0,0)
kernel /vmlinuz26 root=/dev/sda6 ro vga=773
initrd /kernel26.img

title  Arch Linux  [thinkpad]
root   (hd0,0)
kernel /vmlinuz26thinkpad root=/dev/sda6 ro video=vesafb:off acpi_sleep=s3_bios
initrd /kernel26thinkpad.img

Copy the mounts to mtab

grep -v rootfs /proc/mounts > /etc/mtab

Installing the boot loader into Master Boot Record

Now usually there are two ways to install GRUB. One way is to make a boot disk (on a floppy drive, or cd-rom), and the other way is to install grub directly from a running Arch install. If you are upgrading a version of grub you might want to do the latter because its simpler and faster, but the GRUB website states that doing the boot disk method is safer.

Using the grub-install utility

grub-install -root-directory Mount-Point (hdn) 

Installs grub into the MBR of a hard disc. The option gives the path to the kernel-image, if it is not in /, i.e. in /boot.
(hdn) is a disc, where n is the number of the disc, starting with 0.


If you have a separate boot partition mounted at /boot, do one of the following

grub-install --root-directory=/boot '(hd0)'
grub-install --root-directory=/boot sda
grub-install --root-directory=/boot hda

If you don't have a separate boot partition, then just run the command without the --root-directory option

 grub-install /dev/sda

Warning GRUB does not understand the naming schemes hda, sda, etc. It views the disk in terms of (hd0), (hd1), etc. This is why one 'must' be careful when using grub-install.

grub-install tries to map the BIOS drives to hda/sda format, and usually it does this correctly. The way to check if this is done correctly is provided by the command after it has finished installing the bootloader. grub-install will print something along the lines of

(fd0) /dev/fd0
(hd0) /dev/hda

You have to check if this mapping is correct. If it is not correct, go to /boot/grub and edit the 'device.map' file so that it is correct. Then re-run the grub-install utility to reinstall GRUB.

Boot loader configuration

The grub configuration is done in this file:

  • (hdn,m) is the partition m on disc n, numbers starting with 0
  • splashimage (hdn,m)/grub/Name.xpm.gz is the splash-image-file
  • default n is the default boot entry, that is choosen after timout for user action
  • timeout m time m to wait in seconds for a user selection, before default is booted
  • password -md5 str encrypted boot password 'str'
  • title str title string 'str' for a boot entry
  • root (hdn,m) base partition, where the kernel is stored to
  • kernel /path ro root=/dev/device initrd /initrd.img use the root option, if the kernel not placed in /
  • makeactive
    chainloader +1
    sets root active and gives booting procedure to its boot-loader (for Windows, f.e.)
  • map (hd0) (hd1)
    map (hd1) (hd0)
    changes primary and secondary disc for a boot, necessary to boot Windows from a secondary disc
  • root (hdn,m,z)
    kernel /boot/loader
    boots the FreeBSD-Partition x
  • default saved remembers each current boot selection and makes it the new default. Place "savedefault" at the end of each boot section, for that you want this feature shall be used.

For those who like eye-candy, there is Graphical GRUB.

Dual booting

These are the two most common ways of configuring the menu.lst file. For more complex uses, click here.

Dual booting with Windows

Add this at the end of your /boot/grub/menu.lst. This assumes that your Windows partition is [s/h]da2.

# (2) Windows XP
title Windows XP
rootnoverify (hd0,1)
chainloader +1

Dual booting with Windows on another hard disk

Add this at the end of your /boot/grub/menu.lst. This assumes that your Windows partition is [s/h]db1.

# (2) Windows XP
title Windows XP
map (hd0) (hd1)
map (hd1) (hd0)
rootnoverify (hd1,0)
chainloader +1

The map function tricks your Windows install into thinking that a second hard drive is the primary.

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 [s/h]da3.

title Other Linux
root (hd0,2)
kernel /boot/vmlinuz (add other options here as required)
initrd /boot/initrd.img (if the other kernel uses/needs one)

Dual booting with other linux distro (Chainloading)

To avoid maintenance nightmare, you might want to chainload the GRUB in the MBR to another bootloader you might have installed in the bootrecord of partition (hd0,2) by example (instead of the MBR). This way the auto-magic stuff of some distro will manage the menu.lst on (hd0,2) (if it is grub) for its own distro and you will boot with all the option needed (like the correct last kernel) without the need to copy/paste some part of that menu.lst into yours.

In our example [1], GRUB is in the MBR and some other bootloader (BL) (be it grub or lilo) is in the Boot Record of (hd0,2).

Then, you simply use in your menu.lst:

title Other Linux distro
root (hd0,2)
chainloader +1

LiLO and GRUB interaction

If you once had used lilo Don't forget to remove it with

pacman -R lilo

as some tasks (f.e. kernel compilation using make all) will make a lilo call, and then lilo is installed over grub. Note that this will not remove lilo from the MBR, but it will be overwritten when you install another bootloader.


GRUB error 15

Make sure that the kernel line has ro in menu.lst.

External Resources