How does linux boot?

1. The machine's boot firmware loads and runs a boot loader program. The bootloader finds the kernel image from the disk and loads it to main memory (RAM) and starts it.
2. The kernel looks for devices (cpu, memory, disk devies etc) and initializes them.
3. Kernel mounts the root filesystem, takes the root partition we define in the disk and mounts it at /
4. Then the kernel starts a program called
init which has a process ID of 1. This point is the user space start.
5. The init process then starts all the rest of the processes needed for normal usage. Towards the end of the this, it starts a process which lets you log in and the rest is a bunch of user space processes managed by the kernel as we know.
In step 1, when the bootloader starts the kernel, it passes a set of parameters. These parameters decide where the kernel resides in the disk and how the kernel starts. You can check these parameters by running

$ cat /proc/cmdline
The parameters include the location of the kernel image in disk and also the UUID of the root partition of the disk in order to mount it at /

You can cross check the UUID of the root partition by running

$ sudo blkid
Interestingly, to read from the disk we need to traverse the root filesystem and the kernel device drivers to access to disk. For both of these to be available we need to have the kernel loaded into the memory and the filesystem mounted. This is similar to the chicken egg problem
CC : @thetronjohnson @avron_raji @SubinSiby @asxyzp @shibija1 Feel free to add to/correct the thread :)
You can follow @fillerInk.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: