First stage: power-on
The moment the user presses the power switch, it is called the power on stage. At this stage, the BIOS checks the status of some hardware on the computer and the settings stored in the CMOS. CMOS is a special block inside the South bridge that allows the BIOS to store user settings (the options seen in the BIOS). North Bridge, the South Bridge is the chipset on the motherboard, AMD's CPU does not use this architecture, North Bridge control CPU and memory, South Bridge responsible for PCI,USB,VGA and other peripheral equipment.
Phase II: BIOS power-on self-test
The Power on stage starts with the BIOS activation process and the BIOS is the abbreviation for the input/output system, which is the software that determines the basic function of the machine before the computer has access to the disk, and contains the code to control the keyboard, display, and drive. The BIOS then executes in flash memory and then extracts itself and the data previously stored in the CMOS into memory. The BIOS function is primarily:1> self-test and initialization, detecting the motherboard hardware and notifying the start of execution. 2> set interrupt. 3> loads the operating system, which is forwarded by the BIOS to the boot sector, and then the boot sector jumps to each partition to activate the appropriate operating system.
Third stage: Read MBR
MBR ( Master Boot record, master boot recording), in the first sector of the hard disk, the previous stage BIOS loads the MBR into memory for execution. MBR is 512Byte, divided into three parts bootloader,partition table and magic number. Bootloader is the place where the MBR is used to store boot management programs (Grub,lilo, etc.). Bootloader performs the function of loading sectors and aspiration kernel. Magic number will always fill in "55AA", let bootloader in the boot manager to confirm that this place is MBR.
Stage Four: Loading bootloader
When the BIOS finds the MBR on the hard disk, the control is handed over to bootloader. Grub is a powerful boot management program that supports multiple boot management. /boot/gurb directory can see several system files, mainly the stage1,stage1_5,stage2 of these three types. STAGE1 is responsible for BIOS to bootloader, load boot management program, Linux is grub. stage1.5 recognizes different types of file systems, such as loading e2fs_stage1_5, to recognize the ext2 format. When stage1.5 is loaded, it gives grub the power to access the file system directory, meaning that the stage2 location can be found from the file system if Stage2 is not found at the beginning. Stage2 is the most core program of GRUB, the loading of operating system, new parameters, and the modification options are all stage2 responsible. Therefore, the stage2 is not too small, it is impossible to put in the MBR, can only be placed in the file system. And stage1.5 provides the ability to identify different file systems, which is a clever design. When Stage2 executes, the settings file is loaded from the existing file system,/boot/grub/grub.conf the configuration file. As follows:
# grub.conf generated by anaconda## note that you do not Have to rerun grub after making changes to this file# notice : you have a /boot partition. this means that# all kernel and initrd paths are relative to /boot/, eg.# root (hd0,0) #内核文件所在的设备, for grub, all drives are hd#, #表示第几个磁盘, and the latter represents the corresponding disk partition # kernel / vmlinuz-version ro root=/dev/sda2# initrd /initrd-[generic-]version.img#boot=/dev/ sdadefault=0 #设置默认启动的title编号, starting from 0. timeout=5 #等待用户选择的超时时常, Unit is seconds. Splashimage= (hd0,0)/grub/splash.xpm.gz #启动背景图片hiddenmenu #隐藏菜单title Red Hat Enterprise Linux 6 (2.6.32-504.el6.i686) #内核标题, or operating system name, Free to modify root (hd0,0) #内核文件所在的设备kernel /vmlinuz-2.6.32-504.el6.i686 ro root=uuid=77085801-d743-4704-b454-46954507f798 rd_no_luks rd_no_lvm lang=en_us. Utf-8 rd_no_md sysfont=latarcyrheb-sun16 crashkernel=auto keyboardtype=pc keytable=us rd_NO_DM rhgb quietinitrd /initramfs-2.6.32-504.el6.i686.img #initial RAMDisk the file system to be loaded by the activation system
Fifth stage: Kernel initialization
According to the/boot/grub/grub.conf configuration file, the kernel is extracted to memory according to the kernel path, so that the kernel obtains system control and bootloader exits. After the kernel takes over, the following procedures are performed:
1> Device Detection
2> Driver Initialization
3> mount the root file system as read-only (for security reasons)
4> installed in the first process init (pid:1)
Sixth stage: Execution of the first process/sbin/init
/ The main function of Sbin/init is to prepare the environment for the software execution, including the host name, network settings, language, file system format and other services of the system. All actions are planned according to/etc/inittab. RHEL6 version This file and RHEL5 differ greatly, can only set the RunLevel, other related configuration profile is clear, understanding RHEL5 Inittab file is very helpful to understand RHEL6 startup mechanism.
RHEL5 's Inittab file
## inittab this file describes how the init process should set up# the system in a certain run-level.## author: miquel Van smoorenburg, <[email protected]># modified for rhs linux by marc ewing and donnie barnes## default runlevel. the runlevels used by RHS are:# 0 - halt (Do not set initdefault to this) # 1 - single user mode# 2 - multiuser, without NFS (the same as 3, if you do not have networking) # 3 - full multiuser mode# 4 - unused# 5 - x11# 6 - reboot (do not set initdefault to this) # #id: runlevels:action: process #id: identifier; RUNlevel: At which level to execute; Action: under what circumstances; process: The program to run id:3:initdefault: #默认运行级别3 # system initialization.si::sysinit:/etc/rc.d/rc.sysinit #表示所有级别, the system initializes the execution of the/ETC/RC.D/RC.SYSINITL0:0:WAIT:/ETC/RC.D/RC 0 l1:1:wait:/etc/rc.d/rc 1 #运行指定级别对应目录下的脚本l2:2:wait:/etc/rc.d/rc 2l3:3:wait:/etc/ rc.d/rc 3l4:4:wait:/etc/rc.d/rc 4l5:5:wait:/etc/rc.d/rc 5l6:6:wait:/etc/rc.d/rc 6# trap ctrl-alt-deleteca::ctrlaltdel:/sbin/shutdown -t3 -r now #Ctrl +alt+ Del key combination function # when our ups tells us power has failed, assume we have a few minutes# of power left. schedule a shutdown for 2 minutes from now.# This does, of course, assume You have powerd installed and your# ups connected and working &NBSP;CORRECTLY.&NBSP;PF::p Owerfail:/sbin/shutdown -f -h +2 "Power failure; system shutting down" # Defining the operation of a UPS power failure # run gettys in standard runlevels1:2345:respawn:/sbin/mingetty tty1 #启动虚拟终端2:2345:respawn:/sbin/mingetty tty23:2345:respawn:/sbin/mingetty tty34 : 2345:respawn:/sbin/mingetty tty45:2345:respawn:/sbin/mingetty tty56:2345:respawn:/sbin/mingetty tty6 # run xdm in runlevel 5x:5:respawn:/etc/x11/prefdm -nodaemon #启动图形终端
/etc/rc.d/rc.sysinit is the system initialization script that accomplishes the following tasks:
1> activating Udev and SELinux
2> set kernel parameters according to the/etc/sysctl.conf file
3> Setting the Clock
4> Loading Keyboard mapping
5> starting the Swap partition
6> Setting the host name
7> root filesystem detection and re-mounting in read/write mode
8> activating raid and LVM devices
9> Boot Disk quotas
10> Check and mount other file systems according to/etc/fstab
11> clearing expired locks and PID files
L3:3:WAIT:/ETC/RC.D/RC 3 #进入级别3, execute/etc/rc.d/rc,/etc/rc.d/ In the Rc3.d folder, the service that begins with K will be turned off, the start of S will be turned on, the smaller the data is selected, and the last execution rc.local,rc.local can be put into the task that the user wants to boot .
RHEL6 's Inittab file
# inittab is only used by upstart for the default runlevel.# # adding other configuration here will have no effect on your system.## system initialization is started by /etc/init/rcs.conf## individual runlevels are started by /etc/init/rc.conf## ctrl-alt-delete is handled by /etc/init/control-alt-delete.conf## terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,# with configuration in /etc/sysconfig/init.## for information on how to Write upstart event handlers, or how# upstart works, see init (5), init (8), and initctl (8) .## default runlevel. the runlevels used are:# 0 - halt (DO&NBsp Not set initdefault to this) #关机 # 1 - single user mode #单用户 # 2 - multiuser, without nfs (the same as 3, if you do not have networking) #多用户, no Nfs# 3 - full multiuser mode #多用户, command line # 4 - unused #保留级别 # 5 - x11 #图形 # 6 - reboot (do not set initdefault to this) #重启 # id:3:initdefault:
The RHEL6 inittab file only sets the default run level.
Seventh Stage: Login
Start the virtual terminal after the user login interface, you can use the user name and password login.
This article is from the "Linux" blog, so be sure to keep this source http://yaoyaoquqi.blog.51cto.com/8124243/1619596
Talking about the Linux start-up process