Top Banner
7/23/2019 Boot Process of Linux http://slidepdf.com/reader/full/boot-process-of-linux 1/25 Welcome  Boot Process in LINUX
25

Boot Process of Linux

Feb 18, 2018

Download

Documents

dinesh kumar
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 1/25

Welcome

 Boot Process inLINUX

Page 2: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 2/25

System Boot-up

• USER

PressesSwitch

Switch SMPS

Power Passesto

SMPS( Switch MoePower Supply! is a "in

o# RE$UL%&'R &hrou)h SMPS* Power

is Re)ulate to MainBoar an 'ther %reas

Mothe

rBoar

  'ther%reas

  P  o  w  e  r

   P  a  s  s

  e  s 

  t  o

P  o w  e r   P  a s s e s  

t  o 

+ ,PU %N. /%R0 0IS1 2 ,0 R'M

Page 3: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 3/25

 IN M'&/ER B'%R0 (%1% M%IN B'%R0!

BI'

S

BI'S(Basic Input3OutputSystem! is 4uilt usin) %ssem4ly

Lan)ua)e Its main #unction is toLoa 1ernel into Memory BI'S isa Pro)ram * locate at a R'M,hip in Mother4oar It is also"nown as R'M Pro)ram It1eeps the in#ormation o# all the/arware an is responsi4le #orma5or tas"s in Boot ProcessBI'S $ets Loae in MEM'R6 (Boot Strappin)!

 R%M(MEM'R6! + BI'S

.,M'S

P'S&

P'S&(power-on sel# test ! is a Pro)ram thatpro7ies Status o# all the peripherals connecte tothe System an chec"s i# e7ery e7ice is#unctionin) properly or

 &he BI'S per#orms the power-on sel# test (P'S&! I# there are any #atal errors* the 4oot processstopsP'S& 4eep coes can 4e #oun in this area o# the &rou4leshootin) E8pert

 

,M'

S

$et s 

Loae

,M'S is a Pro)ram * itchec"s the 4oot e7icespriority an also ienti9es

the +st sector (: ,yliner * : &rac"s! o# /30 *;+. 4ytes in

$   e  t   s   L  o  

a     

e      t   h  r   u   

B   I   '   S   

,M'S

B%&&ER6

,mos(ComplementaryMetal-O8ie Semiconuctor!4attery )i7es power to

,mos pro)ram * so thatit retains all its,ontains (settin)s!

,PUPIN RESE&S

P r  o 7 o " e s 

 ,PU-E8ecute a =ump at :8: ( +st instruction a#ter

power on ! >5ump> instruction tellin) the processor where to)o to 9n the real BI'S startup pro)ram

Page 4: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 4/25

At the First Sector of HD (0 Cylinder = 0

Tracks = st Sector!

MBR

  HA"DDIS# 

  st 

Sector

 R%M(MEM'R6!

+BI'S.,M'S2MBR

 $e t s 

 Loae ( t h r u 

 B I ' S !Sta)e + 4oot loaer

 &he primary 4oot loaer that resies in the MBR is a ;+.-4yte ima)e containin) 4oth pro)ram coe an a smallpartition ta4le (see i)ure .! &he 9rst ??@ 4ytes are theprimary 4oot loaer* which contains 4oth e8ecuta4lecoe an error messa)e te8t &he ne8t si8ty-#our 4ytesare the partition ta4le* which contains a recor #or eacho# #our partitions (si8teen 4ytes each! &he MBR enswith two 4ytes that are e9ne as the ma)ic num4er(:8%%;;! &he ma)ic num4er ser7es as a 7aliationchec" o# the MBR

 &he 5o4 o# the primary 4oot loaer is to 9n an loa the

