From 483838e91e2130bf788313924ab2d5bbffb4aa2b Mon Sep 17 00:00:00 2001 From: Bruce Dubbs Date: Mon, 20 Jun 2011 22:58:34 +0000 Subject: [PATCH] Update to GRUB-1.99 git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@9563 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- chapter01/changelog.xml | 10 ++ chapter06/grub.xml | 7 +- chapter08/grub.xml | 245 +++++++++++----------------------------- general.ent | 4 +- packages.ent | 12 +- 5 files changed, 90 insertions(+), 188 deletions(-) diff --git a/chapter01/changelog.xml b/chapter01/changelog.xml index 0ae3d024c..e4e7087fa 100644 --- a/chapter01/changelog.xml +++ b/chapter01/changelog.xml @@ -36,6 +36,16 @@ --> + + 2011-06-20 + + + [bdubbs] - Update to grub-1.99. Fixes + #2818. + + + + 2011-06-19 diff --git a/chapter06/grub.xml b/chapter06/grub.xml index dcea697d6..16bf69797 100644 --- a/chapter06/grub.xml +++ b/chapter06/grub.xml @@ -43,10 +43,9 @@ Prepare GRUB for compilation: ./configure --prefix=/usr \ - --sysconfdir=/etc \ - --disable-grub-emu-usb \ - --disable-grub-fstest \ - --disable-efiemu \ + --sysconfdir=/etc \ + --disable-grub-emu-usb \ + --disable-efiemu \ --disable-werror The --disable switches minimize what is built by disabling features diff --git a/chapter08/grub.xml b/chapter08/grub.xml index 58178d6fc..6c24381c9 100644 --- a/chapter08/grub.xml +++ b/chapter08/grub.xml @@ -19,25 +19,29 @@ Introduction - Boot loading can be a complex area, so a few cautionary - words are in order. Be familiar with the current boot loader and any other - operating systems present on the hard drive(s) that need to be - bootable. Make sure that an emergency boot disk is ready to + Configuring GRUB incorrectly can render your system + inoperable without an alternate boot device such as a CD-ROM. This + section is not required to boot your LFS system. You may just + want to modify your current boot loader, e.g. Grub-Legacy, GRUB2, or + LILO. + + + Ensure that an emergency boot disk is ready to rescue the computer if the computer becomes - unusable (un-bootable). + unusable (un-bootable). If you do not already have a boot device, + you can create one. In order for the procedure below to work, + you need to jump ahead to BLFS and install + xorriso. - The procedure involves writing some special GRUB files to specific - locations on the hard drive. We highly recommend creating a GRUB boot - floppy diskette as a backup. Insert a blank floppy diskette and run the - following commands: +cd /tmp && +grub-mkrescue --output=grub-img.iso && +xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso -cd /tmp -grub-mkrescue --output=grub-img.iso -dd if=grub-img.iso of=/dev/fd0 bs=1440 count=1 + - Alternatively, a boot CD can be created by using your host system's - CD burning tools to burn the grub-img.iso on to a - blank CD. + + GRUB Naming Conventions GRUB uses its own naming structure for drives and partitions in the form of (hdn,m), where n @@ -59,6 +63,16 @@ dd if=grub-img.iso of=/dev/fd0 bs=1440 count=1 grub-mkdevicemap --device-map=device.map cat device.map + + + + Setting Up the Configuration + + GRUB works by writing data to the first physical track of the + hard disk. This area is not part of any file system. The programs + there access GRUB modules in the boot partition. The default location + is /boot/grub/. + The location of the boot partition is a choice of the user that affects the configuration. One recommendation is to have a separate small (suggested size is 100 MB) partition just for boot information. That way @@ -73,10 +87,6 @@ cat device.map Using the current lfs partition will also work, but configuration for multiple systems is more difficult. - - - - Setting Up the Configuration Using the above information, determine the appropriate designator for the root partition (or boot partition, if a separate @@ -85,142 +95,7 @@ cat device.map class="partition">sda2. Install the GRUB files into /boot/grub: - -grub-install --grub-setup=/bin/true /dev/sda - - We use --grub-setup=/bin/true for now to prevent updating the - Master Boot Record (MBR). In this way, we can test our installation - before committing to a change that is hard to revert. - - Generate /boot/grub/grub.cfg: - -grub-mkconfig -o /boot/grub/grub.cfg - - Here grub-mkconfig uses the files in /etc/grub.d/ to determine the contents - of this file. The configuration file will look something like: -# -# DO NOT EDIT THIS FILE -# -# It is automatically generated by /usr/sbin/grub-mkconfig using templates -# from /etc/grub.d and settings from /etc/default/grub -# - -### BEGIN /etc/grub.d/00_header ### -set default=0 -set timeout=5 -### END /etc/grub.d/00_header ### - -### BEGIN /etc/grub.d/10_linux ### -menuentry "GNU/Linux, Linux &linux-version;-lfs-&version;" { - insmod ext2 - set root=(hd0,2) - search --no-floppy --fs-uuid --set 915852a7-859e-45a6-9ff0-d3ebfdb5cea2 - linux /boot/vmlinux-&linux-version;-lfs-&version; root=/dev/sda2 ro -} -menuentry "GNU/Linux, Linux &linux-version;-lfs-&version;" (recovery mode)" { - insmod ext2 - set root=(hd0,2) - search --no-floppy --fs-uuid --set 915852a7-859e-45a6-9ff0-d3ebfdb5cea2 - linux /boot/vmlinux-&linux-version;-lfs-&version; root=/dev/sda2 ro single -} -menuentry "GNU/Linux, Linux 2.6.28-11-server" { - insmod ext2 - set root=(hd0,2) - search --no-floppy --fs-uuid --set 6b4c0339-5501-4a85-8351-e398e5252be8 - linux /boot/vmlinuz-2.6.28-11-server root=UUID=6b4c0339-5501-4a85-8351-e398e5252be8 ro - initrd /boot/initrd.img-2.6.28-11-server -} -menuentry "GNU/Linux, Linux 2.6.28-11-server (recovery mode)" { - insmod ext2 - set root=(hd0,2) - search --no-floppy --fs-uuid --set 6b4c0339-5501-4a85-8351-e398e5252be8 - linux /boot/vmlinuz-2.6.28-11-server root=UUID=6b4c0339-5501-4a85-8351-e398e5252be8 ro single - initrd /boot/initrd.img-2.6.28-11-server -} -### END /etc/grub.d/10_linux ### - -### BEGIN /etc/grub.d/30_os-prober ### -### END /etc/grub.d/30_os-prober ### - -### BEGIN /etc/grub.d/40_custom ### -# This file provides an easy way to add custom menu entries. Simply type the -# menu entries you want to add after this comment. Be careful not to change -# the 'exec tail' line above. -### END /etc/grub.d/40_custom ### - - - - - Even though there is a warning not to edit the file, you - can do so as long as you do not re-run - grub-mkconfig. - - The search lines are generally not - useful for LFS systems as that command only sets an internal GRUB - variable used to find the kernel image. The set root - command provides the same capability without the overhead of - searching. - - The set root and - insmod ext2 commands can be moved out of the - menuentry sections to apply to all sections of the file. - This leads to a simple section like: - - -menuentry "Linux &linux-version;-lfs-&version;" { -linux /boot/vmlinux-&linux-version;-lfs-&version; root=/dev/sda2 ro -} - - - - - Passing a UUID to the kernel requires an initial ram disk - (initrd) not built by LFS. - - If the /boot partition is installed - on a separate partition, the linux and initrd lines should not have the - string /boot prefixed to the file - names. - - In this example the kernel files for a Ubuntu - installation are also found in /boot. - - - - - - - - Testing the Configuration - - The core image of GRUB is also a Multiboot kernel, so if you already - have GRUB Legacy loaded you can load - GRUB-&grub-version; through your old boot loader. To accomplish this, you - will need to exit the chroot environment now and - re-enter it in the next section to finish the few remaining portions of - the book. - -/sbin/reboot -... -grub> root (hd0,1) -grub> kernel /boot/grub/core.img -grub> boot - - Note that the GRUB commands above are assumed to be GRUB Legacy. - At this point the GRUB prompt will appear (very similar to GRUB Legacy) and - you can explore the interface or boot to one of the systems in the grub.cfg - file. - - - - - Updating the Master Boot Record - - If you tested the GRUB configuration as specified above, re-enter - the chroot environment. + class="directory">/boot/grub and set up the boot track: The following command will overwrite the current boot loader. Do not @@ -228,32 +103,50 @@ grub> boot boot manager to manage the Master Boot Record (MBR). - Update the MBR with: +grub-install /dev/sda -grub-setup '<DEVICE>' + grub-install is a script and calls another + program, grub-probe, that may fail with a message "cannot stat `/dev/root'". + If so, create a temporary symbolic link from your root partition to /dev/root: - Change the DEVICE above to your boot disk, normally '(hd0)' or /dev/sda. - If using (hd0) be sure to escape the parentheses with backslashes or single - quotes to prevent the shell from interpreting them as a sub-shell. +ln -sv /dev/sda2 /dev/root - This program uses the following defaults and are correct if you did not - deviate from the instructions above: + The symbolic link will only be present until the system is rebooted. + The link is only needed for the installation procedure. + - - boot image - boot.img - core image - core.img - directory - /boot/grub - device map - device.map - default root setting - guessed - + - The root setting is the default value if a 'set root' - instruction is not found in grub.cfg. This is the partition that is - searched for the kernel and other supporting files. It is different from - the 'root=' parameter on the 'linux' line in the configuration line. The - latter is the partition the kernel mounts as '/'. In the example grub.cfg - above, both values point to /dev/sda2, but if there is a separate boot - partition, they will be different. + + Creating the Configuration File + + Generate /boot/grub/grub.cfg: + + cat > /boot/grub/grub.cfg << "EOF" +# Begin /boot/grub/grub.cfg +set default=0 +set timeout=5 + +insmod ext2 +set root=(hd0,2) + +menuentry "GNU/Linux, Linux &linux-version;-lfs-&version;" { + linux /boot/vmlinux-&linux-version;-lfs-&version; root=/dev/sda2 ro +} +EOF + + GRUB is an extremely powerful program and it provides a tremendous + number of options for booting from a wide variety of devices, operating + systems, and partition types. There are also many options for customization + such as graphical splash screens, playing sounds, mouse input, etc. The + details of these options are beyond the scope of this introduction. + + There is a command, grub-mkconfig that + can write a configuration file automatically. It uses a set of scripts in + /etc/grub.d/ and will destroy any customizations that you make. These scripts + are designed primarily for non-source distributions and are not recommended for + LFS. If you install a commercial Linux distribution, there is a good chance + that this program will be run. Be sure to back up your grub.cfg file. diff --git a/general.ent b/general.ent index f26720c1d..ca6d156b1 100644 --- a/general.ent +++ b/general.ent @@ -1,5 +1,5 @@ - - + + diff --git a/packages.ent b/packages.ent index 421ddc536..e5ca5b070 100644 --- a/packages.ent +++ b/packages.ent @@ -239,13 +239,13 @@ - - - - + + + + - - + +