– General Linux 2 – Booting the System (Linux Professional Institute Certification) $Id: gl2.106.1.slides.tex,v 1.1 2003/07/26 03:13:31 geoffr Exp $ Copyright c 2005, 2003 Angus Lees, Nick Urbanik, Geoffrey Robertson. 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. 1 Boot the system 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. 2 Boot the system Key files, terms, and utilities dmesg /var/log/messages /etc/conf.modules or /etc/modules.conf LILO GRUB • Note that 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 Booting • Machine powers up, BIOS POST, spin up SCSI drives, etc • BIOS boots boot loader • (Boot loader may load its “second stage” from somewhere else) – 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 4 • Linux kernel mounts / • Linux kernel starts init(8) • init(8) starts up rest of system 5 Finding the 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. 6 Boot Loaders LILO • “Usual” i386 boot loader – at least it was a few years ago. • 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. 7 Boot Loaders GRUB • 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 • Reads the menu file /boot/grub/menu.lst directly from the hard disk • No need to change MBR when install a new kernel 8 Boot loaders isolinux • CDROMs often use isolinux as the bootloader 9 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 – 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 10 Snarfing kernel output • dmesg(8) gives you the last 16k of kernel messages. • syslog usually logs this to /var/log/messages and /var/log/dmesg or /var/log/kern.log for posterity. • syslog gathers messages from many daemons as well as the kernel, and sends them to /var/log/messages 11 /etc/modules.conf • Configuration for modprobe(8) • AKA /etc/modules.conf, or with the 2.6 kernel, /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). 12