|
| 1 | +--- |
| 2 | +marp: true |
| 3 | +paginate: true |
| 4 | +color: #ffff |
| 5 | +backgroundColor: #2A2A2A |
| 6 | +header: '' |
| 7 | +footer: "**28/10/2021 - AnthonyF**" |
| 8 | +author: AnthonyF |
| 9 | +--- |
| 10 | +<style> |
| 11 | +section { |
| 12 | + font-family: 'Century Gothic', serif !important; |
| 13 | +} |
| 14 | +</style> |
| 15 | +<!-- _class: invert --> |
| 16 | +<!-- _header: Séance --> |
| 17 | + |
| 18 | +# Linux Startup Process <!-- fit --> |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +--- |
| 23 | +<!-- _class: invert --> |
| 24 | + |
| 25 | +# Table of Contents |
| 26 | + |
| 27 | +- Importance of understanding Linux startup |
| 28 | +- Main process during Linux startup |
| 29 | +- Some commands to manipulate Linux runlevel |
| 30 | + |
| 31 | +--- |
| 32 | +<!-- _class: invert --> |
| 33 | + |
| 34 | +# Importance of understanding Linux startup |
| 35 | + |
| 36 | +--- |
| 37 | +<!-- _class: invert --> |
| 38 | + |
| 39 | +- Good for knowledge |
| 40 | +- Being able to configure and resolve startup issues |
| 41 | + |
| 42 | +--- |
| 43 | +<!-- _class: invert --> |
| 44 | + |
| 45 | +# Main process during Linux startup |
| 46 | + |
| 47 | +--- |
| 48 | +<!-- _class: invert --> |
| 49 | + |
| 50 | +# Two main sequences during a Linux distro startup |
| 51 | + |
| 52 | +- Boot |
| 53 | + - ==> When the computer is turned on, and completed when the kernel is initialized and systemd is launched. |
| 54 | +- Startup |
| 55 | + - ==> When the booting sequence is over and it launches all the process necessary of making the computer operational for the user. |
| 56 | + |
| 57 | +--- |
| 58 | +<!-- _class: invert --> |
| 59 | + |
| 60 | +**boot** and **startup** sequences are composed of 6 steps : |
| 61 | + |
| 62 | +1. BIOS (POST) |
| 63 | +2. MBR |
| 64 | +3. Bootloader (GRUB2) |
| 65 | +4. Kernel (Linux) |
| 66 | +5. Init (Systemd) |
| 67 | +6. Runlevel and scripts |
| 68 | + |
| 69 | +--- |
| 70 | +<!-- _class: invert --> |
| 71 | + |
| 72 | +## BIOS (**B**asic **I**nput **O**utput **S**ystem) |
| 73 | + |
| 74 | +- Stored in EEPROM (**E**lectrically-**E**rasable **P**rogrammable **R**ead-**o**nly **M**emory). |
| 75 | +- Written in Assembly Language. |
| 76 | +- First interaction with the physical material. |
| 77 | +- Loads and executes the 512 bytes of the disk (MBR). |
| 78 | + |
| 79 | +>Nowadays the BIOS is replaced by UEFI (Unified Extensible Firmware Interface) |
| 80 | +
|
| 81 | +--- |
| 82 | +<!-- _class: invert --> |
| 83 | + |
| 84 | +# MBR (**M**aster **B**oot **R**ecord) |
| 85 | + |
| 86 | +- Contains Bootstrap code which contains information about the boot loader (446 bytes). |
| 87 | +- Partitions table to index all the partitions of the disk (64 bytes). |
| 88 | +- Boot signature to check if the disk is bootable or not (2 bytes). |
| 89 | + |
| 90 | +--- |
| 91 | +<!-- _class: invert --> |
| 92 | + |
| 93 | +# GRUB (**GR**and **U**nified **B**ootloader) |
| 94 | + |
| 95 | +- Loads all the available operating system or other boot loaders. |
| 96 | +- Loads and executes automatically the default Linux kernel (vmlinuz) and initrd (inital ramdisk) images. |
| 97 | +- Contains all the additional modules and drivers for the kernel. |
| 98 | + |
| 99 | +--- |
| 100 | +<!-- _class: invert --> |
| 101 | + |
| 102 | +# Kernel |
| 103 | + |
| 104 | +- The Linux kernel first mounts the root file system set in `grub.conf` in the line `root=`. |
| 105 | +- Then executes the `/sbin/init` program as the fisrt program with root privileges which executes some others scripts. |
| 106 | + |
| 107 | +>Init has the PID (Process IDentifier) of 1. |
| 108 | +
|
| 109 | +- Establishes a temporary root file system with initrd until the real file system is mounted. It also contains necessary drivers compiled inside. |
| 110 | + |
| 111 | +--- |
| 112 | +<!-- _class: invert --> |
| 113 | + |
| 114 | +# Init |
| 115 | + |
| 116 | +- init program reads its initialization files which are in /etc/init.d/ (/etc/inittab before with SysV). |
| 117 | +- It sets everything the system needs for its initialization. |
| 118 | +Then it set the default run level. |
| 119 | + |
| 120 | +--- |
| 121 | +<!-- _class: invert --> |
| 122 | +There are 7 run level from 0 to 1 : |
| 123 | + |
| 124 | +| Level | Description | |
| 125 | +| ----- | ------------------------------------ | |
| 126 | +| 0 | Halt | |
| 127 | +| 1 | Single user mode | |
| 128 | +| 2 | Multi-user | |
| 129 | +| 3 | Full multi-user mode | |
| 130 | +| 4 | Unused | |
| 131 | +| 5 | X11 (Full multi-user graphical mode) | |
| 132 | +| 6 | Reboot | |
| 133 | + |
| 134 | +--- |
| 135 | +<!-- _class: invert --> |
| 136 | + |
| 137 | +Modern Linux systems use systemd which refers with this : |
| 138 | + |
| 139 | +| Level | Target | |
| 140 | +| ----- | ----------------- | |
| 141 | +| 0 | poweroff.target | |
| 142 | +| 1 | rescue.target | |
| 143 | +| 2,3,4 | multi-user.target | |
| 144 | +| 5 | graphical.target | |
| 145 | +| 6 | reboot.target | |
| 146 | + |
| 147 | +--- |
| 148 | +<!-- _class: invert --> |
| 149 | + |
| 150 | +## Runlevels and scripts |
| 151 | + |
| 152 | +- The scripts in /etc/init.d are not directly executed by the init process. |
| 153 | +- Each of the directories /etc/rc0.d through /etc/rc6.d contain symbolic links to scripts in the /etc/init.d directory. |
| 154 | + |
| 155 | +> "S" stands for "start" and the "K" stands for "kill" |
| 156 | +
|
| 157 | +--- |
| 158 | +<!-- _class: invert --> |
| 159 | + |
| 160 | +# Some commands to manipulate Linux runlevel |
| 161 | + |
| 162 | +--- |
| 163 | +<!-- _class: invert --> |
| 164 | + |
| 165 | +# Commands |
| 166 | + |
| 167 | +## Current runlevel of the system `sudo runlevel` |
| 168 | +> "N" means has not changed since the boot. |
| 169 | +
|
| 170 | +## Default runlevel `systemctl get-default` |
| 171 | + |
| 172 | +## Current loaded targets`systemctl list-units --type target` |
| 173 | + |
| 174 | +## Change runlevel `sudo systemctl set-default runlevel.target` |
| 175 | + |
| 176 | +--- |
| 177 | +<!-- _class: invert --> |
| 178 | + |
| 179 | +# Thank you ! <!-- fit--> |
0 commit comments