
Inside the Linux boot process (2006) - kercker
https://www.ibm.com/developerworks/library/l-linuxboot/
======
r4um
This is very old, for a more recent version [https://github.com/0xAX/linux-
insides](https://github.com/0xAX/linux-insides)

~~~
therein
One of my favorite guides on anything.

------
lkurusa
I appreciate the article is from 2006, but it would be nice to see a similar
write up for recent EFI-based machines and maybe other architectures, as well.

~~~
mastax
I just did a lot of reading about EFI to get my system booting again, so I'll
write a bit about it. Cunningham's law and all that.

On system startup, the CPU begins executing from the EFI ROM - a few-megabyte
chip on the motherboard somewhere. The EFI is essentially a simple (won't say
_small_ ) OS: it can enumerate devices and partitions, mount filesystems, draw
graphics, and connect to the internet (shudder). It provides APIs for these
capabilities to the loaded EFI executables. EFIs are either 32-bit or 64-bit
so its boot code must switch from real mode at some point.

After handling whatever system initialization, the EFI looks through the
connected disks in the order configured by the user, searching for an EFI
system partition. This partition is FAT32 and has a special GPT partition
attribute to mark it. These partitions are usually 100-500MB and are usually
the first partition on the disk. If found, the EFI mounts this partition.

At this point, the boot process depends on the value of various EFI variables,
which you can inspect with the `efivar` command on linux. These instruct the
EFI bootloader to load various EFI executables, which are PE-format but
otherwise fairly normal. First it will load any drivers specified by the
`Driver####` and `DriverOrder` variables, which could be used to enable the
EFI bootloader to load from e.g. a RAID controller or a BTRFS partition. I
haven't seen this used in practice, however. Next it will run an executable
specified by a `Boot####` variable, depending on the `BootNext` or `BootOrder`
variables or a user-selection at the EFI boot menu. These EFI applications are
stored in vendor-specific directories of the EFI system partition like
`/EFI/Fedora/shimx64.efi`. These applications are usually either an EFI shim
which executes a traditional bootloader, or a traditional bootloader compiled
as an EFI application. EFI could also be used to directly boot a kernel, such
as linux compiled with EFISTUB enabled.

If the EFI isn't able to boot any of the registered entries, it will usually
run the EFI Shell (if installed) or try to run whatever is at
`/EFI/BOOT/bootx64.efi`.

~~~
JdeBP
You made an incorrect assumption about real mode.

* [https://superuser.com/a/345333/38062](https://superuser.com/a/345333/38062)

------
amelius
How difficult would it be to register the dependencies of the boot process,
and only run the full boot process when those dependencies have been touched,
using a generated and quickly loadable binary image otherwise?

~~~
icebraining
I think most of the boot process is initializing hardware, so I don't see how
you avoid it.

~~~
amelius
How come recovering from hibernation is much faster then?

My (perhaps overly simple) conclusion is that the boot process is doing stuff
it doesn't need to do.

~~~
userbinator
The boot process does hardware detection and configuration, while resuming
from hibernate basically involves nothing more than writing the last-saved
configuration back to the hardware. It's relying on the assumption that the
hardware hasn't changed since it was last hibernated.

~~~
amelius
> It's relying on the assumption that the hardware hasn't changed since it was
> last hibernated.

Which is also true in 99% of cases when I boot.

------
dvfjsdhgfv
I'm sorry but the article has very little to do with the actual boot process
of modern distributions.

~~~
sverige
I run modern distributions and it describes at a high level the way my dual
boot (and modern) laptop works. Not everyone uses EFI and systemd or Windows.

------
stevekemp
The comments on that article look like they've been mangled at some point in
the past!

~~~
sml156
It's like bash gone wild, look at one of the links they actually work

http:\/\/tldp.org\/HOWTO\/Bootdisk-HOWTO\

Edit: I'm using Firefox

------
usr1106
article is from 2006

~~~
std_throwaway
...and references the good old Reiser file system.

~~~
IntelMiner
Reiser jokes always kill

------
okket
(2006)

~~~
jsjohnst
Title clearly says that, no?

~~~
lkurusa
It didn’t when it was posted, probably a helpful moderator fixed it.

