Linux boot flow

Linux BootFlow:
BIOS Post Setup->MBR(GRUB/LILO)->Kernel->Kernel self-extract->Kernel Start

Kernel Start:
Create the process that ID is 1->The first process create other kernel threads->The kernel

threads load the /sbin/init binary file then that become a user level process->The init subroutine

 init the system with keyboard,font,netword etc by the /etc/inittab configure file:
The configuring flow of the redhat linux is:
/etc/rc.d/rc.sysinit->/etc/rc.d/rc.$RUNLEVEL->/etc/rc.d/rc.local->/sbin/mingetty(wait user

login)
The $RUNLEVEL variable configuring by the /etc/inittab file:
Value range is 0-6:
0:halt
1:Single user
2:Multiple user
3:Multiple user and start the NFS service
4:Reserve
5:Start xdm(X Window)
6:reboot

The /et/inittab file content:
#Set the run level when the machine is starting
id:3:initdefault

#Before starting the services with the current run level, run the bath file for system

initializing or testing.
si::sysinit:/etc/rc.d/rc.sysinit

#Needed services for each run level configured by the script file:
0:0:wait:/etc/rc.d/rc.0
1:1:wait:/etc/rc.d/rc.1
2:2:wait:/etc/rc.d/rc.2
3:3:wait:/etc/rc.d/rc.3
4:4:wait:/etc/rc.d/rc.4
5:5:wait:/etc/rc.d/rc.5
6:6:wait:/etc/rc.d/rc.6

#What to do when press the Alt+Ctrl+Del hot key
ca::ctrlatldel:/sbin/shutdown -t3 -r now

#Run the script file when starting with run level 5(X Window)
x:5:once:/etc/X11/prefdm -nodaemon

Syntax:
ID:Level:Init action:Instructions

ID:
Max length is 4 character,Just the identifier for the some work on init

Level:
What level is the instruction.example: 35 that is run when the run level is 3 or 5.

Init action:
Some instructions often is some script.

About GRUB:
The GRUB is a boot loader or using lilo when early version of linux.
After the BIOS post setup, the BIOS subrutine jump to the instruction load from MBR(0

cylinder 0 track 1 section) to executing.

/boot/grub/grub.conf file content:
default 0 --default starting item
splashimage (hd0,0) /boot/grub/splash.xpm,gz --the bk of grub start menu
timeout 20 --wait time for user select

title=Boot 1 --the menu title
root (hd0,0) --where is the root partition of hd for the linux kernel
kernel /boot/bzImage root=/dev/loop0 init=/initdisk.gz --where is the kernel file

initrd /initdisk/gz --use the initrd to load the kernel file

title= Boot 1 --the menu title
root (hd0, 1) --where is the partition of hd for the system
makeactive --set the partition to active(windows can't boot from a not active partition)
chainloader +1 --the chainloader command call the boot loader on the partition +1 indicates

the boot loader code offset.

If forget the root password do this:
$passwd root
$reboot

Set the password for grub:
password 123456 --pub this above all the default command

title Boot 1
lock --lock the menu item when password error

title Boot 1
password 123456 --pub the password only for the menu item

MD5 encrypt the grub password:
$grub-md5-crypt
$grub
grub>md5crypt

 

Referrence:

《linux 啓動詳解 分析 啓動流程》

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章