7.22. Making the CLFS System Bootable

You are nearly ready to boot to the new temporary system. One of the last things to do is to ensure that the system can be booted. The instructions below apply only to x86_64 machines on which lilo is going to be installed. Information on using a pre-installed Grub on machines currently running as x86 or x86_64 multilib should be available in the usual resource-specific locations for those architectures. If you have installed an x86 version of lilo, these instructions should be modified to refer to the lilo and keytab-lilo.pl commands you installed on the host system.

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 “rescue” the computer if the computer becomes unusable (un-bootable).

If you have multiple systems on your machine using a different bootloader such as grub, you may prefer to use that instead - consult the appropriate documentation. The rest of this section assumes you are going to use lilo.

Earlier, we compiled and installed the Lilo boot loader software in preparation for this step. The procedure involves writing a boot image to a specific location on the hard drive. If you have a floppy disk drive, or if you have installed a cd recording program, we highly recommend using mkrescue to create a Lilo boot floppy, or CD (using e.g. dvdrecord from dvdrtools) as a test and as a backup.

Normally, you interact with lilo by using the cursor and enter keys to select from the available option(s), but sometimes it is necessary to add other boot options, such as e.g. 'init=/bin/bash' to debug boot failures. The more your keyboard layout differs from the US qwerty layout, the harder it will be to type boot options unless lilo knows about your keyboard layout. So, we will create a key table for Lilo (.ktl) file - at one point in the documentation these are referred to as .klt files, which may be a typo, but has been followed by some distros. The name, and location, are not important but it is conventional to put these in /boot with the name representing the key layout. For a British keyboard layout, the following command will achieve this:

keytab-lilo.pl uk >i${LFS}/boot/uk.ktl

The argument to the command is the name of the keymap, or if necessary you can specify the full path to the keymap. Use whatever is appropriate for your keyboard.

The next step is to create /etc/lilo.conf

cat > ${LFS}/etc/lilo.conf << "EOF"
# Begin /etc/lilo.conf
# lilo.conf
#
# global options
boot=/dev/<bootdisk>
keytable=/boot/<keytable>
lba32
map=/boot/map
prompt

# set the name of the default image to boot
default=lfs

# define an image
image=/boot/lfskernel
    label=lfs
    root=/dev/<partition>
    read-only
# optionally add parameters to pass, e.g.
#   append="video=radeonfb:1024x768-16@70"

# if you had an existing system, you could
# add its details here.
EOF

Replace <bootdisk> with the name of the disk (or partition) on which the boot sector is to be written, e.g. sda. Replace <keytable> with the name of the keytable file you created, and <partition> with the name of the root partition for the new system.

[Warning]

Warning

The following command will overwrite any current boot loader. Do not run the command if this is not desired. If you have cross-compiled on a different machine from the target, you must install the bootloader on the target machine, the installed boot block is not a file which can be copied with tar.

Run Lilo:

/tools/bin/lilo-static -v
[Note]

Note

People who have been used to GRUB need to be aware that lilo works differently - in particular, you cannot edit the available choices as you can in the grub shell, and lilo records the block addresses of the kernels into the boot blocks each time /sbin/lilo is run. This means that when you compile a new kernel, you have to add it to /etc/lilo.conf and rerun /sbin/lilo. It also means that if you recompile an existing kernel and save it to the same name you still have to rerun /sbin/lilo in case it now occupies different blocks on the filesystem.