<div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div bgcolor="#ffffff" text="#000000"><blockquote type="cite">
      
      I want to know the basics linux booting process. I googled for
      this but i didn&#39;t find the detailed things anywhere. I want to
      know the boot process including the hardware work flow. Can anyone
      give me the detailed tutorial to learn about this.<br>
      <br>
    </blockquote>
    First, when you power up the system the bios goes through a POST,
    which is power-on self test. This just checks that hardware is
    working, etc. Then it looks for a boot sektor, which must be 512
    bytes long and end with a magic number, and loads the kernel. From
    there, you can look at the head.s assembly, and I think someone
    posted a tutorial here a while back--maybe they&#39;ll post that again.</div></blockquote><div> </div><div><ol><li>The POST (Power-On-Self-Test) is done. POST checks all the processors that are connected, the amount of RAM available, disks that are connected, network cards available etc. <br>

</li><li>Then the BIOS (Basic Input/Output Services) program is loaded. The BIOS searches for IDE, SCSI, PATA drives. Then it searches for active (bootable) partition(s). Using this knowledge, it checks the information in the Master Boot Record (MBR) of the drive (that has the active partition(s)). Then, it loads the bootloader (mostly GRUB - Grand Unified Bootloader) from the MBR.<br>

</li><li>Grub knows how to read all kinds of partitions. So, it can boot from any file system.</li><ol><li>It checks and loads the settings in /boot/grub/grub.conf. This file contains path for root = (hd0,0), kernel = vmlinuz, initrd = initrd.img (cpio archive).</li>

<li>The Linux kernel is loaded into the RAM. It knows how to unpack the cpio archive which was specified by initrd parameter in grub.conf. The kernel loads this unpacked initial RAM disk and root file system (also called initramfs) into the RAM. Then it starts executing the /etc/init file present in this initramfs.</li>

<ol><li>initrd: It contains the initial RAM disk and the initial root file system. These are loaded into the RAM before the actual root file system from the hard disk is loaded.</li><li>ntldr: In case another bootloader is required to be loaded, then the &#39;chainloader+1&#39; command tells grub to load the bootloader mentioned. ntldr is the Windows bootloader. In Windows, all drives are loaded in user-space.<br>

</li></ol></ol><li>init starts populating /dev with the devices that are connected. init inserts kernel modules (.ko files) to detect the connected hardware.</li><ol><li>init loads the hard disk. Then, init &quot;switches root&quot; to the root file system in the hard disk. Finally, before terminating, this init file of the initramfs passes control to the init file in the hard disk.</li>

<li>init loads the partitions which are mentioned in /etc/fstab.</li><li>Then, all the files up to and including the required &quot;init level&quot; are executed.</li><ol><li>These include rc.sysinit, rc.local (directory) and rcX.d (directory - where X refers to a whole number).</li>

<li>If you check the /etc/rc0.d directory, you will find symlinks starting with either a &#39;K&#39; or a &#39;S&#39;. This is followed by a number. This convention is followed purposely. All symlinks with a starting K are &#39;kill&#39; commands. All symlinks with a starting S are start commands. All the symlinks are followed in lexicographic order. So, all the kill commands are executed first (K00*, K01* etc.), followed by the start commands (S00*, S01* etc.).</li>

<li>So, if you want to boot to init level 1, then all the commands in /etc/rc1.d directory are executed. If you want a Graphical Environment (i.e., init level 5), then all commands from rc1.d up to rc5.d are executed.</li>

<li>init level 0 is for shutdown and init level 6 is for restart (i think; not sure about init level 6).</li></ol></ol></ol>This is a brief introduction to the boot process. Modern OSs require much more than these basic things. Also, this boot process refers to the SysVInit model. Then is another model used by Upstart, which Ubuntu uses. Watch this video to learn more about Upstart: <a href="http://www.youtube.com/watch?v=ssnZBQqnze8">http://www.youtube.com/watch?v=ssnZBQqnze8</a><br>

<br>Hope this helps!<br><br>Rigved Rakshit<br></div></div>