Home - News - FAQ - Download - Read - Errata - Lists - IRC - Mirrors - Bootloaders - Machine-Specifics - File Systems - CBLFS - Community - Developer

Grub Legacy for CLFS Builds

Needed Files

Grub Legacy

256-byte inode Patch
EXT4 Patch
Fixes Patch
x86_64 Fixes Patch

Apply the Patches

These patches are required for both the Boot Method and the Final-System sections of the book.

patch -Np1 -i ../grub-0.97-use_mmap-1.patch
patch -Np1 -i ../grub-0.97-fixes-1.patch
patch -Np1 -i ../grub-0.97-256byte_inode-1.patch
patch -Np1 -i ../grub-0.97-ext4-1.patch

Changes for Cross-Tools Section

This build is only required if you're using the Boot Method of the build.

Build Grub Legacy

./configure --prefix=/usr \
   --build=${CLFS_HOST} --host=${CLFS_TARGET}
make DESTDIR=${CLFS} install
mkdir -v ${CLFS}/boot/grub
cp -v ${CLFS}/usr/lib/grub/*/stage{1,2} ${CLFS}/boot/grub

Changes for Final-System Section

This build is only required for the Final-System section of the book.

Build Grub Legacy

The 'make check' is optional.

./configure --prefix=/usr
make check
make install
mkdir -pv /boot/grub
cp -v /usr/lib/grub/*/stage{1,2} /boot/grub

The FHS stipulates that the bootloader's configuration file should be symlinked to /etc/{Bootloader Name}. The bootloader's configuration file is created in the following section. To satisfy this requirement for GRUB, issue the following command:

mkdir -v /etc/grub &&
ln -sv /boot/grub/menu.lst /etc/grub

Installing Grub

GRUB uses its own naming structure for drives and partitions in the form of (hdn,m), where n is the hard drive number and m is the partition number, both starting from zero. For example, partition hda1 is (hd0,0) to GRUB and hdb3 is (hd1,2). In contrast to Linux, GRUB does not consider CD-ROM drives to be hard drives. For example, if using a CD on hdb and a second hard drive on hdc, that second hard drive would still be (hd1).

Using the above information, determine the appropriate designator for the root partition (or boot partition, if a separate one is used). For the following example, it is assumed that the root (or separate boot) partition is hda4.

After running the 'grub' command. tell GRUB where to search for its stage{1,2} files. The Tab key can be used everywhere to make GRUB show the alternatives. Install grub to the MBR and then quit.

root (hd0,3)
setup (hd0)

Creating the Boot Menu

Create a "Boot Menu" for grub by defining the boot menu; ${CLFS} is only required if you are using the Boot Method.

cat > ${CLFS}/boot/grub/menu.lst << "EOF"
# Begin /boot/grub/menu.lst

# By default boot the first menu entry.
default 0

# Allow 30 seconds before booting the default.
timeout 30

# Use prettier colors.
color green/black light-green/black

# The first entry is for CLFS.
title CLFS SVN-20100101
root (hd0,3)
kernel /boot/clfskernel- root=/dev/hda4

Add an entry for the host distribution if desired. It might look like this:

cat >> ${CLFS}/boot/grub/menu.lst << "EOF"
title Red Hat
root (hd0,2)
kernel /boot/kernel-2.6.5 root=/dev/hda3
initrd /boot/initrd-2.6.5

If dual-booting Windows, the following entry will allow booting it:

cat >> ${CLFS}/boot/grub/menu.lst << "EOF"
title Windows
rootnoverify (hd0,0)
chainloader +1
Last modified 5 years ago Last modified on Jun 28, 2019, 9:56:31 AM