Version 9 (modified by Justin R. Knierim, 5 years ago) (diff)


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

Grub2 for CLFS Builds

Needed Files


Changes for Boot Method

These changes apply if you are using the Boot Method.

Building Grub2

./configure --prefix=/usr \
   --build=${CLFS_HOST} --host=${CLFS_TARGET}
make DESTDIR=${CLFS} install

Changes for Final-System Section

These changes apply to the Final-System section of the book.

Building Grub2

The 'make check' is optional.

./configure --prefix=/usr --sysconfdir=/etc
make check
make install

Installing Grub2

To install Grub2 onto the MBR you need to run the following command. Remember to substitute 'sda' for your boot hard drive.

grub-install /dev/sda

Creating the Boot Menu

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. The hard drive numbers start from zero and the partition numbers from one. For example, partition hda1 is (hd0,1) to GRUB and hdb3 is (hd1,3). 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).

Create a "Boot Menu" for grub by defining the boot menu; ${CLFS} is only required if you are using the Boot Method. The menu below uses the second partition on the first hard drive, (hd0,2); remember to substitute this for your hard drive and partition.

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

set default=0
set timeout=5

set root=(hd0,2)
menuentry "Linux" {
  linux /boot/kernel- root=/dev/sda2


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

cat >> ${CLFS}/boot/grub/grub.cfg << "EOF"
menuentry "Microsoft Windows" {
        set root=(hd0,1)
        chainloader +1

Setting the Frame Buffer Resolution

Add the following to the start of your grub.cfg file.

set gfxpayload=1280x800 (put your desired resolution here)
insmod gfxterm
insmod vbe


Gentoo Wiki
Cosmo's Example grub.cfg file