Hacker News new | past | comments | ask | show | jobs | submit login

Believe it or not, you don't even need a physical disk to boot at all (on many systems).

The first step in the boot process is loading the boot firmware. On a BIOS/UEFI PC, this gives you Preboot Execution Environment (PXE) [0]. Raspberry Pi boards have something similar since the Pi 3, though it's not exactly PXE. Network booting allows you to setup a DHCP server in a way that automatically serves the machine a kernel, initramfs, and cmdline over the network. You can run a full Linux that way, though you probably want to switch_root [1] to another filesystem that has a block device backing it with more storage, for practical purposes. This is what most initramfs images do.

Once the machine can automatically retrieve those three, you're set. The initramfs can be built with whatever binaries, firmware, and kernel modules you need to initialize the network and set up an NBD or NFS share. Add `root=/dev/nbd0` or whatever, and you're running over the network.

Same concept applies to booting with a split boot partition. The boot partition contains the kernel, initramfs, and bootloader, along with the boot configuration. The kernel cmdline specifies which disk contains the root filesystem. It need not be on the same disk as the kernel, or even on the same machine.

[0] https://en.wikipedia.org/wiki/Preboot_Execution_Environment

[1] https://landley.net/writing/rootfs-programming.html




Many thanks for the detailed response. This is probably the part that was missing in my mind

>The kernel cmdline specifies which disk contains the root filesystem.


Absolutely. It's a part of the kernel I find very interesting.

Here's a related bit from the kernel docs that describes the initramfs and switch_root in more detail.

https://www.kernel.org/doc/Documentation/filesystems/ramfs-r...

Interestingly, there's even a mechanism for leaving programs running even after exiting the initramfs.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: