Live data from Hacker News

Ask HN: Where can I find a primer on how computers boot?

news.ycombinator.com

11–20 of 96 posts

Re: Ask HN: Where can I find a primer on how computers boot?

#11
It might be easier to study something other than an x86 PC, at least to start with. There's so much legacy in x86 that's distracting.

This post[1] has an animated image that's pretty helpful: https://embeddedinn.xyz/images/posts/rvLinuxQemuBoot/bootAni...

It's of course specific to one platform, but the visualization of building up a structures in memory with the right offsets/order and jumping in is pretty typical.

[1] https://embeddedinn.xyz/articles/tutorial/RISCV-Uncovering-t...

Re: Ask HN: Where can I find a primer on how computers boot?

#14
Here are a couple of resources I think can help you:

- old x86 PCs boot in BIOS mode: https://opensource.com/article/17/2/linux-boot-and-startup

With BIOS, your PC initializes hardware and contains firmware drivers for reading disk drives. BIOS loads the first sector (MBR) from the selected boot drive to a fixed memory location and jumps to it. Everything else is up to the bootloader (BIOS still provides methods for reading disk, interacting with the keyboard/moues and text or (S)VGA video output). GRUB2 is saved to the disk in two stages: Stage 1 is - new x86 PCs and some ARM use UEFI: https://hackaday.com/2021/11/30/whats-the-deal-with-uefi/

UEFI works similarly, but is cross-platform (can work on x86, x86_64, itanium, 32bit and 64bit ARM, possibly on RISC-V). UEFI doesn't look for boot drives but for EFI applications (bootloaders) on a special EFI System Partition (uses FAT32 filesystem per spec, but can be any filesystem your UEFI firmware has a driver for). The firmware then loads the configured UEFI application and runs it (it also provides services for input devices, disks, networking, display). GRUB does the same as above.

The only difference is if you are using a distribution that has a signed bootloader (using Microsoft's UEFI CA) probably also check whether the kernel and 3rd party modules are signed using distribution's or your (owner's) signing keys.

- other ARM devices and most MIPS, RISC-V commonly use U-Boot with Device Tree (as without UEFI or ACPI, there has to be a way to inform the kernel of basic non-PNP hardware and how to communicate with it).

Re: Ask HN: Where can I find a primer on how computers boot?

#15
https://osdev.org has a lot of resources about this.

Your computer and all of its hardware are built on standards. For the most part, they are adhered to by hardware and BIOS manufacturers. GRUB et al are just abstracting those away because they're obtuse and not very ergonomic to work with from day to day.

Re: Ask HN: Where can I find a primer on how computers boot?

#17
Installing Arch is a great way to learn. As you go step by step you'll learn the parts of the OS, and kind kind of grok why they're there (and when you'll inevitably skip a step, you'll learn more). It's also a great system to have total control over your OS. And since you built it yourself you can fix it yourself.

Re: Ask HN: Where can I find a primer on how computers boot?

#19
Plenty of good links here already. I'll just add that booting is enormously complex, and starts well before any of the dozen comments so far. I skimmed many of them (not all) and they all tell pretty much the same story whether on real hardware or virtual.

But modern real hardware first boots a Management Engine (or BMC, or T2, or similar), which prepares things and starts subsystems like hardware controllers, before releasing the CPU where the "OS" finally boots, blissfully unaware that it is running on an abstraction.

Watch https://www.youtube.com/watch?v=36myc8wQhLo from about 10:00 to about 20:00 for a decent super high level overview.

These two are also good for a deeper understanding.

https://i.blackhat.com/USA-19/Thursday/us-19-Davidov-Inside-...

https://i.blackhat.com/USA-19/Thursday/us-19-Krstic-Behind-T...

They both cover UEFI, even though the focus is on T2.

I know that's well beyond what you were asking for, but the boot process goes well beyond GRUB.

Re: Ask HN: Where can I find a primer on how computers boot?

#20
Here's a write up I found recently.

> This is a discussion of what happens when a CPU chip starts. It may be thought of as what happens when a whole computer starts, since the CPU is the center of the computer and the place where the action begins.

https://lateblt.tripod.com/bit68.txt

Post reply on HN