14

I am preparing a document in detail showing light on the boot sequence of Linux right from pressing of Power-on button the host to the login prompt appearance.

It would be great if we could combine and collate that right answers here into a single place of reference. Please include any details worth possible to note during the startup. Once the document gets complete from all the points, I will post the document details here as well and update the link in the question.

Please consider all possible scenarios like booting from disk, booting from usb, booting from network on a disk-less client where the rootfs(/) is on network.

  • 3
    Judging from this (including references) and this, you propose quite a huge project... – sr_ Dec 17 '11 at 10:36
  • 4
    Does this feel like a homework/thesis question to anyone else? – Shadur-don't-feed-the-AI Dec 17 '11 at 14:26
  • if this is a question of thesis and does not fit in UL, please move it to the right QA site. Home work? I do not think so. I have already said that I am preparing to write a detailed document on it, could do so with whatever I could put my hands on but its likely that I might have missed some and with the expert base at UL, it is likely I will get closer in understanding. – Nikhil Mulley Dec 17 '11 at 16:08
  • 1
    Shouldn't it then be flagged as community-wiki? – user unknown Dec 17 '11 at 20:05
  • good idea, makes sense to upload there once I have something concrete and shape. btw, I am not sure whether community wiki exists for UL. Does it? – Nikhil Mulley Dec 17 '11 at 20:19
  • 4
    I think this is far too broad for a question on SE, there are huge variations between distributions and configurations. – Gilles 'SO- stop being evil' Dec 17 '11 at 22:46
  • 1
    can you please post the document prepared by you – Abhishek Jan 21 '12 at 02:43
  • This is by far the best X86/Linux booting presentation I've found. It's over 2hrs and it's dense, lots of assembly and hardware architecture bits, so it's not just Linux commandline stuff. http://excess.org/article/2008/08/oclug-august-kernel-walkthrough-boot-process/ – Marcin Dec 19 '11 at 02:39

2 Answers2

7

You want booting sequence of Linux or just PC booting sequence ... because there is no difference between booting Linux from usb/cdrom/hdd ... Linux is always booting from MBR where the bootloader is ...

Linux boot process:

  1. As power comes up the BIOS is given control
  2. BIOS runs self tests, usually including cursory memory tests.
  3. The BIOS then loads the first sector of the disk to be used for booting and transfers control to it.
  4. The MBR code varies. One version will chain to the code in the first sector of the boot partition (Windows), another will load a bootloader. Windows boot proceeds from code and information in the boot partition.
  5. bootloader chooses kernel location and version
  6. bootloader prepares kernel and initrd image in memory, transfers control to kernel
  7. loading kernel modules
  8. discovering hardware and load additional kernel modules to support it
  9. looking for disks
  10. R/O mount of / partition so that it can potentially be checked and repaired
  11. init process spawn
  12. /etc/inittab read and executing
  13. mounting all FSes from /etc/fstab
  14. runlevels running (based on default runlevel in /etc/inittab) or another init method such as systemd or upstart
  15. rc.local
  16. login prompt
Kevin
  • 40,767
  • Thanks @Sebastian, that was a good list. I am looking for detailed steps for example 1: what loads mbr info, before that how is post and bios instructions are flowing; 2. why r/o mount of / partition and then again read/write mount / partition .. what is process 0 in this whole process.. but thanks for the answer. – Nikhil Mulley Dec 17 '11 at 17:40
  • @Nikhil regarding process 0 ... there is no such process, after kernel load You have process 1, which is init process. Regarding rest of points:
    1. check http://www.ibm.com/developerworks/library/l-linuxboot/index.html
    2. because first it needs to be checked files, then You can start write on it ... it's rather for security reasons ...
    – Sebastian Szary Dec 17 '11 at 23:36
  • There is no MBR on floppies or cdroms. The boot process for cdroms involves a catalog file that describes one or more multi sector images that the bios can choose to load and execute. – psusi May 22 '12 at 13:49
  • What if the kernel modules are on a ext3 file system and the ext3 kernel module is not loaded yet? What's more, what if the kernel itself is on a file system that bootloader doesn't recognize? How is the following things loaded in sequence, loading kernel, loading bootloader, mounting /boot directory, reading /etc/fstab file, etc. – yegle Feb 10 '14 at 07:17
3

Try installing and using bootchart.

nopcorn
  • 9,559
Alexander
  • 9,850
  • 1
    thanks for the pointer, am actually looking to present a visualizing flow document of what happens during boot and what kind of decision making is involved in. – Nikhil Mulley Dec 17 '11 at 16:10
  • 1
    thanks @Alexander I installed it on my fedora and it provides very detailed png – Abhishek Jan 21 '12 at 03:06