|(1)||Power on system|
|(2)||BIOS executes code stored in non-volatile ram (EEPROM, ROM, flash memory)|
|(3)||Code performs POST (Power ON Self Test)|
|(4)||Code loads MBR from first sector of boot drive|
|(5)||Control of boot process is passed to code read from MBR - the partition boot record and a stage 1 boot loader|
|(6)||Stage 1 boot loader locates and loads the Stage 2 (or Stage 1.5 which then loads Stage 2) boot loader|
|(7)||Stage 2 boot loader locates kernel image and loads|
|(8)||Root filesystem is mounted. A temporary ramdisk image can be loaded|
|(9)||The init process runs. The parent of all other Linux processes PID=1|
|(10)||init reads /etc/inittab (if it exists), determines configuration of the remaining boot steps. Default runlevel is set near top of file|
- System boot overview
- System shutdown and restart
- 'telinit' or 'init'
can be used to stop multiuser activity, switch to single-user mode, halt the system etc..
sends all running processes a SIGTERM signal. After 5 seconds, or a specified delay, 'init' then sends a SIGKILL signal to forcibly end each remaining process.
sends a warning message to all logged on users, blocks further logins, signals init to switch runlevels.Brings the system down in a secure, organised manner, by default shutdown switches to runlevel 1 (single-user mode).
- a shudown can be cancelled if there is enough time remaining since it was initiated.
shutdown [-t sec] [-arkhncfFHP] time [warning-message] Common options: -t sec Wait sec seconds between sending processes the warning and the kill signal -a Use /etc/shutdown.allow -k Do not really shutdown; only send the warning messages to everybody -r Reboot after shutdown -h Halt or poweroff after shutdown -f Skip fsck on reboot -F Force fsck on reboot -c Cancel an already running shutdown, no 'time' arg, can give a 'warning-message' time When to shutdown: hh:mm absolute time +m number of minutes to wait now alias for +0
'Ctrl-c' may cancel depending on how far the process has progressed and if the command is running in the foreground.
- Halt, shutdown and reboot a system
/sbin/halt, reboot, poweroff
Halt the system
halt [-n] [-w] [-d] [-f] [-i] [-p] [-h]
When used in runlevels 1-5, 'halt' calls 'shutdown' with '-h' or '-r' flags.
Reboot - shutdown first then reboot
reboot [-n] [-w] [-d] [-f] [-i]
Poweroff - shut down the system and power off the machine
poweroff [-n] [-w] [-d] [-f] [-i] [-h]
-n Do not sync before reboot or halt -w Do not reboot or halt but only write the wtmp record -d Do not write the wtmp record. The -n flag implies -d. -f Force halt or reboot, do not call shutdown -i Shut down all network interfaces just before halt or reboot -h Put all hard drives on the system in standby mode just before halt or poweroff -p Do a poweroff on halt. Default = poweroff on halt.
If an option can be applied to one of the above commands then it has the same meaning as above.
- Influencing the boot process
There are four main areas where the booting of a system may be influenced:
Area Method BIOS Change boot order, boot device. Modern BIOSes support booting from various devices e.g. floppy, USB disk, CD-Rom, DVD, network ... Boot Loader If applicable, select which OS and or OS version to boot Kernel Pass parameters to the kernel (via the boot loader) to influence what it does during loading /sbin/init Change the script or it's configuration file /etc/inittab to alter startup behavior
- Influence the boot process using the LILO boot loader
On startup LILO presents the user with the following prompt
Can either pass parameters to the kernel
LILO: apci=force vga=0x317
or hit the 'tab' key to select a kernel/OS to boot
LILO: linux* vmlinuz-2.6.24-23-generic linux vmlinuz-2.6.24-21-custom win2k
(* denotes default image, unless overridden it is the first 'image=' entry in 'lilo.conf')
If LILO is not configured to be interactive i.e. Tab key has no affect, press and hold the Alt or Shift key before the LILO message appears.
- Influence the boot process using the GRUB boot loader
Grub provides a menu as opposed to a prompt. The menu consists of available OSs to boot.
Grub menu commands
e On an entry to edit it c To switch to a GRUB command line - alter or append kernel parameters b To boot the system Enter Boots p To enter a password esc To return to the menu or to the previous step.
Run a grub simulated shell, can test configuration or run commands
# grub Probing devices to guess BIOS drives. This may take a long time. ..... grub> help help blocklist FILE boot cat FILE chainloader [--force] FILE ..... grub>
*** you are probably using grub2 now ...
- Influence the boot process via kernel parameters
To control kernel modules use /etc/modprobe.conf (/etc/modules.conf or /etc/conf.modules for earlier versions).
Kernel parameters can be supplied via the boot loaders cmd-line or set in the boot loader config files. They control the kernel ONLY.
Partial list of kernel parameters
CONSOLE OPTIONS: console=ttyn Use virtual console device n. debug Set kernel logging to debug level KERN_DEBUG (7). quiet Set log level to (4), suppress all messages except really serious ones. loglevel=0 (KERN_EMERG) System is unusable. loglevel=1 (KERN_ALERT) Actions that must be taken immediately. loglevel=2 (KERN_CRIT) Critical conditions. loglevel=3 (KERN_ERR) Non-critical error conditions. loglevel=4 (KERN_WARNING) Warning conditions that should be addressed. loglevel=5 (KERN_NORMAL) Normal but significant events. loglevel=6 (KERN_INFO) Informational messages that require no action. loglevel=7 (KERN_DEBUG) Debug info if kernel debugging is enabled in config. INTERRUPT OPTIONS: apic=[quiet|verbose|debug] Intel chip Advanced Programmable Interrupt Controller. Default=quiet. noapic Do not use any IOAPICs that may be in the system. irqfixup Search all known interrupt handlers to find one for an interrupt that is not handled. Intended for systems with badly broken firmware. irqpoll Search all known interrupt handlers and check all handlers on each timer interrupt for an interrupt that is not handled. Intended for systems with badly broken firmware. SUSPEND OPTIONS: resume=suspend_device Which disk contains the suspended kernel image. This is the kernel device name not userspace device name. noresume Disable. Any swap space used to hold suspended system images will revert back to available swap space. CPU OPTIONS: cachesize=n (bytes) Override level 2 CPU cache size detection. Sometimes CPU hw bugs may report this size incorrectly. Kernel attempts to suss it out but cannot always do so. This option provides an override for this situation. nosmp Tell SMP kernel to act as a uniprocessor even on a multiprocessor machine. max_cpus Max number of CPUs to use even if there are more. SCHEDULER OPTIONS: There are some. RAMDISK OPTIONS: initrd=filename Location of ramdisk image. noinitrd Do not use one even if configured elsewhere to be used. ROOT DISK OPTIONS: ro Mount root device as read-only at boot. rw Read-write. root=device Specify root filesystem to be used. rootfstype=type Try to mount root fs as this type e.g. rootfstype=ext3. INIT OPTIONS: init=filename Run this binary as the init process instead of default is /sbin/init. rdinit=full_path_name Run init process from ramdisk instead of root fs S|s|single|1 Run init in single-user-mode. Default is multi-user-mode number Run level to boot into
- Print or manage the kernel ring buffer
dmesg [ -c ] [ -n level ] [ -s bufsize ] Options: -c Clear the ring buffer contents after printing. -sbufsize Use buffer of size bufsize to query the kernel ring buffer. 16392 by default -nlevel Set the level at which logging of messages is done to the console e.g. -n 1 prints only panic messages to console
View boot messages
$ dmesg | head -n 6 [ 0.000000] BIOS EBDA/lowmem at: 0009fc00/0009fc00 [ 0.000000] Initializing cgroup subsys cpuset [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Linux version 2.6.28-16-generic (buildd@yellow) (gcc version 4.3.3 \ (Ubuntu 4.3.3-5ubuntu4) ) #57-Ubuntu SMP Wed Nov 11 09:49:32 UTC \ 2009 (Ubuntu 2.6.28-16.57-generic) [ 0.000000] Command line: root=UUID=155af2b2-9107-43c0-a034-67ce99db1ebb ro vga=0x317 [ 0.000000] KERNEL supported cpus:
- Boot log files
These are configurable in terms of logfile names and what messages get logged to each via 'syslogd' i.e. /etc/syslog.conf. Will vary from distribution to distribution.
Common boot log files
/var/log/messages /var/log/boot /var/log/dmesg