Skip to main content

System Startup And Operation

System Startup & Operation

The startup & operation are crucial for understanding how the system starts, what services are running, and how resources are managed. They are also essential knowledge for troubleshooting system issues

Operation Startup fundamentals

Booting

The boot process is the sequence of events that takes place when you turn on your computer. Here's a simplified overview:

  1. BIOS/UEFI: The Basic Input/Output System (BIOS) or Unified Extensible Firmware Interface (UEFI) initializes hardware and searches for a bootable device.
  2. Bootloader (e.g., GRUB): The bootloader is loaded from the bootable device (usually the hard drive's Master Boot Record or a separate boot partition). It allows you to choose which operating system to boot (if you have multiple OSs installed).
  3. Kernel Loading: The bootloader loads the Linux kernel into memory and starts it.
  4. init Process (Systemd): The kernel starts the first user-space process, traditionally called init. In most modern Linux distributions, init is implemented by systemd, a system and service manager.:
  • Analogy: Imagine a one-way conversation through a speaking tube. One person speaks into the tube, and the other listens.
  • Software Example: A parent process filtering the output of a child process. The child process writes its output to the pipe, and the parent process reads and filters it. Common in shell commands like grep or wc when used with pipes (e.g., ls -l | grep "txt$").
Init & Systemd
  • Traditional init (SysVinit): Older init systems used a numbered runlevel system (e.g., runlevel 3 for multi-user text mode, runlevel 5 for graphical mode). init would start services and processes based on the current runlevel.
  • Systemd: Systemd is a more modern and sophisticated init system. It uses unit files to define and manage services, and it supports parallel startup of services, making the boot process faster. It also provides features like dependency management and resource control.
Key systemd concepts:
  1. Unit files: Configuration files that describe services, targets (groups of units), and other system components.
  2. Targets: Predefined groups of units that represent different system states (e.g., multi-user.target for normal operation).
  3. systemctl command: Used to control and manage systemd units (start, stop, enable, disable, etc.).
Process Management:

The Linux kernel is responsible for managing processes. Key aspects of process management include:

  1. Creating processes: The fork() system call creates a new process by duplicating the existing process. The exec() family of system calls loads a new program into a process.
  2. Scheduling: The kernel's scheduler decides which process gets to run on the CPU at any given time. It uses various algorithms to ensure fairness and responsiveness.
  3. Memory management: The kernel allocates and manages memory for each process. It uses techniques like virtual memory and paging to provide each process with its own address space.
  4. Inter-process communication (IPC): As discussed previously, IPC mechanisms allow processes to communicate and synchronize.
  5. Process termination: Processes can terminate normally by exiting or be terminated by signals (e.g., SIGTERM, SIGKILL).

Summary

The boot process loads the kernel, which then starts init (usually systemd). Systemd initializes the system and starts services. The kernel manages running processes, including creation, scheduling, resource allocation, and termination.