Sobes.tech
Middle

How does the process of loading the Linux operating system occur?

sobes.tech AI

Answer from AI

  1. BIOS/UEFI: Hardware initialization, peripheral check, boot device selection.

  2. MBR/GPT: Reading the contents of the Master Boot Record (MBR) or GUID Partition Table (GPT) from the boot device.

  3. Bootloader (GRUB, LILO): Loading the bootloader. Displaying the boot menu (if available), selecting the kernel and initial ramdisk.

  4. Kernel: Loading the operating system kernel into memory. Hardware initialization, mounting the root filesystem.

  5. Initial Ramdisk (initrd/initramfs): Loading a temporary root filesystem into memory. Executing scripts to detect hardware and prepare for mounting the real root filesystem.

  6. Root Filesystem: Mounting the real root filesystem specified in kernel parameters or initrd/initramfs.

  7. Init System (SysVinit, systemd): Starting the init system. systemd is more modern and widely used.

    • SysVinit: Starting services based on runlevels.
    • systemd: Starting services in parallel based on units (services, targets, etc.).
    # Example systemd unit
    [Unit]
    Description=My Application Service
    After=network.target
    
    [Service]
    ExecStart=/usr/local/bin/my-app
    Restart=on-failure
    
    [Install]
    WantedBy=multi-user.target
    
  8. Runlevel/Target: Transition to the appropriate runlevel (SysVinit) or target state (systemd), starting necessary services (network services, graphical shell, etc.).

  9. Login Prompt/Display Manager: Starting the login shell (terminal) or graphical login manager (GDM, LightDM, etc.).

  10. User Login: User logs into the system. User session is started.