02 Boot System and System Management


  • .

The boot system is the process that occurs when a computer is powered on, starting from the hardware initialization until the operating system is loaded and ready to use. System management focuses on managing various hardware and software components to ensure the system runs smoothly. One of the key parts of the boot process is GRUB (Grand Unified Bootloader), which is responsible for loading the operating system.

Booting Process

The booting process consists of the steps that occur from the moment the computer is powered on until the operating system starts. This process is divided into two main phases: Initial Booting (BIOS/UEFI) and Operating System Booting.

Booting Awal (BIOS/UEFI)

  • BIOS (Basic Input/Output System) is the first firmware software that runs when the computer is turned on. BIOS is responsible for performing a hardware check (POST - Power On Self Test) and initializing hardware components such as the CPU, RAM, and storage devices.

  • UEFI (Unified Extensible Firmware Interface) is a more modern replacement for BIOS, offering advanced capabilities such as faster booting, support for large drives, and a graphical interface. Once BIOS or UEFI completes the hardware check, it looks for a valid boot device (e.g., hard drive, SSD, or USB drive).

Operating System Booting

After BIOS/UEFI finds a valid boot device, it loads the bootloader. In Linux systems, GRUB is the most commonly used bootloader.

GRUB (Grand Unified Bootloader)

GRUB is a bootloader used in many Linux distributions to load the operating system kernel. GRUB is responsible for selecting and loading the operating system to be run. There are two main versions of GRUB: GRUB Legacy (older version) and GRUB 2 (newer and more advanced version).

GRUB Functions

  • Selecting the Operating System: GRUB allows users to choose between multiple installed operating systems on a computer. This is particularly useful for dual-boot configurations (e.g., Linux and Windows).

  • Loading the Kernel: GRUB loads the Linux kernel into memory and hands over control to the kernel to continue the booting process.

  • Loading the Initrd File: GRUB also loads initrd (initial RAM disk), which contains necessary system files for the boot process before the main file system is used.

Konfigurasi GRUB

The GRUB configuration is located in the /etc/default/grub file (for GRUB 2). Some important parameters that can be configured include:

  • GRUB_DEFAULT: Specifies the default entry to be selected during boot.

  • GRUB_TIMEOUT: Specifies the duration GRUB waits before automatically booting.

  • GRUB_CMDLINE_LINUX: Specifies kernel parameters to be passed during booting.

After making changes to the GRUB configuration file, update GRUB with the command:

sudo update-grub

GRUB Menu

GRUB provides a boot menu that allows users to choose the operating system or kernel to be loaded. This menu appears if there is more than one entry in the GRUB configuration, such as in a dual-boot system. Users can navigate the menu using arrow keys and press Enter to initiate booting.

System Management

System management focuses on managing and maintaining the operating system and hardware to ensure optimal performance and security. Some key system management tasks include:

Service and Process Management

Services are programs that run in the background to support system operations. In Linux, service management is performed using systemd (on modern distributions) or init.d (on older distributions). Systemd is a modern initialization and service manager used in many Linux distributions. Commonly used commands for managing services with systemd include:

  • Displaying service status:

    systemctl status service_name
  • Enabling a service to run automatically at boot:

    sudo systemctl enable service_name
  • Disabling a service:

    sudo systemctl disable service_name
  • Starting a service:

    sudo systemctl start service_name
  • Stopping a service:

    sudo systemctl stop service_name

System Initialization and Services with Systemd

Systemd is a modern initialization system used by many Linux distributions to manage processes and services. Systemd replaces older initialization systems like SysVinit with a faster, more parallel, and more flexible approach.

System Initialization Process with Systemd

The initialization process with Systemd begins after the bootloader (such as GRUB) loads the Linux kernel. The steps are as follows:

  1. Kernel is initialized: The kernel loads hardware drivers and activates the root file system.

  2. Systemd starts: The kernel starts Systemd as the first process (PID 1).

  3. Systemd reads unit files: Systemd reads configuration files called unit files, which define services, sockets, mount points, and more.

  4. Services are started: Systemd starts services and processes based on defined dependencies.

Unit Files in Systemd

Unit files are configuration files used by Systemd to manage various system resources. Unit files are typically located in:

  • /lib/systemd/system/: System default unit files.

  • /etc/systemd/system/\*\*: User-modified or added unit files.

Types of Unit Files:

  • Service (.service): For services.

  • Target (.target): For service groups (similar to runlevel in SysVinit).

  • Socket (.socket): For inter-process communication.

  • Mount (.mount): For mounted file systems.

Starting, Stopping, and Managing System Services

Basic Systemd Commands

  • Starting a Service

    sudo systemctl start service_name.service
  • Stopping a Service

    sudo systemctl stop service_name.service
  • Restarting a Service

    sudo systemctl restart service_name.service
  • Reloading Service Configuration
    If you only want to reload the configuration without stopping the service:

    sudo systemctl reload service_name.service
  • Enabling a Service
    To enable a service to start automatically at boot:

    sudo systemctl enable service_name.service
  • Disabling a Service
    To disable a service from starting at boot:

    sudo systemctl disable service_name.service
  • Checking Service Status
    To check the status of a service:

    systemctl status service_name.service

System Monitoring and Logging

Journalctl

Journalctl is a built-in Systemd tool for viewing system logs. All logs managed by Systemd are stored in the journal. Basic journalctl commands:

  • Display all logs:

    Journalctl
  • Display the latest logs:

    journalctl -f
  • Display logs for a specific service:

    journalctl -u service_name.service
  • Display logs based on time:

    journalctl --since "2025-01-01" --until "2025-01-08"
  • View journal log size:

    journalctl --disk-usage
  • Clean up journal logs:

    sudo journalctl --vacuum-size=100M

Rsyslog

Rsyslog is a traditional logging system used to store logs in text files, such as /var/log/syslog or /var/log/messages.

  1. Rsyslog Configuration:

    • Main configuration file:: /etc/rsyslog.conf.

    • Additional configuration directory2: /etc/rsyslog.d/.

  2. Basic Rsyslog Commands :

    • Start the Rsyslog service:

      sudo systemctl start rsyslog
    • Stop the Rsyslog service:

      sudo systemctl stop rsyslog
    • Check Rsyslog logs:

      tail -f /var/log/syslog

System Maintenance and Patching

System Maintenance

System maintenance involves software updates, disk space management, and system performance monitoring.

  1. System Updates

    • For Debian-based distributions (Ubuntu, Debian):

      sudo apt update && sudo apt upgrade
    • For Red Hat-based distributions (CentOS, Fedora):

      sudo yum update
  2. Cleaning Up Disk Space

    • Remove unnecessary packages:

      sudo apt autoremove
    • Clean package cache:

      sudo apt clean
  3. Monitoring Disk Usage

    • View disk usage:

      df -h
    • Check large files or directories:

      du -sh /path/to/directory

System Patching

Patching is the process of updating software to fix bugs or security vulnerabilities.

  1. Automating Patching
    On Ubuntu, use unattended-upgrades for automatic updates:

    sudo apt install unattended-upgrades
    sudo dpkg-reconfigure unattended-upgrades
  2. Kernel Updates
    The Linux kernel is frequently updated to fix bugs and improve security. Kernel updates can be performed as follows:

    • Ubuntu/Debian :

      sudo apt install linux-generic
    • CentOS/RHEL :

      sudo yum update kernel