37. System Startup And Shutdown Flashcards
Learning Objectives
By the end of this chapter, you should be able to:
- Explain the boot process.
- Identify several types of boot loaders.
- Describe what the BIOS does.
- Identify the relevant configuration files.
- Describe how the system shuts down and reboots.
Boot Sequence
What is the basic steps in the boot sequence?
- The BIOS/UEFI locates and executes the boot program, or boot loader.
- The boot loader loads the kernel.
- The kernel starts the init process (pid=1).
- init manages system initialization, using systemd or the older Upstart and SysVinit startup scripts.
Boot Sequence
First, the BIOS runs the POST (Power On Self Test), which checks the ___ and ___ and then searches a specific location or device for a ___ program. Typically, the ___ program is found in the device’s MBR (Master Boot Record, or using UEFI). Control of the computer is then transferred to this ___ program (usually GRUB).
The ___ program then loads the kernel into the memory and executes it. On x86 platforms (and many others), the kernel first has to decompress itself in place. It then performs hardware checks, gains access to important peripheral hardware, and eventually runs the ___ process.
The ___ process in turn continues the system startup, running __ scripts if SysVinit is being used, or managing either Upstart or systemd.
Newer computers are moving to UEFI, a replacement for BIOS, which performs many of the same functions.
- memory
- hardware
- boot, boot, boot, boot
- init, init
BIOS
On the x86 architecture, the BIOS contains all the code required to gain initial access to the keyboard, display screen, disk drives, serial communications, and a number of miscellaneous functions. Once the full system is running, most of these devices will have enhanced capabilities when complete and specialized device drivers can be loaded and take over.
The BIOS is typically placed in a ROM chip that comes with the computer (it is often called a ROM BIOS). This ensures that the BIOS will always be available and will not be damaged by disk failures. This also makes it possible for a computer to boot itself.
During the boot process, the BIOS loads the boot loader.
Boot Loaders
Name 4 common linux bootloaders.
- GRUB
- efibootmgr
- LILO
- Das U-Boot
Boot Loaders
Describe the GRUB bootloader
Virtually, all (non-embedded) modern Linux distributions use GRUB (GRand Unified Boot Loader). GRUB’s features include the ability to boot multiple operating systems, both a graphical and a text-based interface allowing ease of use over a serial cable, a powerful command line interface for interactive configuration, network-based diskless booting, and other advanced features.
Boot Loaders
Describe the efibootmgr
efibootmgr is not actually a boot loader, but is a boot manager, used in conjunction with GRUB on multi-boot EFI systems.
Boot Loaders
Describe LILO boot loader
- The Linux Loader (LILO) is old and obsolete.
Boot Loaders
Describe Das U-Boot boot loader
Das U-Boot is in wide usage for embedded systems. There are some other boot loaders used, including bareboot. However, we are not focused on embedded systems in the present course.
Configuration Files in /etc
Earlier, we discussed about where Linux distributions cooperate, and hopefully follow agreed-upon standards to place certain kinds of files in standard places on the system.
In particular, system-wide configuration files are generally placed in /etc and its subdirectories, while user-specific ones are often placed in their individual home directories. This is not completely true; for example, default configuration information might be stored in /usr/lib/systemd, but can be overridden by files in /etc/systemd.
For historical reasons, Linux distributions evolved their own rules about exactly where to place some information in /etc. For example, all Red Hat-derived systems make extensive use of /etc/sysconfig, while Debian-based systems have used /etc/default. Interestingly, RHEL and SUSE use both.
There should be only text files found under /etc, no binary formats or data.
/etc/sysconfig
Files in this directory and its subdirectories are used by many system utilities services. They are often consulted or invoked when the system starts and stops services or queries their status.
On RHEL systems:
$ ls /etc/sysconfig
We can take a look at one file in the screenshot here; this file reads and sets the selinux configuration at system startup.
$ cat /etc/sysconfig/selinux
/etc/default
The screenshot shows the /etc/default directory on an Ubuntu system.
The use of this directory is similar to that of Red Hat’s /etc/sysconfig:
- The files are used to provide extra options when starting a service.
- They typically contain code to set environment variables.
For example, the file /etc/default/useradd sets the defaults that are used when new user accounts are being created. All significant Linux distributions, including Red Hat-based ones, now have /etc/default, even if they still have /etc/sysconfig.
Shutting Down and Rebooting
Shutdown is used to bring the system down in a secure fashion, notifying all users that the system is going down and then stopping it in a graceful and non-destructive way. After it is shut down, the system is either halted or rebooted. You can see some shutdown examples here:
$ shutdown -h +1 “Power Failure imminent”
$ shutdown -h now
$ shutdown -r now
$ shutdown now
The options can easily be listed by the built-in –help message.
With no options (e.g. shutdown now), the default behavior is to power off the system completely. Some distributions, such as Ubuntu, violate this and go to single user mode instead.
There are also the legacy commands reboot, halt, and poweroff, which many veteran users use frequently.