Linux Boot Process PDF
Linux Boot Process PDF
6StagesofLinuxBootProcess(Startup Sequence)
byRameshNatarajanonFebruary7,2011
138 Like 187 Tweet 84
www.thegeekstuff.com/2011/02/linux-boot-process/
1/17
8/25/13
1.BIOS
BIOSstandsforBasicInput/OutputSystem Performssomesystemintegritychecks Searches,loads,andexecutesthebootloaderprogram. Itlooksforbootloaderinfloppy,cdrom,orharddrive.Youcanpressakey(typicallyF12ofF2, butitdependsonyoursystem)duringtheBIOSstartuptochangethebootsequence. Oncethebootloaderprogramisdetectedandloadedintothememory,BIOSgivesthecontrolto it. So,insimpletermsBIOSloadsandexecutestheMBRbootloader.
2.MBR
MBRstandsforMasterBootRecord. Itislocatedinthe1stsectorofthebootabledisk.Typically/dev/hda,or/dev/sda MBRislessthan512bytesinsize.Thishasthreecomponents1)primarybootloaderinfoin1st 446bytes2)partitiontableinfoinnext64bytes3)mbrvalidationcheckinlast2bytes. ItcontainsinformationaboutGRUB(orLILOinoldsystems). So,insimpletermsMBRloadsandexecutestheGRUBbootloader.
3.GRUB
GRUBstandsforGrandUnifiedBootloader. Ifyouhavemultiplekernelimagesinstalledonyoursystem,youcanchoosewhichonetobe executed. GRUBdisplaysasplashscreen,waitsforfewseconds,ifyoudontenteranything,itloadsthe defaultkernelimageasspecifiedinthegrubconfigurationfile. GRUBhastheknowledgeofthefilesystem(theolderLinuxloaderLILOdidntunderstand filesystem). Grubconfigurationfileis/boot/grub/grub.conf(/etc/grub.confisalinktothis).Thefollowingis samplegrub.confofCentOS.
# b o o t = / d e v / s d a d e f a u l t = 0 t i m e o u t = 5 s p l a s h i m a g e = ( h d 0 , 0 ) / b o o t / g r u b / s p l a s h . x p m . g z h i d d e n m e n u t i t l eC e n t O S( 2 . 6 . 1 8 1 9 4 . e l 5 P A E ) r o o t( h d 0 , 0 ) k e r n e l/ b o o t / v m l i n u z 2 . 6 . 1 8 1 9 4 . e l 5 P A Er or o o t = L A B E L = / i n i t r d/ b o o t / i n i t r d 2 . 6 . 1 8 1 9 4 . e l 5 P A E . i m g
Asyounoticefromtheaboveinfo,itcontainskernelandinitrdimage. So,insimpletermsGRUBjustloadsandexecutesKernelandinitrdimages.
4.Kernel
Mountstherootfilesystemasspecifiedintheroot=ingrub.conf Kernelexecutesthe/sbin/initprogram Sinceinitwasthe1stprogramtobeexecutedbyLinuxKernel,ithastheprocessid(PID)of1. Doapsef|grepinitandcheckthepid.
www.thegeekstuff.com/2011/02/linux-boot-process/
2/17
8/25/13
5.Init
Looksatthe/etc/inittabfiletodecidetheLinuxrunlevel. Followingaretheavailablerunlevels 0halt 1Singleusermode 2Multiuser,withoutNFS 3Fullmultiusermode 4unused 5X11 6reboot Initidentifiesthedefaultinitlevelfrom/etc/inittabandusesthattoloadallappropriateprogram. Executegrepinitdefault/etc/inittabonyoursystemtoidentifythedefaultrunlevel Ifyouwanttogetintotrouble,youcansetthedefaultrunlevelto0or6.Sinceyouknowwhat0 and6means,probablyyoumightnotdothat. Typicallyyouwouldsetthedefaultrunleveltoeither3or5.
6.Runlevelprograms
WhentheLinuxsystemisbootingup,youmightseevariousservicesgettingstarted.For example,itmightsaystartingsendmail.OK.Thosearetherunlevelprograms,executed fromtherunleveldirectoryasdefinedbyyourrunlevel. Dependingonyourdefaultinitlevelsetting,thesystemwillexecutetheprogramsfromoneofthe followingdirectories. Runlevel0/etc/rc.d/rc0.d/ Runlevel1/etc/rc.d/rc1.d/ Runlevel2/etc/rc.d/rc2.d/ Runlevel3/etc/rc.d/rc3.d/ Runlevel4/etc/rc.d/rc4.d/ Runlevel5/etc/rc.d/rc5.d/ Runlevel6/etc/rc.d/rc6.d/ Pleasenotethattherearealsosymboliclinksavailableforthesedirectoryunder/etcdirectly.So, /etc/rc0.dislinkedto/etc/rc.d/rc0.d. Underthe/etc/rc.d/rc*.d/directories,youwouldseeprogramsthatstartwithSandK. ProgramsstartswithSareusedduringstartup.Sforstartup. ProgramsstartswithKareusedduringshutdown.Kforkill. TherearenumbersrightnexttoSandKintheprogramnames.Thosearethesequencenumberin whichtheprogramsshouldbestartedorkilled. Forexample,S12syslogistostartthesyslogdeamon,whichhasthesequencenumberof12. S80sendmailistostartthesendmaildaemon,whichhasthesequencenumberof80.So,syslog programwillbestartedbeforesendmail. Thereyouhaveit.ThatiswhathappensduringtheLinuxbootprocess.
www.thegeekstuff.com/2011/02/linux-boot-process/
3/17
8/25/13
138
Tweet
84
Like
187
>Addyourcomment
Ifyouenjoyedthisarticle,youmightalsolike..
1. 50LinuxSysadminTutorials 2. 50MostFrequentlyUsedLinuxCommands (WithExamples) 3. Top25BestLinuxPerformanceMonitoringand DebuggingTools 4. Mommy,Ifoundit!15PracticalLinuxFind CommandExamples 5. Linux101Hacks2ndEditioneBook AwkIntroduction7AwkPrint Examples AdvancedSedSubstitutionExamples 8EssentialVimEditorNavigation Fundamentals 25MostFrequentlyUsedLinux IPTablesRulesExamples TurbochargePuTTYwith12Powerful AddOns
www.thegeekstuff.com/2011/02/linux-boot-process/
4/17
8/25/13
1PushprajFebruary7,2011at1:11am Excellent!!!2011seemstoberockingforTGSviewers. 2BalaCFebruary7,2011at2:53am @Ramesh:Thisisofftopicdiscussion.Couldyouwriteaarticleonack.Thanks 3shezarsFebruary7,2011at4:02am youarerock,,,lol nice, 4AdamFebruary7,2011at4:20am Greatarticle Youcouldalsowritefewwordsaboutgrub2configurationfilesforgrubdoesntworkingrub2. (Testedinubuntu) 5EdwardFebruary7,2011at4:30am veryverynice, tanx 6AjeyaFebruary7,2011at4:58am HelloRamesh, Itwouldhavebeenbetterififyoucouldhaveexplainedmoreoneachtopic.Probablyeachhigh levelbootprocesswouldneedaseparatepage. Thisdocisgoodforbegineers. Thanks, AjeyaKrishnaKR 7AbhijeetFebruary7,2011at5:02am GoodGraphics GreatTutorial Keepitup 8sagarFebruary7,2011at5:36am nicepieceofinformation thankslot 9sandeepFebruary7,2011at6:38am AmazingggggggggoodjobGuyscarryon
www.thegeekstuff.com/2011/02/linux-boot-process/
5/17
8/25/13
10jamesleeFebruary7,2011at6:56am Thanku 11KuldeepFebruary7,2011at8:09am verywellexplained!!!!!!!! Thanxalot.. plzexplainGRUBindetail.HowtouseGRUBcommandpromptatsystemstartup?? 12KyleFebruary7,2011at11:02am Theseareveryhelpful.Keepemcomingplease! 13YogeshUpadhyayFebruary7,2011at1:22pm Excellent!!!TGSRocks 14shanilFebruary7,2011at2:08pm thanksalot,justintimetofutherclarifythingslol..Asalways,TGSrocks!!! 15JlioHoffimannMendesFebruary7,2011at8:15pm Ilearntomuchwithyourblog.Thankyou. Regards, Jlio. 16SteevenPaulYFebruary7,2011at10:04pm IknowthetermsGRUB,KERNEL,INIT,MBR.Butidonotknowhowtheyworktogether. ThankstoRameshNatarajan,forhisblogandusefulposts. 17LordFebruary8,2011at12:42am ThankyouRAMESH.thiswassogood 18analogtekFebruary8,2011at1:01am Thefilethatmostwouldwantis.Themenu.listthatisinthe/boot/grub/directoryonmydebian system.Iofteneditthisfileforamanualkernelupdate,timeout,bootimagechange. 19Suresh.GFebruary8,2011at2:33am ShortandSweet 20SameerAmbekarFebruary8,2011at8:03am ReallynicedocumentforquickreferencetoLinuxbootprocess!!! 21afujitaFebruary8,2011at8:09pm
www.thegeekstuff.com/2011/02/linux-boot-process/
6/17
8/25/13
Greatarticle,thankyou 22RenjithGFebruary10,2011at1:45am Goodone.Thanks. 23MohanFebruary11,2011at10:25am plzexplainabouthowtoconfigurezimbramailserverandhowtomigratesendmailtozimbra 24RobertoFebruary11,2011at6:17pm Anexcelentarticle,Iseeanothergreatarticlehere. 25HemChanderMarch1,2011at2:57pm ThisisveryhelpfulIwaslookingforsimilarone..thanks 26PabloMarch7,2011at10:16am GreatarticleRamesh!ButisnotcompletelyvalidforUbuntu,whichuseupstart.Nothingon /etc/inittab,foreg. 27SameerJune7,2011at7:07am Gooddoc. Thanks 28VerbilaJune21,2011at5:44pm Lovethissite,yourexplanationsareexcellent,andIlikehowyoudefinetermsandacronyms. Sometimesamanpagecanmakemyheadspinyoursiteistheantidotetothatthanks!! 29ethaqerJuly4,2011at8:50pm thebestexplanationever thanksTGS 30robinJuly7,2011at1:30am Howmanytimesdidiaskmyselfhowtofindoutorderoflinuxsstart? whenthistimeisawyourblogviaTSG,iseethoroughly. thanksamillion BestRegards RobinGuo 31SenthilkumarJuly29,2011at12:38am Awesome!!Forbeginnershelpedalot..
www.thegeekstuff.com/2011/02/linux-boot-process/
7/17
8/25/13
32DVIjayAugust11,2011at5:48am Excellent,indetailandsimple.Thanksverymuch 33karthickSeptember4,2011at2:14am Actaullyihavefailedinmyfirstinterviewfornotansweringtheabovequestion,butafterreading theaboveanswer.iensureiwillgetsuccess.itsreallygudexplanation,especiallybeginnerslyk me.Thanksalot 34dulanjaSeptember19,2011at1:11am greatarticle!veryuseful!thanksalot. 35R.YADAVSeptember30,2011at2:52am really.mytotalconfuseremoveafterreadthisarticle.Thankyou. 36GregoryOctober7,2011at2:35am AreyousurethatDependingonyourdefaultinitlevelsetting,thesystemwillexecutethe programsfromoneofthefollowingdirectories.? Forexamplemysystemisrunningonlevel3butexecutesVERITASinitscriptsfromrc2.d duringthebootaswell. 37ArunOctober15,2011at8:13am VeryNice. 38rajeshOctober20,2011at10:02pm Excellent!!!!!!!!!!!!!!!!!!!!! Enoughdetailandsimple. Thanksverymuch Bestregard, rajesh 39enderOctober21,2011at1:20am goodworkfinetoknowhowlinuxbootandthebasicsoftheinitrunlevelsonlybyubuntuyou haveinits(singleuser)andinitu(reruninit)asextra 40evaaNovember12,2011at9:12pm wow,yourexplainationissimpleyetfullwithinformation veryhelpful!<3 41brijeshNovember19,2011at2:49pm greateusefull
www.thegeekstuff.com/2011/02/linux-boot-process/
8/17
8/25/13
42KetanNovember30,2011at1:34pm Iamflabbergasted..IhavemadeautomationonthesepartsonSandK.,..ItwastooEasyto understandthis..Thepersonwhopostthis..isreallyacooltechie..Urockman.. 43hosseinJanuary2,2012at12:06am Thatwasveryusefulinformation. Thanks. 44NARESHJanuary17,2012at9:45pm Excellent.keepitup.. 45ArunJanuary24,2012at9:52pm Nice.Veryuseful 46OmkarJanuary27,2012at9:32am shortandsweetandpreciseexplanation 47AnonymousFebruary3,2012at3:53am verygoodmaterialandeasytounderstandgreatwork 4854nju1February19,2012at1:59pm Thanksdude,thatwassohelpful.. 49subhashMarch13,2012at8:27am itsverynicematerial..ilikeit..superb 50sandeepsamaleMarch21,2012at9:37pm HIthisisveryveryusefulinformationasinterviewpointofviewaswellasforstudyhowLinux boots.GreatinfoThankyouverymuchRamesh 51AnujApril12,2012at9:28am GreatandbriefdocforLinuxbootprocess.Itrulylikedit!!! 52RaviMay4,2012at11:05pm Thanx 53DeepikaMay9,2012at11:03pm Superbarticlewithdetailedinformation. 54DeepakMay14,2012at11:11am
www.thegeekstuff.com/2011/02/linux-boot-process/
9/17
8/25/13
Itisverynicearticle 55divyaMay21,2012at5:19am howtocreatekickstartserverinrhel6.0 56sasidharanMay25,2012at4:54am ExcellentstufffromTGS!!! 57AnandJune3,2012at1:41pm gr8article,gotalotofotherinfowhilereadingthisawesomestuff,thxalot 58SumenJune22,2012at5:09am Greatverywellexplained 59VIKASJune26,2012at5:15am Verynice,veryneatlyexplained. 60SaravanaKumarJuly12,2012at2:18am Keepontheworkgoing 61KuldeepKulkarniJuly14,2012at1:58pm NiceStuff!! Thanksalot!! 62RakeshyadavjaipurJuly19,2012at10:20pm really.mytotalconfuseremoveafterreadthisarticle.Thankyou. 63SudhakarJuly26,2012at1:14am GoodOne,willbehelpfullfornewleaners!!! 64rajendraJuly31,2012at8:22am excellent 65NaveenAugust8,2012at12:17am ItsveryGoodarticleandhelpfulforlinuxbeginers 66RanjitRajputSeptember10,2012at12:57am Excellent 67HugheSeptember10,2012at5:21am
www.thegeekstuff.com/2011/02/linux-boot-process/
10/17
8/25/13
Youcanbypassthefirstthreestageusingkexecprogramforfastboot.Thissavestimewhenyou havetorebootalotfortuningsystemorhandlinginitscript. Debianprovidesitaskexectoolspackage. Findthekerneloptions: $cat/proc/cmdline BOOT_IMAGE=/vmlinuz3.4.010.dmz.1liquorixamd64root=UUID=07cf8c3ad5a54b41 833f16a9afebf70croquiet Addakernelimage: vmlinuzisthekernelimagefileIuses.Ifthekernelimageusesinitrdfile,addinitrdoption. Withoutitkernelwillpanicnextboot. $sudokexecl/vmlinuzappend=root=UUID=07cf8c3ad5a54b41833f16a9afebf70c roquietinitrd=/initrd.img Or InmyLinuxbox,bootpartitionis/dev/sda1 $sudokexecl/vmlinuxappend=root=/dev/sda1roquietinitrd=/initrd.img Startwarmboot: $sudokexece LinuxwillbootupwithoutgoingthroughBIOS,MBR,andGrub. 68manojsharmaSeptember18,2012at9:14am thanks 69GuruReddySeptember24,2012at8:04am Excellent..,andthankyoualot.., 70karunakarSeptember27,2012at2:22pm Excellentandsimpleexplanationandagreatdealforbeginners!!Thankyou. 71RajeevSeptember28,2012at3:23am verynice 72MithunShrivastavOctober11,2012at3:01am Hiitsexcellent.Thanks. 73AmareshSamalNovember13,2012at12:34pm thanksfriend. 74krishNovember14,2012at2:11pm
www.thegeekstuff.com/2011/02/linux-boot-process/
11/17
8/25/13
whatis1ststagebootloaderandwhatis2ndstagebootloader?kindlyclearthispointalso. 75RajgopalH.G.November19,2012at12:58am IamworkingonLinuxsincedecade.SometimesIamunableexplainthebasicstufflikethis. ThanksforexplainingRameshNatarajan.Todayonwards,Iamthememberofyourfanclub. 76saurabhDecember5,2012at2:41am Thanksforthisexcellentarticle. 77PurnaDecember18,2012at3:26pm Hello, Descriptionisgoodandveryeasytounderstand,thanksforthis. Ifpossiblepleaseexplainindetailabouteachandeveryconfigfileorscript,howisjumpingfrom onscript/configfiletoanother AnywaysIamhappyforthispost. Thankyouoncemore. 78RajshekharDecember28,2012at11:49am Excellentmaterial.Sosimpletounderstandit.Doingagreatjob!!!!! 79nikyDecember28,2012at1:08pm TheArticleisgoodAndexplainedSimple tnx4this 80CsubhashJanuary1,2013at6:36am Thanksforthisexcellentarticle 81AmitBhandariJanuary18,2013at12:31am itsasuperbarticle.andsimpleandsuperbexplanation. 82RajaswaminathanJanuary24,2013at8:33am Thisisreallynicearticle.Appreciateyourexcellentwork. 83karthiprasanthFebruary16,2013at7:12am sirnowiamusingwindows7andlinuxinonecomputer.idontwanttouselinuxthathave250gb harddiskthenhowtoboot(delete)alinuxandhowtoplaace250gbinwindows7?Plshlpme. 84AswathyFebruary25,2013at11:33am ThanksMr.Linuxnatarajan 85lakshmanMarch1,2013at4:59am
www.thegeekstuff.com/2011/02/linux-boot-process/
12/17
8/25/13
itwassimplygood. 86prathameshMarch1,2013at11:43am thanksdude 87chrlychackoMarch1,2013at11:15pm goodkeepitup 88KapilMarch20,2013at3:46am VeryGoodExplanation. Thankyouverymuch. 89LilyApril4,2013at12:36pm Hey,youexplainedall,excellent.Thanks 90RanjithApril6,2013at1:34am ThanksFriend 91shipraApril13,2013at11:51pm thnkss..veryusefulfome..) 92MageshApril16,2013at5:29am GreatMan.. 93laksApril19,2013at3:13am itsreallyuseful. 94googlerApril22,2013at2:25pm Ohyes..thisiswhatiamseekingfor..somethingsimpleandeffective.. idontknowwhymostpeoplewhotalkaboutbootprocessandFHSlovetomakeit verydifficult butyoumyfriend..urbrilliant..thisreallyeasyandusefulexplanation.. thanksasenormousasthesky 95shrutiApril27,2013at1:18am goodexplanation&easytounderstand!!! 96AnonymousMay4,2013at12:36pm excellent,verywellexplained 97sudhakarMay21,2013at11:24pm
www.thegeekstuff.com/2011/02/linux-boot-process/
13/17
8/25/13
Goodarticle. 98sreejithksMay26,2013at6:01pm awesomeman,whatasimplywaytoexplainsuchadifficultprocess.,,thanksalot,,keepgoing,, 99MiteshMay30,2013at3:22am ReallyNiceArticle.learnmuchfromthis Thanks 100AshokrajRMay30,2013at5:45am Thankyou 101AkshayJune23,2013at12:05pm PerfectarticleonGreattopic. 102ShamsJuly20,2013at1:19pm Ramesh, Thanksatonforyoureffortstoprovidesuchaexcellentinformationbykeepingitsimple. YourockmanKeepitup 103karthikJuly25,2013at1:32am nicejob.anyonecanunderstandthis.goodexplantion 104SurajAugust2,2013at1:12am SuperbArticle!!!Excellentexplanation. Keepiton. 105KaaliDasuAugust9,2013at1:50am Igotconfusedbystudyingtheprocessinanothersiteshoweverthisoneisveryeasyto understandandremember. LeaveaComment Name Email Website
www.thegeekstuff.com/2011/02/linux-boot-process/
14/17
8/25/13
Notifymeoffollowupcommentsviaemail
Submit
COURSE
LinuxSysadminCentOS6CourseMastertheTools,ConfigureitRight,andbeLazy
EBOOKS
Linux101Hacks2ndEditioneBookPracticalExamplestoBuildaStrong FoundationinLinux Bash101HackseBookTakeControlofYourBashCommandLineandShellScripting SedandAwk101HackseBookEnhanceYourUNIX/LinuxLifewithSedandAwk Vim101HackseBookPracticalExamplesforBecomingFastandProductiveinVim Editor NagiosCore3eBookMonitorEverything,BeProactive,andSleepWell
POPULARPOSTS
12AmazingandEssentialLinuxBooksToEnrichYourBrainandLibrary 50UNIX/LinuxSysadminTutorials 50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples) HowToBeProductiveandGetThingsDoneUsingGTD 30ThingsToDoWhenyouareBoredandhaveaComputer LinuxDirectoryStructure(FileSystemStructure)ExplainedwithExamples LinuxCrontab:15AwesomeCronJobExamples GetaGripontheGrep!15PracticalGrepCommandExamples UnixLSCommand:15PracticalExamples 15ExamplesToMasterLinuxCommandLineHistory
www.thegeekstuff.com/2011/02/linux-boot-process/
15/17
8/25/13
Top10OpenSourceBugTrackingSystem ViandVimMacroTutorial:HowToRecordandPlay Mommy,Ifoundit!15PracticalLinuxFindCommandExamples 15AwesomeGmailTipsandTricks 15AwesomeGoogleSearchTipsandTricks RAID0,RAID1,RAID5,RAID10ExplainedwithDiagrams CanYouTopThis?15PracticalLinuxTopCommandExamples Top5BestSystemMonitoringTools Top5BestLinuxOSDistributions HowToMonitorRemoteLinuxHostusingNagios3.0 AwkIntroductionTutorial7AwkPrintExamples HowtoBackupLinux?15rsyncCommandExamples TheUltimateWgetDownloadGuideWith15AwesomeExamples Top5BestLinuxTextEditors PacketAnalyzer:15TCPDUMPCommandExamples TheUltimateBashArrayTutorialwith15Examples 3StepstoPerformSSHLoginWithoutPasswordUsingsshkeygen&sshcopyid UnixSedTutorial:AdvancedSedSubstitutionExamples UNIX/Linux:10NetstatCommandExamples TheUltimateGuideforCreatingStrongPasswords 6StepstoSecureYourHomeWirelessNetwork TurbochargePuTTYwith12PowerfulAddOns
CATEGORIES
LinuxTutorials VimEditor SedScripting AwkScripting BashShellScripting NagiosMonitoring OpenSSH IPTablesFirewall ApacheWebServer MySQLDatabase PerlProgramming GoogleTutorials UbuntuTutorials PostgreSQLDB HelloWorldExamples CProgramming C++Programming DELLServerTutorials OracleDatabase VMwareTutorials
www.thegeekstuff.com/2011/02/linux-boot-process/
16/17
8/25/13
Ramesh Natarajan
Follow
1,743 followers
AboutTheGeekStuff
SupportUs
Supportthisblogbypurchasingoneofmyebooks. Bash101HackseBook SedandAwk101HackseBook Vim101HackseBook NagiosCore3eBook
ContactUs
EmailMe:UsethisContactFormtogetintouchmewithyourcomments,questionsor suggestionsaboutthissite.Youcanalsosimplydropmealinetosayhello!. FollowusonGoogle+ FollowusonTwitter BecomeafanonFacebook Copyright20082013RameshNatarajan.Allrightsreserved|TermsofService
www.thegeekstuff.com/2011/02/linux-boot-process/
17/17