CentOS 7 Boot Process
1. BIOS/UEFI Initialization and POST
When you power on a computer with CentOS 7 installed, the system starts by initializing the BIOS (Basic Input/Output System) or UEFI (Unified Extensible Firmware Interface). This firmware performs a PowerOn SelfTest (POST), which checks the system's hardware components such as the CPU, memory, disk drives, and other peripherals. The POST ensures that all hardware is functioning correctly and initializes basic hardware settings.
Key Points:
BIOS/UEFI: First level of system firmware; responsible for hardware initialization.
POST: Hardware selftest conducted during boot to ensure all components are functioning.
Boot Order: Determines the order in which devices are Checked for bootable media (e.g., HDD, SSD, USB drive, Network Boot).
2. Bootloader Stage (GRUB2)
After the POST completes successfully, the control passes to the bootloader stored in the Master Boot Record (MBR) of the boot device. In CentOS 7, this is typically GRUB2 (GRand Unified Bootloader version 2). The MBR is the first sector on a hard disk that contains code to locate and load the secondary stage of the bootloader from /boot/grub directory.
Key Points:
MBR: Master Boot Record; holds the primary bootloader code.
GRUB2: Secondary bootloader that provides menu options for booting different OS kernels or versions.
/boot/grub: Directory containing additional stages of the bootloader and configuration files likegrub.cfg
.
3. Loading Kernel and initramfs
Once the bootloader is loaded, it fetches the Linux kernel (vmlinuz
) and the initial RAM filesystem (initramfs orinitrd
image) from the /boot partition and loads them into memory. The kernel then takes over the boot process.
Key Points:
Kernel: Core component of the Linux operating system responsible for managing system resources and processes.
initramfs: A temporary root filesystem used to complete the boot process before the real root filesystem is mounted.
/boot: Partition where the kernel and initramfs images are stored.
4. Systemd Init System
CentOS 7 replaces the traditional SysVinit with systemd, a more advanced init system that manages services and dependencies more efficiently. Upon taking over from the initramfs, systemd starts by mounting the real root filesystem and executing various targets (similar to runlevels in SysVinit).
Key Points:
systemd: Service manager controlling the boot process and service dependencies.
Targets: Groups of systemd units (services, sockets, etc.) defining system states like multiuser.target (default for CentOS 7).
Default Target: Set via/etc/systemd/system/default.target
, usually multiuser.target for server environments.
5. Startup of Services and Login Manager
With the system now fully booted, systemd proceeds to start the services defined in its unit files under the default target. Finally, the login manager (getty
) starts, prompting users to log in via console or display manager (if graphically enabled).
Key Points:
Services: Managed by systemd based on targets; Includes critical system services and userdefined applications.
Login Manager:getty
handles user authentication and session initiation.
Graphical Interface: May startgraphical.target
if configured, leading to a GUI login screen.
Summary Table
Step | Description | Key Components | Purpose |
1. BIOS/UEFI | Initialize hardware and perform POST | BIOS/UEFI, POST | Verify hardware functionality |
2. Bootloader (GRUB2) | Load and hand off to kernel | MBR, GRUB2, /boot/grub | Boot management and configuration |
3. Kernel & initramfs | Load and initialize core OS | Kernel, initramfs, /boot | Start core OS functionalities |
4. Systemd Init System | Manage services and targets | systemd, default.target | Control system state transitions |
5. Services & Login Manager | Start services and allow user login | systemd services, getty | Launch user environment and sessions |
FAQs
Q1: How does CentOS 7 handle service dependencies during boot?
A1: CentOS 7 uses systemd, which employs a dependency graph to manage service startup order. Each service unit file specifies its dependencies usingRequires=
andWants=
, ensuring services start in the correct sequence.
Q2: Can I customize the boot process in CentOS 7?
A2: Yes, you can customize the boot process by modifying systemd unit files, editing targets, creating new ones, or adjusting the default target. For advanced customization, you can also edit GRUB2 configurations in/etc/default/grub
and/etc/grub.d/
. Remember to rungrub2mkconfig
after making changes to GRUB configurations.