| 1 | = Grub Legacy for CLFS Builds = |
| 2 | |
| 3 | == Needed Files == |
| 4 | |
| 5 | Grub Legacy [[ftp://alpha.gnu.org/gnu/grub/grub-0.97.tar.gz]][[BR]] |
| 6 | |
| 7 | 256-byte inode Patch [[http://patches.cross-lfs.org/dev/grub-0.97-256byte_inode-1.patch]][[BR]] |
| 8 | EXT4 Patch [[http://patches.cross-lfs.org/dev/grub-0.97-ext4-1.patch]][[BR]] |
| 9 | Fixes Patch [[http://patches.cross-lfs.org/dev/grub-0.97-fixes-1.patch]][[BR]] |
| 10 | x86_64 Fixes Patch [[http://patches.cross-lfs.org/dev/grub-0.97-use_mmap-1.patch]] |
| 11 | |
| 12 | == Apply the patches == |
| 13 | |
| 14 | These patches are required for both the boot method and the Final-System sections of the book. |
| 15 | |
| 16 | {{{ |
| 17 | patch -Np1 -i ../grub-0.97-use_mmap-1.patch |
| 18 | patch -Np1 -i ../grub-0.97-fixes-1.patch |
| 19 | patch -Np1 -i ../grub-0.97-256byte_inode-1.patch |
| 20 | patch -Np1 -i ../grub-0.97-ext4-1.patch |
| 21 | }}} |
| 22 | |
| 23 | |
| 24 | == Changes for Cross-Tools Section == |
| 25 | |
| 26 | This build is only required if you're using the Boot Method of the build. |
| 27 | |
| 28 | === Build Grub Legancy === |
| 29 | |
| 30 | {{{ |
| 31 | |
| 32 | ./configure --prefix=/usr \ |
| 33 | --build=${CLFS_HOST} --host=${CLFS_TARGET} |
| 34 | make |
| 35 | make DESTDIR=${CLFS} install |
| 36 | mkdir -v ${CLFS}/boot/grub |
| 37 | cp -v ${CLFS}/usr/lib/grub/*/stage{1,2} ${CLFS}/boot/grub |
| 38 | }}} |
| 39 | |
| 40 | == Changes to Final-Sysyem section == |
| 41 | |
| 42 | Thid build is only required for the final-system section of the book. |
| 43 | |
| 44 | === Build Grub Legancy === |
| 45 | |
| 46 | The 'make check' is optional. |
| 47 | |
| 48 | {{{ |
| 49 | ./configure --prefix=/usr |
| 50 | make |
| 51 | make check |
| 52 | make install |
| 53 | mkdir -pv /boot/grub |
| 54 | cp -v /usr/lib/grub/*/stage{1,2} /boot/grub |
| 55 | }}} |
| 56 | |
| 57 | |
| 58 | 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: |
| 59 | {{{ |
| 60 | mkdir -v /etc/grub && |
| 61 | ln -sv /boot/grub/menu.lst /etc/grub |
| 62 | }}} |
| 63 | |
| 64 | |
| 65 | == Installing Grub == |
| 66 | 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). |
| 67 | |
| 68 | 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. |
| 69 | |
| 70 | 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. |
| 71 | |
| 72 | {{{ |
| 73 | grub |
| 74 | root (hd0,3) |
| 75 | setup (hd0) |
| 76 | quit |
| 77 | }}} |
| 78 | |
| 79 | === Creating the Boot Menu === |
| 80 | |
| 81 | Create a "Boot Menu" for grub by defining the boot menu, ${CLFS} is only required if you are using the boot method. |
| 82 | |
| 83 | {{{ |
| 84 | cat > ${CLFS}/boot/grub/menu.lst << "EOF" |
| 85 | # Begin /boot/grub/menu.lst |
| 86 | |
| 87 | # By default boot the first menu entry. |
| 88 | default 0 |
| 89 | |
| 90 | # Allow 30 seconds before booting the default. |
| 91 | timeout 30 |
| 92 | |
| 93 | # Use prettier colors. |
| 94 | color green/black light-green/black |
| 95 | |
| 96 | # The first entry is for CLFS. |
| 97 | title CLFS SVN-20100101 |
| 98 | root (hd0,3) |
| 99 | kernel /boot/clfskernel-2.6.30.5 root=/dev/hda4 |
| 100 | EOF |
| 101 | }}} |
| 102 | |
| 103 | Add an entry for the host distribution if desired. It might look like this: |
| 104 | {{{ |
| 105 | cat >> ${CLFS}/boot/grub/menu.lst << "EOF" |
| 106 | title Red Hat |
| 107 | root (hd0,2) |
| 108 | kernel /boot/kernel-2.6.5 root=/dev/hda3 |
| 109 | initrd /boot/initrd-2.6.5 |
| 110 | EOF |
| 111 | }}} |
| 112 | |
| 113 | |
| 114 | If dual-booting Windows, the following entry will allow booting it: |
| 115 | {{{ |
| 116 | cat >> ${CLFS}/boot/grub/menu.lst << "EOF" |
| 117 | title Windows |
| 118 | rootnoverify (hd0,0) |
| 119 | chainloader +1 |
| 120 | EOF |
| 121 | }}} |