HowTos GrubInstallation
HowTos GrubInstallation
Contents
1. Grub naming conventions
2. Create or edit the configuration file /boot/grub/grub.conf
3. Installing Grub using grub-install
4. Alternative: Installing boot loader only using grub
5. Notes and warnings
1. Using a separate partition for /boot
2. Grub and ext4fs
3. Using the Grub command line from the boot loader
4. Using Grub to boot a Windows partition
6. More information
The 2nd and 3rd steps can be done using a single command, grub-install. Alternatively, the 3rd step can
be done using the grub command.
1. All disks are designated as hd, whether they are IDE (PATA), SATA or SCSI disks, and whether they
would usually be designated using hd or sd.
2. All disks and partitions are numbered starting with 0 rather than 1.
3. Extended partitions are counted from 4, regardless of the actual number of primary partitions on the
hard disk.
4. The first number indicates the disk; the second number (if present) indicates the partition.
Examples:
Example:
(The numbers before each line should not be written. They refer to the explanations after the sample file.)
1 default=0
2 timeout=10
3 splashimage=(hd0,5)/boot/grub/splash.xpm.gz
If you have a separate partition for /boot, see the note below.
Explanations:
1. By default, boot the 1st partition listed below. Remember that Grub starts counting with 0, not 1.
4. Name of 1st possible boot partition. In this case, it's the default boot partition (see line 1).
kernel /boot/vmlinuz-2.6.18-238.19.1.el5.centos.plusPAE
ro
root=/dev/sda6
Location of root partition, using conventional naming system. The root partition can also be identified using
the file system's UUID (universally unique identifier) as follows: root=UUID=134d2a24-2699-4b0c-
823b-1e13633f3b07. CentOS now uses UUIDs by default. You can find a file system's UUID with the
following command: tune2fs -l /dev/sda6.
rhgb
Use graphical boot (Red Hat Graphical Boot). Omit if you want text-only boot.
noquiet
kernel /boot/vmlinuz-2.6.32-26-generic-pae
ro
root=/dev/sda10
Location of root partition, using conventional naming system. See also the comment about UUIDs in line 6.
11. Location of initial ramdisk (initrd or initramfs), using conventional naming system.
Examples:
Command Meaning
Install Grub files in directory /boot/grub of current partition. Install boot
grub-
loader in master boot record of first hard disk. This is the recommended
install /dev/sda
way to install Grub.
grub- Install Grub files in directory /boot/grub of current partition. Install boot
install /dev/sda1 loader in first partition of first hard disk.
grub- Install Grub files in directory /boot/grub of current partition. Install boot
install /dev/sda2 loader in second partition of first hard disk.
1. Do grub.
2. Optionally, do find /boot/grub/stage1 to find which partitions have the required Grub files in
/boot/grub. If you have a separate partition for /boot, do find /grub/stage1 instead.
3. Do root [partition using Grub convention] to indicate the partition which has the Grub
files in /boot/grub and the /boot/grub/grub.conf configuration file.
4. Install the boot loader using setup [location of boot loader using Grub convention].
5. Do quit to leave the Grub programme.
Example:
[root@localhost ~]# grub
Probing devices to guess BIOS drives. This may take a long time.
[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename.]
grub> quit
If you have a separate partition for /boot, the lines starting with root, kernel and initrd in
/boot/grub/grub.conf must be modified as follows:
The line starting with root must indicate the partition for /boot, not the partition for /.
The line starting with kernel must assume that the kernel (vmlinuz) is in /, not in /boot. However,
the command root in that line must indicate the partition for /, not the partition for /boot.
The line starting with initrd must assume that the initial ramdisk (initrd or initramfs) is in /,
not in /boot.
Example:
The /boot partition is /dev/sda1, or hd(0,0). The / partition is /dev/sda2, or hd(0,1). The file
/boot/grub/grub.conf must indicate the following:
5.3. Using the Grub command line from the boot loader
Commands can be given to Grub from the boot loader itself. Type c at the boot menu, and then give Grub the
same commands that would be in the /boot/grub/grub.conf configuration file.
Example:
grub> boot
You can also edit a line in /boot/grub/grub.conf from the Grub boot loader with the e command. For
example, to boot Linux in single-user mode (runlevel 1), edit the line with the kernel command by adding 1
at the end. Then type b to boot.
To boot a Windows partition using Grub, add a "stanza" similar to this one in /boot/grub/grub.conf:
Example:
title Windows
rootnoverify (hd0,0)
makeactive
chainloader +1
6. More information
For complete information on Grub, do info grub.
How to re-install bootstrap code (GRUB)
Troubleshooting GRUB Issues
Information on Grub from RHEL's Installation Guide
Created by YvesBellefeuille
2023-09-11 07:22