03.0 (Conspect) Pre-SystemBoot

Power on. What now? Run a program? What program? All we have is CPU and pristine clean RAM

  1. ROM:

    • There are BIOS — to make a simple I/O operations (video, keyboard, primitive disk)

We can:

  1. Primary loader:

    • Very small.
    • Very dull.
    • Specific by the device it resides:
      • Knows how to read blocks from device
      • Knows what to read ad run from this device (e. g. by hardcoding a list of blocks to read just into primary loader code)

  2. Secondary loader:

    • Very smart (must be):
      • Must recognize a umber filesystems (e. g. ext2, ext3, ext4, jfs, xfs, btrfs, zfs, HPFS, ...) to find loadable file on
      • Must recognize a number of formats (e. g. linux, BSD, windows, OS/X etc) to load any OS kernel

      • Must have an ability to load and link modules (drivers) with the kernel

        • Why? Because no modern kernel is so monolith to include all the drivers in it, and disk driver is sufficient to the kernel, that must mount that version disk as root

    • IRL: No such thing as universal boot loader

      • Knows about disk partition and filesystems
      • Can select and boot specific OS kernel or something alike from the given FS

      • Can boot other secondary loader to boot another OS (e. g. windows)

  3. OS kernel:

    • Checks and tunes hardware
    • mounts root filesystem
    • initial OS startup

So, theoretically:

  1. BootROM
    • Select a device to boot from
    • Load a Boot block from it
  2. Boot block (primary loader)
    • (almost never) select a secondary loader

    • load and boot a secondary loader from somewhere at the current device

  3. Boot program (secondary loader)
    • Select and boot variant (one of kernels available and parameters) and boot it
    • or select and chainload another secondary loader (capable for boot other type kernels)
  4. Kernel
    • check and set-up devices
    • find filesystem to mount as root, mount it and initiate OS startup

The locked key problem:

  1. Kernel is to mount / directory from the particular filesystem of the particular partition on the particular hard disk drive connected to the particular disk controller
  2. There are so many filesystem types, disks and disk controllers, that no kernel has them compiled in. Those are loadable modules, that collected as files on the particular filesystem (often in the /lib/modules directory). The kernel shall load some of them first

so, let's pick the VirtualBox and check out its settings:

How does the operating system load?

Programs are copied to RAM from a permanent storage device and run.

The ROM loader can only load one sector from an external device. This sector contains a loader that is specific to this device.

The secondary loader (of any size) starts next. It can load multiple operating system cores.

In order for the download to be normal, all levels must be independent.

Problems

  1. There is a dependency problem: If the lower-level operation is managed with a higher level. Then when you write a change to one component, the other component will stop working.
  2. Another problem is the recognition of external devices. In other words, the core must be very "smart", since it is not possible to support controllers of all devices. To do this, the corresponding modules are loaded.

The secondary loader functions are divided into two parts:

  1. Load the core
  2. Find all the necessary modules and use them to build the core

The starting virtual disk is a small OS that contains all the necessary drivers and can link them to the core.

Commands

The df command shows which file systems are currently in use.

The lsblk command shows all available block devices.

New loading sequence:

We have a partition on a 128MB disk with the FAT16 file system. When the computer starts, a small OS called EFI is loaded from the ROM. This is a universal loader that is needed for trusted downloads. It can also run programs. It has its own drivers. Can check the core signature.

Windows works differently.

HSE/ArchitectureOS/03_PreSystemBoot/Conspect_en (последним исправлял пользователь VasilyKireenko 2020-06-10 00:30:18)