Linux running on a PC goes through four boot stages: firmware, boot loader, kernel, and initialization. Learn about each stage and how they spawn each other until the system is ready to be logged into.
- [Instructor] From Chapter Two on, all exercises will be done inside one or more CentOS 7 virtual machines. If you were not able to install CentOS 7 on a physical computer, you can start here with CentOS 7 installed on a VirtualBox virtual machine, running on any host operating system. A Linux system goes through several stages when booting, the firmware stage, the boot loader stage, the kernel stage and lastly, the initialization stage. During the firmware stage, the computer runs code in either the BIOS or UEFI during power-on self-test, or POST.
Older computers have a BIOS and newer computers have UEFI. After the firmware stage, the BIOS or UEFI executes the boot loader stage. In the case of Enterprise Linux, the boot loader is grub2, or grand unified boot loader 2. Grub's job is to read in its configuration file and boot the Linux kernel. In the case of a BIOS machine, grub reads in /boot/grub2/grub.cfg. For UEFI systems, it loads /boot/efi/EFI/redhat/grub.efi.
The boot loader then executes the kernel. During the kernel stage, the kernel loads the ramdisk into memory. This ramdisk serves as a temporary root file system. This file system includes kernel modules, drivers and possibly even kickstart files. Later, the kernel unmounts the ramdisk and mounts the root filesystem on the hard drive, and then starts the initialization stage by executing the first process. In the initialization stage, the grandfather process runs. In older versions of Red Hat, this was the init process.
Init was replaced by upstart, which has now been replaced by systemd. Systemd then starts all system services. Included would be a login shell or a graphical interface. When it's finished, the OS is ready to be used. Systemd has a concept of targets that are similar to the old init run levels. You can think of a target as a system configuration. For instance, by default, Enterprise Linux boots up into the graphical target. A system can be booted into different targets.
There are targets for different purposes, such as rescuing the system after a crash.
- Linux boot loader process
- Creating a custom GRUB menu entry
- Booting into the emergency target
- Linux init services
- Making systemd services persistent
- Linux kernel directory structure
- Updating the kernel
- Managing kernel modules
- System logging
- Searching and rotating log files