Table of Content

Weight: 3

Description: Candidates should be able to guide the system through the booting process.

Key Knowledge Areas:

  • Provide common commands to the boot loader and options to the kernel at boot time
  • Demonstrate knowledge of the boot sequence from BIOS to boot completion
  • Understanding of SysVinit and systemd
  • Awareness of Upstart
  • Check boot events in the log files

Terms and Utilities:

dmesg
BIOS
bootloader
kernel
initramfs
init
SysVinit
systemd

firmware

  • BIOS Basic Input Output Service non-volatile memory such as ROM, EEPROM, or flash memory, use MBR system, 16bits BIOS
  • EFI/UEFI , FAT file , use GPT(GUID Partition Table) to manage disk , 32bit/64bit, can have 32bit EFI on 64 CPU

booting sequence

1.When a PC is turned on, the BIOS (Basic Input Output Service) performs a self test.
2.When the machine passes its self test, the BIOS loads the Master Boot Record (or MBR,usually from the first 512-byte sector of the boot drive). The boot drive is usually the first harddrive on the system, but may also be a diskette, CD, or USB key.
3.For a hard drive, the MBR loads a stage 1 boot loader, which is typically either the LILO orGRUB stage1 boot loader on a Linux system. This is another 512-byte, single-sector record.
4.The stage 1 boot loader usually loads a sequence of records called the stage 2 boot loader(or sometimes the stage 1.5 loader).
5.The stage 2 loader loads the operating system. For Linux, this is the kernel and possibly an initial RAM disk (initrd).

  1. When the kernel finishes loading, it usually starts /sbin/init. This program remains running until the system is shut down. It is always assigned process ID 1.
  2. When the scripts complete, init starts a program called getty, which displays the login prompt on consoles.
    Graphical login screens are handled with a graphical display manager, such as GDM for Gnome.

to influence your system’s boot process:

  • change boot device
  • interactively change boot config
  • LILO/GRUB to pass parameter to kernal

chain loading

boot manager in MBR loads the boot loader in PBR

LILO

defaults config: /etc/lilo.conf

- whenever you make changes to /etc/lilo.conf, or whenever you install a new kernel, you must run lilo. 
- The lilo program rewrites the MBR or the partition boot record to reflect your changes, including recording the absolute disk location of the kernel.

display LILO config
lilo -q -C /etc/lilo-graphic.conf

GRUB

default config file :  /boot/grub/grub.conf or /boot/grub/menu.lst

interactive change boot parameter

From the menu, you may press e on an entry to edit it, c to switch to a GRUB command line, b to boot the system, p to enter a password, and Esc to return to the menu or to the previous step.

boot to single mode, remove quiet , change to single:
linux16 /boot/vmlinuz-xxx root/UUID=xxx ro rhgb quiet 
linux16 /boot/vmlinuz-xxx root/UUID=xxx ro single

if kernal cannot run init
init=/bin/sh boots system to shell for troubleshoot

init

3 type of init
- SysVinit
- Upstart
- Systemd

When the kernel finishes loading, it usually starts /sbin/init. This program remains running until the system is shut down. It is always assigned process ID 1

root@dclab-u1504s:~# ls -l /sbin/init
lrwxrwxrwx 1 root root 20 Jun  2 16:29 /sbin/init -> /lib/systemd/systemd

# ps --pid 1
  PID TTY          TIME CMD
    1 ?        00:00:01 systemd

The init program boots the rest of your system by running a series of scripts. These scripts typically live in /etc/rc.d/init.d or /etc/init.d

diff between /etc/init.d and /etc/rcX.d
/etc/init.d  real scripts 
/etc/rcX.d  start/stop order, linked to /etc/init.d script 

root@dclab-u1504s:/etc# ll rc0.d/
total 12
drwxr-xr-x  2 root root 4096 Oct 17 08:46 ./
drwxr-xr-x 89 root root 4096 Oct 28 23:56 ../
lrwxrwxrwx  1 root root   20 Sep 20 06:33 K01irqbalance -> ../init.d/irqbalance*
lrwxrwxrwx  1 root root   18 Oct 17 08:46 K01quotarpc -> ../init.d/quotarpc* 

boot event

kernal/module output to kernal ring buffer, print by dmesg 

dmesg | head -n 30 
dmesg | tail -n 20 

system log
SysVinit /var/log/messages
Systemd journalctl 

root@dclab-u1504s:/var/log# dmesg |grep NIC
[   22.350152] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
root@dclab-u1504s:/var/log# cat syslog|grep NIC
Oct 30 08:39:00 dclab-u1504s kernel: [   22.350152] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None

root@dclab-u1504s:/var/log# journalctl |grep NIC
Oct 30 08:39:00 dclab-u1504s kernel: e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None