1. Context 9 License Of This Document 1.106.1 2 5 1.106.1 Boot the system Weight 3 Linux Professional Institute Certification — 102 1 Context Topic 106 Boot, Initialization, Shutdown and Runlevels [6] 1.106.1 Boot the system [3] 1.106.2 Change runlevels and shutdown or reboot system [3] Angus Lees gus@inodes.org Nick Urbanik nicku@nicku.org This document Licensed under GPL—see section 9 2 Objective Description of Objective Candidates should be able to guide the system through the booting process. This includes giving commands to the boot loader and giving options to the kernel at boot time, and checking the events in the log files. Key files, terms, and utilities include: 2005 July Outline dmesg — command to show kernel message ring buffer /var/log/messages — main syslog file Contents 1 2 3 4 5 Context Objective Boot Process How BIOS finds boot loader Boot Loaders 5.1 LILO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2 GRUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3 Other boot loaders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chaining Boot Loaders dmesg /etc/modules.conf 2 2 2 3 3 3 4 4 4 /etc/conf.modules or /etc/modules.conf — modprobe configuration file LILO — older bootloader system, less used now GRUB — newer, more flexible bootloader system • Note that with Red Hat systems, 2.6 kernels use the file /etc/modprobe.conf, not /etc/modules.conf • The name /etc/conf.modules has been out of favour for some years 3 Boot Process • Machine powers up, BIOS POST, spin up SCSI drives, etc Booting 6 7 8 5 5 • BIOS boots boot loader • (Boot loader may load its “second stage” from somewhere else) 4. How BIOS finds boot loader 1.106.1 3 5.2 GRUB 1.106.1 4 – e.g., grub loads /boot/grub/stage2 • Boot loader loads Linux kernel • Linux kernel starts up, detects hardware, etc • Linux kernel creates a ram disk with kernel modules from initrd image file – The drivers in the /boot/initrd.img file are often needed to access the hard disk. • After loading the • Linux kernel mounts / • Linux kernel starts init(8) • init(8) starts up rest of system • lilo(8) install command generates suitable assembly code and installs it into either the MBR or a partition. Configured through /etc/lilo.conf • Remembers actual disk blocks of kernel and uses that to access the file directly (using BIOS disk routines). • Because the calculations are done at install time, LILO can get confused by changes in disk configuration. 5.2 GRUB Boot Loaders • The Grand United boot loader. • Unlike LILO, GRUB understands some partition formats and reads files through “normal” means. • GRUB has drivers for a number of different file systems • depends on BIOS to be able to access the hard disk 4 How BIOS finds boot loader • (i386-specific) • BIOS boots Master Boot Record (MBR), located at the beginning of the disk. • Usual DOS MBR looks for “active” partition and loads the boot loader found in that partition. • You can either install your boot loader – in the MBR, replacing the DOS boot loader, or – use a DOS-compatible boot loader and install your boot loader in the active partition. Finding the boot loader • Reads the menu file /boot/grub/menu.lst directly from the hard disk • No need to change MBR when install a new kernel 5.3 Other boot loaders Boot loaders • CDROMs often use isolinux as the bootloader • loadlin allows booting Linux after having booted MSDOS. 6 Chaining Boot Loaders • One bootloader can load another bootloader • This is how GRUB or LILO start Windows – Windows has its own bootloader at the start of its partition – We tell GRUB or LILO to “chainload” that boot loader • It is often useful to have one GRUB bootloader start another bootloader 5 Boot Loaders Chaining Boot loaders 5.1 LILO Boot Loaders • “Usual” i386 boot loader – at least it was a few years ago. 7. dmesg 1.106.1 5 – For example, if you have several distributions on one disk, have one’s GRUB install its stage1 into the MBR – Other distributions install GRUB at start of their partition – The first GRUB chainloads the other GRUBs – Keeps maintenance local within each distribution 7 dmesg • dmesg(8) gives you the last 16k of kernel messages. • This is written to /var/log/dmesg to refer to after syslog starts up • syslog gathers messages from many daemons as well as the kernel, and sends them to /var/log/messages Snarfing kernel output 8 /etc/modules.conf • Configuration for modprobe(8) • AKA /etc/modules.conf, or with the 2.6 kernel on Red Hat/Fedora systems, /etc/modprobe.conf – Used to be called /etc/conf.modules till people realised that seems back to front • Gives kernel module options, module aliases and a few more exotic options (like module pre/post load commands). /etc/modules.conf 9 License Of This Document License Of This Document Copyright c 2005, 2003 Angus Lees and Nick Urbanik . Permission is granted to make and distribute verbatim copies or modified versions of this document provided that this copyright notice and this permission notice are preserved on all copies under the terms of the GNU General Public License as published by the Free Software Foundation—either version 2 of the License or (at your option) any later version.