Linux Boot Process



 

================================================================================
PART - 1
================================================================================

1] Power On
This time BIOS gets loaded into the RAM.The BIOS software which is
stored in the ROM is called firmware as it communicates with HW.
This process is called Bootstraping.
The main purpose of BIOS is to load any OS.

2] POST
This process is called Power-On-Self-Test.It does Hardware Inventory.

3] CMOS
The thing is called as Complementary-Metal-Oxide-Semiconductor.
BIOS search for OS here as a result it gets the list of 3 bootable
devices.

4] MBR
Called Master-Boot-Record.Which has capacity of 512 bytes.As BIOS
gets into the MBR it loads the contents of MBR into the RAM.

This step is called as FIRST STAGE OF BOOTLOADING.
===================================================

----------------------------------------------------------
MBR is constituted of 3 parts as shown below.

Area Capacity Contents
(1)Boot Sector 446 bytes Contains Bootloader of any OS.

(2)Partition Table 64 bytes Contains entries regarding
partitions on HDD.

(3)Magic No. 2 bytes Flags regarding to OS.

----------------------------------------------------------

5] BIOS then executes the Bootloader in the MBR & transfer the control to it.

6] Anaconda loads LILO behind the currently present Bootloader at the time of
installation. So Bootloader contains LILO bootloader. So LILO gets executed.
===============================================================================

ANACONDA

Anaconda does following things during installation
(1) Loads LILO in the Boot Sector behind the current Bootloader.

(2) Writes partitions in partition table.

(3) Puts Magic No. i.e. flags regarding the MBR status of Bootloader.

(4) Examines the conf. file of LILO which is in /etc directory called lilo.conf. Anaconda converts it in 1's & 0's & stores it in Boot Sector of MBR.
----------------------------------------------------------
The lilo.conf file in /etc directory is run by lilo -t. This command
checks the conf. file first & gives result regarding it's status but
doesn't write the MBR. After getting proper results we can modify MBR
by the command lilo -v(verbose).

lilo -v command does following things
1} It reinstall LILO Bootloader in the Boot Sector of MBR
2} Examines /etc/lilo.conf & compiles(convert to binary) & then
installs this in the Boot Sector of the MBR near LILO provided no
error in the conf. file.
3} Reinstalls the map file located in /boot/map examining lilo.conf
file for location of the kernel.
----------------------------------------------------------

(5) Creates the message file in the /boot partition which contain linux splash
screen,also creates a map file in /etc partition containing 2 fields called
partition no. & location of kernel,it also creates system.map file in /boot
partition which contain startup sequence log of Linux.

(6) It also creates the backup of MBR in boot.0300 if HDD is IDE & boot.0800 if
HDD is SCSI.
================================================================================

7] Now in lilo.conf file LILO checks the prompt which gives directives to LILO
i.e. it directs the LILO to the labels in the lilo.conf & throws it on screen reading default label & timeout given in deciseconds.

8] Now LILO searches for Linux kernel i.e. /boot/vmlinuz 2.4.20.8.

9] But having no knowledge LILO reads the partition table & then loads another
file called /etc/boot.b.

This step is called as SECOND STAGE OF BOOTLOADING
===================================================

10] Now boot.b calls another file called /boot/map which contain detail entry
about partition having Linux kernel.

===============================================================================
PART - 2
================================================================================

11] So after loading vmlinuz-2.4.20.8 gets uncompresed & unarchinved by LILO.

12] LILO then executes the init binary & transfers control to the init system
daemon & init starts as a result of which LILO gets out of the RAM.

13] /sbin/init binary now checks it's conf. file calles /etc/inittab & starts
inittab in a subshell calles inittab.

14] In inittab shell init binary reads the configured runlevel.

15] Now inittab executes /etc/rc.d/rc.sysinit in a subshell called rc.sysinit.

16] In rc.sysinit NW card checking is done,if NW card is present then anaconda
creates file called /etc/sysconfig/Network & hostname command is run
crerating hostname & giving Networking value yes.

17] If NW card is not their then rc.sysinit script creates the file called
/etc/sysconfig/Network hostname gets configured to localhost & for
Networking value is set as no.

