wiki:bootloaders/grub2

Version 8 (modified by M.N. Akhiezer, 8 years ago) ( diff )

Made some terminology/capitalisations, consistent across bootloader wiki docs.

Grub2 for CLFS Builds

Needed Files

Grub2 ftp://alpha.gnu.org/gnu/grub/grub-1.97.1.tar.gz

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
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
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 2.6.31.5" {
  linux /boot/kernel-2.6.31.5 root=/dev/sda2
}

EOF

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
}
EOF

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

References

Gentoo Wiki https://wiki.gentoo.org/wiki/GRUB2
Cosmo's Example grub.cfg file http://clfs.org/~cosmo/wiki_files/grub.cfg

Note: See TracWiki for help on using the wiki.