Client Devices‎ > ‎Linux PC‎ > ‎

Ubuntu Boot Overview

When you power on your computer what is most likely the first thing that you do? Log in, right? Correct, however, while logging in may be the first thing that we do or notice when powering on a computer, user-space is the last thing a Linux system thinks about when powered on. There are multiple stages underlying the boot process to any distro of Linux. It is also a very flexible and resilient process; supporting a wide range of hardware, variety of boot loaders, ability to change runlevels, and manipulate configuration files such as /etc/default. Let’s get started.
  • The following are the steps take by a Linux system when powered on or restarted to complete the boot process.
    • BIOS- When a system is powered on the BIOS (basic input output system) is loaded and the boot process is initiated. BIOS will first identify the default primary boot device. Next BIOS will load and execute the MBR boot loader. Handing control over to the MBR
    • MBR- The Master Boot Record is the first 512 bytes of a storage device. This small space is cut up into a few crucial parts to continuing the boot process. The primary boot loader info, a small partition table, and a validation check of the MBR. The partition table will be scanned in search for the boot loader so GRUB can be loaded.
    • GRUB- This stage is where GRUB takes control and you can choose which operating system to boot from. If you do not make a selection before the timeout the default kernel will be loaded automatically. In short terms, the job of GRUB is to load the kernel into memory.Once the kernel and initrd images are invoked the next stage begins.
      • Configuring GRUB:
        • To configure GRUB you can edit the configuration file /etc/default/grub
        • You would want to configure GRUB if you have multiple kernels on your system.
        • In this file you will find a few interesting things you can change.
          • GRUB_DEFAULT=0
            • This specifies the default menu entry. Menu entries are numbered by a system that starts from 0 and counts up (like most nerd counting systems). To change the default entry simply change the number specified in the line. Setting the variable to 'saved' causes GRUB to boot from the most recently booted menu entry.
          • GRUB_HIDDEN_TIMEOUT=0
            • This specifies the number of seconds GRUB will display a blank screen before displaying the boot menu. That is why it is called a 'hidden' timeout. GRUB will ignore this variable if the system has multiple bootable systems.
          • GRUB_HIDDEN_TIMEOUT_QUIET=true
            • This specifies if a countdown will appear on the blank screen during the hidden timeout. Setting to 'true' will not display the timer. Setting to 'false' will display it.
          • GRUB_TIMEOUT="10"
            • This is the number of seconds GRUB will wait before starting the system from the default entry. Setting to -1 will cause the system to wait indefinably until initiated otherwise by the user.
    • Kernel- This is where the operating system begins to unpack its things and bring the operating system to life. Not only is the kernels job is to locate the root partition a mount it, it is also responsible for managing processes and starting the init daemon. Once the root partition has been found and mounted, Upstart is initiated.
      • When the main upstart binary is executed (/sbin/init) it will be ran as PID 1 and Upstart will have control.
        • The startup process will then begin. Upstart will perform its internal initialization and then emit a single even called 'startup', this event triggers the rest of the system to then initialize. Among the few jobs ran by init is the 'mountall' job which will mount all your disk and filesystems. Once the last filesystem is mounted, the 'mountall' job will emit the 'filesystem' event. Now the rc-sysinit.conf file will come into play. In this file the 'start on' condition for the rc-sysinit job is "start on filesystem and net-device-up IFace=Io", the rc-sysinit job is started. This job will execute the 'telinit' command with the default runlevel argument specified by DEFAULT_RUNLEVEL=2. Next the runlevel event triggers many more upstart jobs to start, including the legacy SystemV init system.
    • Upstart - Upstart is the last piece to the boot process and the first process to be ran by the system. Upstart replaces the old traditional System V init daemon. The old SysVinit daemon works by using traditional runlevels and init scripts to start and stop services. When a runlevel is entered by the system, that runlevels config file is accessed at /etc/rcn.d (n being the runlevel number). /etc/rcn.d contain links to the init scripts located at /etc/init.d, these scripts are ran to start and stop the services specified in /etc/init.d. The new Upstart init daemon is event based and will run specified programs when something changes on the system, rather than when a runlevel is changed. 
      • What does this mean?
        • Well, it means that true runlevels no longer exist. However, the new Upstart system does emulated runlevels to help ease the migration from old to new.
          • The runlevels are as followed:
          • 0 : System halt.
          • 1 : Single-User mode.
          • 2 : Graphical multi-user plus networking.
          • 3 : Same as '2', not really used.
          • 4 : Same as '2', not really used.
          • 5 : Same as '2', not really used.
          • 6 : System reboot.
        • This new Upstart concept is still relatively similar to the old way, and much more flexible. 
        • Instead of using links to the init scripts to start and stop services when the system enters a runlevel and the rc is executed, upstart can start and stop services upon receiving info that something on the system has changed. These changes that occur are called 'events'. 
        • To list these events with a brief description use the following command: # event 2 | grep signalling.
        • Use the 'service' command to start and stop upstart services:
          • sudo service <servicename> start | stop
        • If you wish to disable an upstart service from starting up you can open the respective /etc/init/[service].conf file with a text editor and put a # at the beginning of the line that says "start on".
      • Files: Ubuntu systems now have both the old SysVinit files and the new Upstart files.
        • /etc/init
          • This file is where Upstart stores all the 'jobs'. These jobs usually contain an event and a command for the event. When the event is triggered init will execute the command.
        • /etc/init.d
          • This is where all the old SysVinit scripts can be found
        • /etc/fstab
          • Contains a list of all mountable devices. 
          • Specifies where are file systems are mounted. Most of these are automatically mounted when the system boots. 
          • The fstab has six columns specifying the following:
          • Name - This is where name of the logical block device.
          • Mount point- The name of the directory file where the filesystem/directory is to be mounted on
          • Type - The type of filesystem such as ext2,3,4 or ntfs
          • Mount options - This is where the mount options are listed. Such as if the file is mounted with read and write privileges or just read.
          • Dump - Determines when to backup the filesytem.
          • Fsck- Specifies the order in which fsck checks the file systems. The root filesystem (/) should have a 1 in this column.
Comments