seconary 4oot loaer (sta)e .! It oes this 4y loo"in)throu)h the partition ta4le #or an acti7e partition When it9ns an acti7e partition* it scans the remainin) partitionsin the ta4le to ensure that theyAre all inacti7e When this is7eri9e* the acti7e partitionAs 4oot recor is rea #rom thee7ice into R%M an e8ecuteSta)e . 4oot loaer

 &he seconary* or secon-sta)e* 4oot loaer coul 4emore aptly calle the "ernel loaer &he tas" at this sta)eis to loa the Linu8 "ernel an optional initial R%M is"

Page 5: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 5/25

Let us Unerstan MBR in0etail

Master Boot Recor (MBR! is a ,ommon Pro)ram in 'S * whene7er you4oot your System with the Boota4le ,0 * &he Installer (%nacona inLinu8! writes the MBR at the irst Sector o# your /30 %s shown in a4o7eia)ram* MBR is i7ie into 2 main parts

$ Boot Sector (%%& Bytes! ' Boot Sector is a %rea in MBR * whichcontains the in#ormation o# Boot LoaerC li"e LIL' D $RUB (o#

Linu8 (PO)"F*+!! an N&L0R (o# Winows (+ess Po,erf-lthan +I+O . /"*B!!

  Boot Loaer will 4e responsi4le #or Loain) the 1ernelC (mlinu<in our case! * a#ter BI'S assi)ns it the &%S1 to o so

$ Partition Ta1le (&% Bytes! ' Partition &a4le is a)ain a su4-i7iepart o# MBR It

  has ? pro)rams o# +@ Bytes Each (? X +@ 4 F @? Bytes! EachPro)ram is Responsi4le #or each Partition in /30 /ence you cannotcreate more than ? partitions in a /30 'ut o# this ? partition * youcan create one partition as E8teneC an create Su4 partitions orLo)ical Partitions in it2$ Ma3ic 4-51er ( Bytes! ' Ma)ic Num4er 4asically shows thestatus o# other two

  i7isons o# MBR I# Boot Sector an Partition &a4le are writtenSucess#ully * Ma)ic Num4er will 4e 6esC * 'therwise it will 4e NoC

Page 6: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 6/25

 

BI'S

irst

,/E,1S

Ma)icNum4er

I#6esC

I#

NoC

ReportsError

 

Partition &a4le

,hec"s #or %cti7e Partition inP&

  Boot Sector

ins the Boot Loaerin BS

BI'S now Loas the BootLoaer (LIL' or $RUB in our,ase! in Memory * a"a(irst sta)e o# LIL'! an

/ans o7er the 1ernelLoain C tas" to it

 R%M(MEM'R6!

+BI'S

.,M'S2MBR?LIL' G$RUB

L o  a     e     

LIL' G$RUB

Page 7: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 7/25

  +I+O  I4FO

34oot34oot4 is a4inary 9le

,/S Num4ers is

,onsiere to 4e theM'&/ER &'N$UE o#BI'S   ( Int +2 n

H!

(Int +2 n .!

  ( Int +2 n

.!

 

BIOS

 

unctions to ,%LL BI'S+ Int +2 #n H -- >$et ri7eparameters>. Int +2 #n . -- >Rea sectors#rom ri7e>

34oot34oot4

6 61oot6Ma7 6

&o

loa

 &o

   ,   /   S

    N   '

 (

    ,    /    S

     N    '

 (

,/S N'

 

BIOS

  (Int +2 n .!

 

BIOS

,    /    S     N    '   ( 

+I+O /"*B

+I+O has no interacti8eco55and interface

$RUB has interacti7e commaninter#ace

+I+O does not s-77ort

1ootin3 fro5 a net,ork 

$RUB oes support 4ootin) #rom a

networ"If yo- chan3e yo-r +I+O

con:3 :le; yo- ha8e to

re,rite the +I+O sta3e

one 1oot loader to the

MB"

$RUB automatically etects any

chan)e in con9) 9le an auto

loas the 'S

+I+O s-77orts only lin-<

o7eratin3 syste5

$RUB supports lar)e num4er o#

'S

Below are )i7en some #ew important iKerences a4outLIL' an $RUB

Page 8: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 8/25

Installer (%nacona!* pro7ies the ,ylinrical /ea Sector (,/S! num4er o#34oot34oot4 * 34oot3Messa)e D 34oot3Map 9le to LIL' LIL' can Loa allthese 9le with the help o# ,/S Num4er * howe7er it oesnCt unerstan,/S num4er * So it ,alls BI'S to help it Loa all these 9les LIL' uses a#unction (Int +2 n H! #or 34oot34oot4 D #unction (Int +2 n .! #or other9les * to ,all BI'S

%#ter unction (Int +2 n H! is e8ecute *BI'S Loas 4oot4 9le intoMemory * it is "nown as Secon sta)e o# LIL' %n When unction (Int +2

n .! is e8ecute one 4y one *BI'S Loas 4oth Messa)e an Map 9le intoMemory R%M(MEM'R6!

+ BI'S. ,M'S2 MBR? LIL' GG $RUB

; Boot4@ Messa)e Map

Important 9les in 34ootirectory

+ Boot4. Messa)e2 Map

? mlinu<; Initrim)

Page 9: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 9/25

 $ 6Messa3e has CHS 4-51er of S7lash Screen (also kno,n as#ernel +istin3s!> and it calls BIOS to +oad this ; for the sa5ereason ;as it doesn>t -nderstand CHS 4-51er$

$ 6Ma7 has CHS 4-51er of 85lin-9> and it calls BIOS to +oad this ;as it doesn>t -nderstand CHS 4-51er$6Messa3e

6Ma7

  ( Int +2 n.!

BIOS 

( Int +2 n

.!

BIOS 

/ope this is Sel#E8planatory

mlinu<

(1ernel!

,/SNo

,/SNo+ BI'S

. ,M'S

2 MBR? LIL' GG $RUB; Boot4@ Messa)e MapH mlinu<

 R%M(MEM'R6!

  Splash

Screen

Page 10: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 10/25

 &he "ernel is the central part o# an o7eratin3 syste5* that irectlycontrols the co57-ter hard,are Usually* the "ernel is the 9rst o# theuser-installe soft,are on a computer* 4ootin) irectly a#ter the BIOS1ernel is in 4<ip #ormat1ernel has a ,/S Num4er o# initrim) (INI&I%L R%M 0IS1! * it ,alls BI'S 4y

(Int +2 #n .! #unction an it loas initrim) into Memory Initrim) islocate at 34oot an is in )<ip #ormat Initrim) has ? main 9les

  + nash - Nash is a Minimal shell * it ta"es low memory It is useto run linu8rc script  . e8t2 : - "ernel nees a ri7er 9le calle e8t2 :C #or 9lesystems

without which * youyou cannot mount any partition

  2 =B0 : O ItCs a /30 is" ri7er 9le  ? Linu8rc O ItCs a Script 9le * ha7in) #unctions o# e8t 2 : an =B0 :an also #unction to

mount 3C (slash! partition

 

Initrim) is e8tracte 3 ecompresse an its ,ontents (a4o7e ? 9les! areLoae into R%M 0IS1C

W/%& IS R%M 0IS1

% R%M is" is a portion o# R%M which is 4ein) use as i# it were a is" ri7eR%M is"s ha7e 98e si<es an act li"e re ular is" artitions %ccess time

Page 11: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 11/25

  (int +2 #n.!

  BIOS

  initrim)

 $ e  t s 

  E  8  t r a

 c  t e    i n  t

 o   R  0 

 a n  

 $ e  t s 

  L o a 

 e    i n  t o  m

 e m o r  y

 R%M(MEM'R6!

+ BI'S

. ,M'S2 MBR? LIL'; Boot4@ Messa)e Map

H imlinu<Q e8t2:+:54:

  R%M

0IS1 

+ Nash. E8t2 :2 =B0 :? Linu8rc

%t R%M 0IS1 * 9rst NashC will 4eacti7ate to run the script 9le *linu8rc 

 &his Script 9le will now run #unctions o#e8t2 : * =B0 : an mountin) #unction o#

3C (slash! * this mountin) is also calleSysrootC

In linu8rc script Mountin) o# 3C(slash! *loo"s somethin) li"e thismount 3e73root 3 ro  ------ (rea

only!

, / S  N o (

XXXXXXXXXXXXXX XX EN0 ' 1ERNEL L%N0

61oot68i5lin-9

Page 12: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 12/25

  N%S/ ItCs a minimal shell Uses 7ery lowmemory Nash will 4e acti7ate9rst

  LINUXR,

RUNS

ItCs a Script 9le * ha7in)

instructions to loa e8t2: an 54: an also #unction tomount 3C (slash! partition inro (rea only !

Mounts3C

partition

XXXXXXXXXXXXXX XX EN0 ' 1ERNEL L%N0

mount3e73root 3 ro

Page 13: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 13/25

S&%R& ' USERL%N0

%s the 3C (slash! Partition is now mounte * 1ernel now opens the irst 9lewith the Inoe Num4erC &he ile it opens is locate at 3s4in3initC Init is the

7ery 9rst process to start an hence it has the pi (process I! Num4er as +Init 9le is a Binary 9le (e8ecuta4le! an it has 4een )i7en an Instructions toLoa a 9le calle3etc3initta41ernel

3s4in3init

I n o  e  n u m 4 e r 

3etc3initta4

I  n  s  t  r  u  

c  t  i  o n  s   t  o  L o a   

Page 14: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 14/25

3s4in3init 3etc3initta4

  /IER%R,/6

,hec"s 0e#ault RUNLEELS

System Initialisation (System !( 3etc3rc3rcSysinit!

  'pens a Su4-Shell 

$ 6etc6syscon:364et,ork'   &his 9le is relate to Networ"

6ou can Ena4le or 0isa4leNetwor" #rom this 9le

$ Hostna5e'

  6ou can also set /'S&N%ME inthis 9le e)Ser7erE8amplecom &he0e#ault /ostname islocalhostC

2$ Mo-nt ?n ?t 7roc 6 7roc

Page 15: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 15/25

%$ 6etc6init$d6f-nctions'@3lo1al

-5ask  3lo1al PATH; de:nes shell f-nctions @ s-ccess;fail-re;7assed;,arnin3echos-ccess echofail-re  echo7assed; echo,arnin3 ;kill7roc;7idof7roc;7id:leof7roc  action;check7id;con:r5;stat-s;strstr;dae5on

$ 6etc6redhatErelease'  6ou can chan)e the Release

name withthis 9le

&$ Press i> to enter interacti8eset-7'

  6ou can enter intoInteracti7eC moe tocustomise your 4ootin)

$ 6etc6syscon:36clock'   &his 9le contains U&, &ime

Tone&his9le upates the 9le at

Page 16: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 16/25

G$ 6etc6syscon:36init '  6ou can the set this 9leCs

$raphicalC

  7aria4le to 6esC or NoC &his4asically

)i7es 4ootin) in#ormation in$raphics or console

0$ 6etc6sysctl$conf'

   &his 9le is #or 1ERNEL tunin)

$ 6etc6syscon:36key1oard'  6ou can Unerstan ,ontrol

"eysC with this 9le

$6fast1oot' &his 9le * i# create in 3C

(slash! partition * ensures thatthe #sc"C (ile system chec"!operation is s"ippe &his 9lewill e7en s"ip the #sc"C

operation e7en i# its mentione C

Page 17: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 17/25

2$ 6forcefsck '  &his 9le will ma"e sure * i#

create at 3C Slash Partition*

the #sc"C operation isper#orme E7en i# its notmentione in 3etc3#sta4C 9le

%$ 6etc6syscon:36readonlyEroot'

   6ou can set the Entireilesystems to Reaonly F 6esCor NoC

$ 6etc6r,ta1'  &his can 4e consiere as an

e8ception to3etc3syscon9)3reaonly-rootCwhich means i# you ma"e theentire 9lesystem to rea onlyan wante to )i7e e8ceptionsto certain 9les3ir then you can

ma"e use o# this 9le to )i7e - C

Page 18: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 18/25

$ 6etc65ta1'  mta4 stans #or Mount &a4C

When you run mountC

comman * it re#ers to this 9leIt "eeps the in#ormation o# allmounte partition only

$ 6s1in6-otaon'

G$)na1lin3 6etc6fsta1 s,a7s'

0$ 68ar6lo36d5es3'

 

3etc3rc3rc  &his 9le is responsi4le #orstartin) 3 stoppin)ser7ices when runle7elchan)es

(R, F RUNLEEL,/%N$E!

Page 19: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 19/25

3etc3rc3rc

+ ,hec"s RUNLEEL . ,hec"s RUNLEEL ,'MM%N0

#rom3etc3initta4 9le

 2 3etc3rc31

  3etc3rc3S

 inicates RUNLEEL Num4erwhereas 1C shows that ser7ice

name with 9rst letter 1C will 4e1ILLE0 an ser7ice namestartin) with SC will 4eS&%R&E0C %ll 9les at thislocation are sym4olic lin" o# itsparent 9le at

3etc3init3ser7icename

Page 20: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 20/25

.:

Runle7els

• % runle7el is a so#tware con9)urationo# the system which allows only aselecte )roup o# processes to e8ist

•  &he processes spawne 4y init #oreach o# these runle7els are e9ne inthe 3etc3initta4 9le

Init can 4e in one o# se7en runle7els:-@

Page 21: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 21/25

 6s1in65in3etty ( "-nle8elE;;2! tty+ *tty.*tty2*tty?*tty;*tty@(,an 4e increase upto tty+.!

  'R

 6etc6J67refd5 ("-nle8el E! 

0epensUpon theRunle7elset in3etc3initta

4

6etc6iss-e

 &he 9le 6etc6iss-e is a te8t 9lewhich contains a messa)e orsystem ienti9cation to 4e printe4e#ore the lo)in prompt It maycontain7arious Kchar  an Lchar  seuenc

es

Page 22: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 22/25

61in6lo3in+o3in co55and is use when si)nin) onto asystem It can also 4e use to switch #rom oneuser to another at any time (most moern shells

ha7e support #or this #eature 4uilt into them*howe7er!

61in67ass,d ' Will Prompt you #orPasswor 

PAM

6etc67ass,d

6etc6shado,

6etc63ro-7

6etc63shado,

6$h-shlo3in

lastlo3

Page 23: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 23/25

6etc65otd NMessa3e of theday

68ar6s7ool65ail

61in61ash

6etc67ro:le

De:nition of PATH>

Hostna5e aria1le

HISTSIQ) (C5d historyli5it!

6etc6in7-trc

6etc67ro:le$d6R$shAfter +o3in ; yo- canr-n any scri7ts fro5this locationa-to5atically$

Page 24: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 24/25

6etc61ashrc

-5ask

PS  aria4le #orPrompt

$lo4al User settin)s can 4e one at3etc3pro9le an 3etc34ashrc

3root3$ 1ashrc

3root3 1ashrc7ro:le

3root3 1ashlo3o-t

 &his 9le is #orrespecti7euser 6ou canset umas" atini7iual

le7el

In this caserootC isconsiere to4e the user

Page 25: Boot Process of Linux

7/23/2019 Boot Process of Linux

http://slidepdf.com/reader/full/boot-process-of-linux 25/25

EN0 ' B''& PR',ESS

  &/%N1 6'U