System startup and shutdown procedures in Linux involve a series of steps that are executed to initialize the system during boot-up and gracefully shut it down. These procedures are managed by various components, including the boot loader, init system, and system services. Here’s an overview of the typical system startup and shutdown procedures in Linux:
- System Startup:a. Power-On and Boot Loader:
- When the system is powered on, the boot loader (such as GRUB or LILO) is executed, which resides in the Master Boot Record (MBR) or EFI System Partition (ESP).The boot loader loads the Linux kernel and optional initial RAM disk (initramfs) into memory.
- The Linux kernel is decompressed and initialized with essential hardware drivers and core functionality.The kernel mounts the root file system specified in the boot loader configuration.
- The init system, traditionally SysVinit or more commonly systemd, is responsible for managing the system initialization process.The init system starts the initial user space process, which is typically systemd (PID 1).
- The init system reads the target or runlevel specified in its configuration.The target defines the system state and the set of services to be started.systemd uses targets like multi-user.target (default for server systems) or graphical.target (default for desktop systems).
- The init system starts essential system services and daemons based on the target.
- Services may include network management, system logging, device initialization, and other core components.
- System Shutdown:a. User Initiated Shutdown:
- A user initiates the system shutdown through commands like “shutdown” or “reboot” or through a graphical interface.The shutdown command sends a signal to the init system to initiate the shutdown process.
- The init system receives the shutdown signal and starts the shutdown procedure.It sends termination signals to running processes and stops services in a specific order.
- The init system unmounts file systems, ensuring they are no longer in use.This includes unmounting network shares, detachable devices, and the root file system.
- Services and daemons are stopped in the reverse order of their initialization.This ensures that dependent services are properly shut down before their dependencies.
- The init system signals the kernel to shut down.The kernel terminates running processes and halts the system.
- The system hardware is powered off, either manually or automatically, depending on the system configuration.
It’s important to note that specific distributions or configurations may have variations in the startup and shutdown procedures. However, the general process involves the boot loader loading the kernel, the init system starting user space processes and services, and the orderly shutdown of services and the kernel during system shutdown.
SHARE