In this bog posting, I will present a boot sequence that works for all Linux-based operating systems – from switching on the power to the login screen.

 

7 steps

There are 7 steps for Linux startup:

1

Power on

Obviously, first of all, you have to switch on your computer, then:

  • Each sub process will execute the following one
  • It is the same process for all Linux distributions
  • Close to BSD and Unix style from which it derives
  • Same as Microsoft’s procedure until MBR stage

2

BIOS (Basic Inpout Output System)

  • First firmware executed at startup
  • Inits motherboard hardware components
  • Performs some system integrity checks (i. e. memory)
  • Abstraction layer between hardware and software
  • Searches and executes the boot loader program from MBR disk

3

MBR (Master Boot Record), bootlader stage 1

  • Located on the first sector of booted disk (512 bytes)
  • Contains location and data about 2nd bootloader stage, inside bootloader code section

MBR

  • Partition table (MS DOS limited to 4 primary partitions)
  • Signature helps BIOS to identify from which disk it executes the bootloader code

4

Bootloader, stage 2

  • Located on a disk partition
  • Loads operating system kernel and options

You can choose several bootloader software:

  • Grub, GRand Universal Bootloader
  • Lilo, LInux LOader

Grub configuration (< v1.0) :

Grub version < v1.0 uses a singe configuration file, in which all operating systems and kernel options have to be written by hand.

[root@oel-test ~]# cat /boot/grub/menu.lst

default=0

timeout=5Grub1

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title Oracle Linux Server-uek (2.6.39-200.24.1.el6uek.i686)

root (hd0,0)

kernel /vmlinuz-2.6.39-200.24.1.el6uek.i686

Grub 2 configuration (> v1.0) :

Grub version > v1.0 (Grub 2) allows to use automatic search and configuration mechanism that updates the menu.lst file:

[root@oel-test ~]# grub-mkconfig

[root@oel-test ~]# upgrade-grub2


Moreover, if needed, we can add customization during these processes:

[root@oel-test ~]# vim /etc/default/grub # common configuration file for all Operating systems

[root@oel-test ~]# ls /etc/grub.d/* # search and configuration scripts location

[root@oel-test ~]# upgrade-grub2

warning #> upgrade-grub2
will overvrite /boot/grub/menu.lst

 

5

Kernel

Kernel

  • Located on a disk partition
  • Contains drivers for hardware support
  • Lowest Operating System software layer
  • Enables multi-task support (scheduler)
  • Mounts root file system
  • Executes init program
    • Usually, an “initrd”, INITial RamDisk (filesystem mounted temporarely in RAM memory), is needed

6

Init processinit_debian

The Init process comes first in the operating system startup and defines the running state (Runlevel):

0 – Halt
1 – Single user mode
2 – Multiuser, without NFS
3 – Full multiuser mode
4 – Unused
5 – Full multiuser and graphical mode
6 – Reboot

Default configuration file location:

[root@oel-test ~]# cat /etc/inittab

id:5:initdefault:

7

Runlevel service script organization:

Runlevel scripts are organized acoording to a strict naming convention, allowing their execution order and purpose:

runlevel_script

It is possible to invoke a manual action related to a service:

[root@oel-test ~]# /etc/init.d/service_name start|stop|restart|status|reload

Starting service : [ OK ]

[root@oel-test ~]# service service_name start|stop|restart|status|reload

 

runlevel_config_debian

Runlevel service script configuration

It is possible to manage service execution scripts using more high-level commands:

chkconfig [–level levels ] service_nqme on|off|reset

[root@oel-test ~]# chkconfig –level 2345 ntpd on

[root@oel-test ~]# chkconfig –list ntpd

ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

It is also possible to use a graphical tool:ntsysv

[root@oel-test ~]# ntsysv –level 5

8

That’s it!

login_screen