Boot Managers
| GRUB |
|
|
- GRUB (GRand Unified Bootloader)
The configurations described on this page were tested with GNU GRUB 0.92, with GRUB installed to /boot/grub, on a separate boot partition - hda5, which corresponds in grub.conf to (hd0,4)Configuration file
/boot/grub/grub.conf (/boot/grub/menu.lst is a symbolic link to this file)Booting to Windows or DOS
Usage
- The drive numbers and partition numbers for the device names are zero-based:
- (hd0) = hda
- (hd0,0) = hda1
- (hd0,1) = hda2
- (fd0) = fd0 (the first floppy disk drive)
- The partition numbers for extended partitions are counted from 4, regardless of the actual number of primary partitions on the hard drive.
- (hd0,4) = hda5 (the first extended partition of the first hard drive)
- GRUB automatically runs the boot command at the end of a section, if the other commands in that section ran successfully.
- GRUB cannot boot Windows or DOS directly, they have to be chain-loaded.
Examples
Booting to the first partition of the first hard drive.
title Windows 98
rootnoverify (hd0,0)
chainloader +1
makeactive
- If there is more than one primary partition with a version of Windows or DOS installed, the desired one must be unhidden and all others must be hidden.
Booting from a floppy disk, with access to a Windows or DOS partitionExamples
Booting to the second partition of the first hard drive, hiding the first partition of the first hard drive.title DOS
hide (hd0,0)
unhide (hd0,1)
rootnoverify (hd0,1)
chainloader +1
makeactive
ExamplesInstalling GRUB onto the hard disk
Booting from a Windows 98 boot disk, with access to the first partition of the first hard drive, and hiding the second partition on the first hard drive.
In this example, after the following menu choice in GRUB is selected, the user is prompted to insert a Windows 98 boot disk.
title Windows 98 boot disk
pause Insert Windows 98 boot disk, and press <enter>
unhide (hd0,0)
hide (hd0,1)
rootnoverify (fd0)
chainloader +1
UsageCreating a GRUB boot floppy
- If you are not sure on which device the existing grub files were installed:
Examples
- Login as root
- Run /sbin/grub from the command-line
- Type find /boot/grub/stage1
- If that doesn't work (and it may not if a separate boot partition is used), try find /grub/stage1
- To exit grub, type quit
Install grub on the master boot record of the first hard drive (specified by the "setup" command).
In this example, the existing grub files (specified by the "root" command) are located on (hd0,4).
title Install GRUB on MBR of the first hard drive
root (hd0,4)
setup (hd0)
reboot
Install grub on the linux boot partition, which in this example is the first extended partition of the first hard drive (hd0,4) (specified by the "setup" command).
In this example, the existing grub files (specified by the "root" command) are located on (hd0,4).
title Install GRUB on the Linux boot partition
root (hd0,4)
setup (hd0,4)
reboot
ExamplesChanging the colors
Create a GRUB boot floppy (fd0) with the minimal GRUB files necessary; the existing GRUB files on the hard drive (hd0,4) will be used when booting off the floppy.
In this example, the floppy must first be formatted with the ext2 file system; to format the floppy, login as root, insert the floppy, and type /sbin/mke2fs /dev/fd0title Install GRUB on an ext2-formatted floppy disk
pause Insert an ext2 floppy disk, and press <enter>
root (hd0,4)
setup (fd0)
reboot
Create a GRUB boot floppy with a full version of GRUB, including the current grub.conf file.
In this example, the floppy disk is mounted as /mnt/floppy (this directory must already exist on the hard drive), and the existing grub files are located at /boot/grub
Sample bash script
(note: this example applies to Fedora Core 4, with a mount point of /media/floppy used for the floppy drive)
#!/bin/sh
# Format the floppy.
fdformat /dev/fd0
# Create the ext2 file system.
/sbin/mke2fs /dev/fd0
# Mount the floppy.
mount -t ext2 /dev/fd0 /media/floppy
# Copy the grub files
mkdir -p /media/floppy/boot/grub
cp -dfuv /boot/grub/*stage* /media/floppy/boot/grub/
cp -dfuv /boot/grub/device.map /media/floppy/boot/grub/
# Copy grub.conf
cp -dfuv /boot/grub/grub.conf /media/floppy/boot/grub/
# Create a symlink to grub.conf, called menu.lst
ln -sf /media/floppy/boot/grub/grub.conf /media/floppy/boot/grub/menu.lst
# Unmount the floppy.
umount /media/floppy
# Make the floppy bootable.
echo "Run /sbin/grub as root, and issue the following commands:"
echo " root (fd0)"
echo " setup (fd0)"
echo " quit"
Syntax
Usage
- color fg/bg selection-fg/selection-bg
Examples
- Colors: black, blue, green, cyan, red, magenta, brown, light-gray
- Additional foreground colors: dark-gray, light-blue, light-green, light-cyan, light-red, light-magenta, yellow, white
# Set default colors.
color light-gray/blue black/light-gray
# Change the colors for a particular menu choice.
title Linux
color magenta/blue black/magenta
...
Resources
Resources URL:
notes/linux/resources
Sources URL:
notes/linux/sources