Skip to main content

How a Linux System boots. What happens when you push the power On button...

Booting is a process when a computer system initializes itself and loads the operating system(OS).

So what happens during a boot process on a Linux machine (this post is relevant to Ubuntu, however most systems would do similar steps) ?
  • When you push the power on button, the BIOS (Basic Input/Output System) loads from the ROM present on the motherboard
  • BIOS
    • It launches the Power On Self test (POST) which involves starting the hardware specifically the screen and the keyboard and testing of the RAM i.e. main memory 
  • Boot Loader
    • Once the POST completes, the boot loader takes over. The boot loader is present on the hard disk and for Linux systems the common ones are GRUB and ISOLINUX. Depending on the type of system i.e BIOS/MBR or EFI/UEFI the location of the boot loader varies. For the former it is present at the boot sector and for the latter it is in EFI partition
    • Common boot loaders for Linux are GRUB and ISOLINUX.The boot loader is  responsible for loading the kernel as well as initramfs and it does this in two stages
      • For BIOS/MBR systems the boot loader is located at the Master Boot Record which is the first sector of the hard disk. The bootloader finds a bootable partition after reading the partition table. It then searches for the stage two bootloader e.g. GRUB and loads it in the main memory. For EFI/UEFI systems, the UEFI firmware reads the data from the Boot Manager looking for an entry named GRUB (UEFI location) and determines its location (partition etc.). The GRUB is located at /boot. Incase the system has multiple OS a screen is provided for a choice. After a selection is made, the boot loader loads the respective kernel in RAM. The kernel takes over and uncompresses itself, it analyzes the hardware (processors, I/O subsystems, storage devices) and loads the device drivers present in the kernel and certain necessary user space applications
      • The bootloader also loads the initramfs (Initial RAM Disk) which is a filesystem image containing programs,binary files which help to mount the proper root filesystem. It must also contain drivers which are necessary for accessing the hard disk etc.It uses a component called udev (for User Device) which is responsible for figuring out which devices are present, locating the drivers they need to operate properly, and loading them. After the root filesystem has been found, it is checked for errors and mounted on the mount point. 
    • At this stage the file system is mounted and after this the init (/sbin/init) program is then executed after clearing the initramfs from the RAM. The init process launches other processes except the kernel processes required for the internal working of the OS. It launches the text login prompts i.e shell using getty.
    • The X Window System is loaded as the final step in the boot process. Sometimes the process stops at the text login in that case we can use startx command to launch the X Window System.(Usually Alt + (F1-F6) are text logins and Alt + F7 is the GUI login). The X Window System consists of a display manager to track the displays and load X server, load the appropriate desktop login. The desktop environment has a session manager, which is responsible for starting and maintaining the components of the graphical session. It also has the window manager, which controls the placement and movement of windows, window title-bars, and controls.
  • And  now you have your GUI login ready.

Comments

Popular posts from this blog

Formatting JSON in Kate - KDE Editor

Some years ago, I wrote a post on Formatting XML in Kate - KDE Editor . This one  below is for JSON format. Like the XML one this one also makes use of a tool installed on your machine and is invoked from Kate as a filter. TLDR;   Kate  is one awesome editor ( If you don't like  Vim  for its 'CLI'ness ) When working from the command line we can use a handy tool ' jq ' to format JSON files and pretty print them. Well, the good news is we can use the same from within Kate  as well But it is a tedious task to use it when you have some content in  Kate  ( more so if it is an unsaved file ) and want to format it. Incase, you don't have  jq  installed, simply hit sudo apt-get install jq and that will install it for you. If you use  jq  you would do something like this, Save File (  MySavedFile.xml  ) Go to Command Line cat MySavedFile.txt | jq '.' - > MySavedFile.txt and then reload our file in  Kate . If you wish t...

Formatting XML in Kate - KDE Editor

TLDR;   Kate is one awesome editor ( If you don't like Vim for its 'CLI'ness ) When working from the command line we can use a handy tool ' xmllint ' to format XML files using its --format option. But it is a tedious task to use it when you have some content in Kate ( more so if it is an unsaved file ) and want to format it. Incase, you don't have xmllint installed, simply hit sudo apt-get install libxml2-utils and that will install it for you. If you use xmllint you would do something like this, Save File ( MySavedFile.xml ) Go to Command Line cat MySavedFile.txt | xmllint --format - > MySavedFile.txt and then reload our file in Kate . If you wish to remain in Kate and get this done then you would need to do, Select text ( Complete or Partial ) Hit ' Ctrl + \ '  or go to Tools -> Filter Text Incase your Kate does not have the option for 'Filter Text' under tools, you just need to enable the 'Text F...

Set default profile for Konsole on Ubuntu

The option for changing the default profile is not present in konsole (atleast not in Ubuntu 12.04 LTS). It is really irritating to switch profiles whenever I open a new tab. However, we can change it via the config file. The config file is usually present in the home folder /home/username/.kde/share/config/konsolerc It will look something like this, [$Version] update_info=konsole.upd:2.9.0-global-options [Colors] CurrentPalette=Forty Colors [Desktop Entry] DefaultProfile=NewDawn.profile [Favorite Profiles] Favorites=/home/username/.kde/share/apps/konsole/Shell.profile,/home/username/.kde/share/apps/konsole/NewDawn.profile [MainWindow] Height 900=901 State=AAAA/wAAAAD9AAAAAAAABf8AAANQAAAABAAAAAQAAAAIAAAACPwAAAAA ToolBarsMovable=Disabled Width 1600=1601 You can see in Favorite Profiles, I have added a profile named NewDawn apart from the default one named as Shell. My default profile was Shell.profile which I changed to NewDawn.profile by changing Defaul...