Content deleted Content added
m formatting fix(es), replaced: ,''' → ''', (3) |
Remove bolding that no longer works as intended since refs cannot be bolded anymore (may have been able to before, before my time on Wikipedia probably) |
||
Line 1:
{{Short description|Multi-stage initialisation process}}
The Linux [[booting]] process involves multiple stages and is in many ways similar to the [[BSD]] and other [[Unix]]-style boot processes, from which it derives. Although the Linux booting process depends very much on the computer architecture, those architectures share similar stages and software components,{{Sfn|M. Tim Jones|2006|ps=, "The process of booting a Linux® system consists of a number of stages. But whether you're booting a standard x86 desktop or a deeply embedded PowerPC® target, much of the flow is surprisingly similar."|loc="Introduction"}} including system startup, [[bootloader]] execution, loading and startup of a [[Linux kernel]] image, and execution of various [[startup scripts]] and [[Daemon (computing)|daemons]].{{Sfn|M. Tim Jones|2006|ps=, "Figure 1. The 20,000-foot view of the Linux boot process"|loc="Overview"}} Those are grouped into '''4 steps''': '''system startup''', '''bootloader stage''', '''kernel stage''', and '''init process'''.{{Sfn|M. Tim Jones|2006|ps=|loc="Linux booting process are grouped into 4 stages, based on IBM source"}} When a Linux system is powered up or reset, its processor will execute a specific firmware/program for '''system initialization''', such as [[Power-on self-test]], invoking the reset vector to start a program at a known address in flash/ROM (in embedded Linux devices), then '''load the bootloader into RAM''' for later execution.{{Sfn|M. Tim Jones|2006|ps=, "Figure 1. The 20,000-foot view of the Linux boot process"|loc="Overview"}} In personal computer (PC), not only limited to Linux-distro PC, this firmware/program is called [[BIOS]], which is stored in the mainboard.{{Sfn|M. Tim Jones|2006|ps=, "Figure 1. The 20,000-foot view of the Linux boot process"|loc="Overview"}} In embedded Linux system, this firmware/program is called [[boot ROM]].<ref>{{Cite book |last1=Bin |first1=Niu |title=2020 International Symposium on Computer Engineering and Intelligent Communications (ISCEIC) |last2=Dejian |first2=Li |last3=Zhangjian |first3=LU |last4=Lixin |first4=Yang |last5=Zhihua |first5=Bai |last6=Longlong |first6=He |last7=Sheng |first7=Liu |date=August 2020 |isbn=978-1-7281-8171-4 |pages=5–8 |chapter=Research and design of Bootrom supporting secure boot mode |doi=10.1109/ISCEIC51027.2020.00009 |chapter-url=https://ieeexplore.ieee.org/document/9325327 |s2cid=231714880}}</ref>
For each of these stages and components, there are different variations and approaches; for example, [[GNU GRUB|GRUB]], [[coreboot]] or [[Das U-Boot]] can be used as bootloaders (historical examples are [[LILO (boot loader)|LILO]], [[SYSLINUX]] or [[Loadlin]]), while the startup scripts can be either traditional [[init]]-style, or the system configuration can be performed through modern alternatives such as [[systemd]] or [[Upstart (software)|Upstart]].
== System startup ==
'''System startup''' has different steps based on the hardware that Linux is being booted on, especially between embedded Linux and Linux PC.
The '''system startup stage on embedded Linux system''' starts by executing the firmware/program on the '''on-chip boot ROM''', which is stored on the storage device of the system like USB flash drive, SD card, eMMC, NAND flash, NOR flash, etc.
== Bootloader stage ==
The '''first stage bootloader''', which is a part of the MBR, is a 512-byte image containing the vendor-specific '''program code''' and a '''partition table'''.
In x86 PC, '''first- and second-stage bootloaders''' are '''combined into''' the [[GNU GRUB|GRand Unified Bootloader]] ('''GRUB'''), and formerly Linux Loader ([[LILO (bootloader)|LILO]]).
Beside GRUB, there are some more popular bootloaders:
Line 28:
== Kernel ==
The kernel stage occurs after the bootloader stage. The [[Linux kernel]] handles all operating system processes, such as [[memory management]], task [[scheduling (computing)|scheduling]], [[I/O]], [[interprocess communication]], and overall system control. This is loaded in two stages – in the first stage, the kernel (as a compressed image file) is '''loaded into memory''' and '''decompressed''', and a few fundamental functions are set up such as basic memory management, minimal amount of hardware setup.
For details of those steps, take an example with [[i386]] microprocessor. When its bzImage is invoked, function <code>start()</code> (of <code>./arch/i386/boot/head.S</code>) is called to do some basic hardware setup then calls <code>startup_32()</code> (located in <code>./arch/i386/boot/compressed/head.S</code>).
<code>start_kernel()</code>executes a wide range of initialization functions. It sets up [[interrupt handling]] ([[Interrupt request|IRQ]]s), further configures memory, mounts the [[initrd|initial RAM disk]] ("'''initrd'''") that was loaded previously as the temporary root file system during the bootloader stage
The root file system is later switched via a call to <code>pivot_root()</code> which unmounts the temporary root file system and replaces it with the use of the real one, once the latter is accessible.
Finally, <code>kernel_thread</code> (in <code>arch/i386/kernel/process.c</code>) is called to start the Init process (the first user-space process), and then starts the idle task via <code>cpu_idle()</code>.
Thus, the kernel stage initializes devices, mounts the root filesystem specified by the bootloader as [[file system permissions|read only]], and runs [[Init process|Init]] (<code>/sbin/init</code>) which is designated as the first process run by the system ([[Process identifier|PID]] = 1).<ref name="oldfield">http://oldfield.wattle.id.au/luv/boot.html Linux Boot Process - by Kim Oldfield (2001)</ref> A message is printed by the kernel upon mounting the file system, and by Init upon starting the Init process.<ref name="oldfield" />
Line 46:
== Init process ==
Once the kernel has started, it starts the [[init]] process
Historically this was the "SysV init", which was just called "init". More recent Linux distributions are likely to use one of the more modern alternatives such as [[systemd]]. Below is a summary of the main init processes:
|