No tags found on this site yet.

Boot

06 Jul 2021 - [ Linux  How-to  ]

Linux Boot Process

This list below is a high level overview for x86_64 centOS

Once a system is powered on, it will execute some electrical jump codes:

  1. POST (Power On Self Test)
    • this will initialize hardware devices system clock
    • BIOS – {includes all low level procedures to handle hardware devices}
    • BIOS will now search for bootable devices like cd/usb, disk or network
  2. MBR
    • normally disk is booted and, boot sector of the disk namely the Master Boot Record can be found
    • (MBR = 512 ; includes primary bootloader,partition table and validation checks)
    • Modern OS uses GPT
  3. GRUB2
    • loads from /boot/grub2/grub.cfg and display a menu
  4. then it will load the images into the RAM. those images include kernel and initramfs
    /boot/vmlinuz-3.10.0-1160.24.1.el7.x86_64
    /boot/initramfs-3.10.0-1160.24.1.el7.x86_64.img
    
    • the initramfs contains the basic driver to load the kernel and will be used as a temporary root filesystem
    • once loaded the kernel will initialise the hardware again and most functions
  5. executes /sbin/init from initramfs (remount root) and will create PID 1.
  6. then it will load the systemd runlevels/targets
    # cat  /etc/systemd/system/default.target
    [Unit]
    Description=Multi-User System
    Documentation=man:systemd.special(7)
    Requires=basic.target
    Conflicts=rescue.service rescue.target
    After=basic.target rescue.service rescue.target
    AllowIsolate=yes
    

** list available targets **

# systemctl list-units --type=target --all
  UNIT                      LOAD      ACTIVE   SUB    DESCRIPTION
  basic.target              loaded    active   active Basic System
  cryptsetup.target         loaded    active   active Local Encrypted Volumes
  emergency.target          loaded    inactive dead   Emergency Mode
  final.target              loaded    inactive dead   Final Step
  getty-pre.target          loaded    inactive dead   Login Prompts (Pre)
  getty.target              loaded    active   active Login Prompts
  graphical.target          loaded    inactive dead   Graphical Interface
  initrd-fs.target          loaded    inactive dead   Initrd File Systems
  initrd-root-fs.target     loaded    inactive dead   Initrd Root File System
  initrd-switch-root.target loaded    inactive dead   Switch Root
  initrd.target             loaded    inactive dead   Initrd Default Target
  local-fs-pre.target       loaded    active   active Local File Systems (Pre)
  local-fs.target           loaded    active   active Local File Systems
  multi-user.target         loaded    active   active Multi-User System
  network-online.target     loaded    active   active Network is Online
  network-pre.target        loaded    inactive dead   Network (Pre)
  network.target            loaded    active   active Network
  nfs-client.target         loaded    active   active NFS client services
  nss-lookup.target         loaded    inactive dead   Host and Network Name Lookups
  nss-user-lookup.target    loaded    inactive dead   User and Group Name Lookups

** selecting different target at boot ** use case for rescue shell

  1. reboot the system
  2. interrupt the bootloader
  3. press e to edit
  4. append systemd.unit=target.target
  5. cntrl+x