18] After this rc.sysinit calls another script called /etc/init.d/functions in
the same shell.

19] In the Functions script global UMASK & global PATH get set.

20] It will then ask for interactive startup.

21] Functions script contains 17 shell functions as given below.
/etc/init.d/functions
-----------------------
1. Success
2. Passed
3. Failure
4. Warning
5. echo_success
6. echo_Passed
7. echo_Failure
8. echo_Warning
9. Action
10. Checkpid
11. Confirm
12. Daemon
13. Pidofproc
14. Pidfileofproc
15. Killproc
16. Status
17. Strstr

22] After this "Welcome to Red-hat release script is run" from /etc/
redhat-releas file.

23] Thereafter /var/log/dmesg file gets run & all filesystems will get mounted
in fstab & mtab gets updated.

24] After this rc.sysinit gets ended & from inittab rc script gets started in
a subshell called rcshell.

25] In rc shell previous & current runlevels get set & it will check
rc$runlevel.d in /etc directory exist or not.

26] Then it will run the rc$runlevel script in a subshell.Here all networking
application daemons starts & stops.
5 functions in the sript are
============================
1. Start
2. Stop
3. Restart
4. Condrestart
5. StatusBootProcess

27] At last /etc/rc.d/rc.local script gets executed which starts optional
scripts.

28] Now update command is run which starts the bdflush which synchronises swap
& disk operations.Nowadays this command is part of /sbin/init daemon.

29] Now Shutdown CAD(Ctrl+Alt+Del) magic keys are set.

30] Then Poweroff & Poweron Connections are Considered.

31] Now 6 mingettys are spawned with device drivers of terminals.In these 5
mingettys use to be sleeping state & one in awaken state.

32] Script prefdm is run if runlevel is configured 5.This examines script /etc/
sysconfi/desktop for dispmgr.With this inittab gets over.

================================================================================
PART - 3
================================================================================

33] The one awaken mingetty loads the driver for /dev/tty1.

34] Here /etc/issue script gets executed & magic cookies get allowed.

35] After this process /bin/login get executed & first mingetty goes to sleep.

36] After giving username /bin/login executes /usr/bin/passwd which ask passwd
& does authentication & authorization.

37] The mingetty then puts login in sleep & checks for .hushlogin in $HOME/$USER

38] If >hushlogin exists then it will login quietly witout displaying any
message.

39] If .hushlogin does not exist then mingetty will run following 3 files.
(1) lastlog* -u $USER /VAR/LOG/LASTLOG.
(2) /etc/motd displays message of the day.
(4) /var/spool/mail displays the mail if any this setting is done in
/etc/log.defs.

40] Then it starts /bin/logiv which takes over as independant daemon & mingetty goes into zombie state,later it is killed by init.

41] From here /bin/bash takes over & puts login again goes into sleep state.

42] Then bash executes /etc/profile sets ulimit such as HISSIZE,PATH etc.

43] Now profile executes 3 scripts.
(1) /etc/inputrc Sets Keyboard mappings.
(2) /etc/termcap Sets terminal capabilities.
(3) /etc/profile.d/*.sh Which contain 13 scripts as given below.

13 scripts of /etc/profile.d
=============================
1. colorsls.sh
2. vim.sh
3. glib2.sh
4. gnome-ssh-askpass.sh
5. krb5.sh
6. lam.sh
7. lang.sh
8. less.sh
9. mc.sh
10. pvm.sh
11. qt.sh
12. which-2.sh
13. xpvm.sh

44] Another file bash executes after login is /etc/bashrc which sets global
aliases & shell functions.Sets user's & root's final global umask.

45] Now bashrc executes another script called .bash_profile which is user's
personal profile & .bash_history,.bash_logout.After this we get the prompt
to to type various commands.


2 comments:

Anonymous said...

http://teknoteknik.wordpress.com/2010/10/19/step-by-step-explanation-of-linux-boot-sequence/

Anonymous said...

http://www.thegeekstuff.com/2011/02/linux-boot-process/

Other Articles

Enter your email address: