The approximate process for system startup is as follows:
1. Load the hardware information of the Bois and perform post power-on self-test, and obtain the first bootable device according to the configuration;
2. Read and run the bootloader (i.e. grub, LILO, Spfdisk, etc.) of the MBR in the first starter unit;
3. Loading Kernel,kernel According to bootloader configuration will start to detect hardware and load drivers;
4. After the hardware driver succeeds, kernel will actively execute the/sbin/init, while the Init read/etc/inittab obtains run-level information;
5.init reads/etc/rc.d/rc.sysinit, executes the corresponding service process according to Run-level under/etc/rc.d/rc#.d/(#表示run-level), executes/etc/rc.d/ Rc.local a customized service process;
6.init Execute/bin/login program, enter login status
BOIS
The BIOS program is cured in the BIOS ROM, and the parameters of the BIOS setup are placed in the CMOS RAM.
BIOS work can be divided into two phases:
Phase one: Post power-on self-test, is one of the functions of the BIOS, mainly used to detect the system critical equipment is normal
Phase two: reads the first sector of the first boot device, the MBR, according to the system boot order set in the BIOS
Bootloader
Bootloader is the first 446B code in the MBR, and the main function is to read the corresponding configuration to locate and load the kernel image in the boot device and initrd the image into memory. Common bootloader are grub, Lilo, and Spfdisk, with grub as the example below.
Grub is usually divided into three stages of stage1, stage1_5, and Stage2
Stage1 and Stage1_5 for auxiliary loading stage2
Stage2 is used to read the grub configuration file/boot/grub/grub.conf and then load the kernel image and initrd mirroring into memory
Stage1: Reads 0 0 Channel 2 sectors into memory, content is/stage2/start in source code. S, it's the entrance to Stage1_5 or Stage2.
If start. The S-load stage1_5:stage1_5 is stored in the 0-head 0-Channel 3-sector backward position, with the ability to identify the file system, after which grub has the ability to position the Stage2 in the/boot partition/boot/grub/directory, load Stage2 into memory and execute
If start. S direct loading: This time Start.s reads the stage2 that is stored in boot sector of the/boot partition
Install Grub Stage1:
# Grub
grub> Root (hd0,0) probe disk, specifying disk type
grub> Setup (hd0)
Installing Grub Stage2
# Grub-install--root-directory=/path/to/boot ' S_PARENT_DIR/DEV/SDA
Boot system enters grub> prompt when grub configuration is damaged
Grub > Find (hd#,n)
grub> Root (Hd#,n)
Grub> Kernel/path/to/kernel_file
Grub> Initrd/path/to/initrd_file
grub> Boot
grub.conf file format
Default=0 # Sets the number of the default start title, starting with 0
Timeout=5 # waits for the user to select the timeout length, in seconds
Splashimage= (hd0,0)/grub/splash.xpm.gz # Grub Background image
Hiddenmenu # Hidden Menu
Password Redhat
Password--md5 $1$hkxj51$b9z8a. X//xa. Atzu1.kug.
Title Red Hat Enterprise Linux Server (2.6.18-308.el5) # kernel header, or operating system name, string, can be freely modified
Root (hd0,0) # The device on which the kernel file resides; For grub, all types of hard drives are HD, in the format (hd#,n), hd#, #表示第几个磁盘; the last N indicates the partition of the corresponding disk;
Kernel/vmlinuz-2.6.18-308.el5 ro root=/dev/vol0/root rhgb quiet # kernel file path, and parameters passed to the kernel
INITRD/INITRD-2.6.18-308.EL5.IMG # RAMDisk file path
Password--md5 $1$hkxj51$b9z8a. X//xa. Atzu1.kug.
Title Install Red Hat Enterprise Linux 5
Root (hd0,0)
Kernel/vmlinuz-5 ks=http://172.16.0.1/workstation.cfg Ksdevice=eth0 Noipv6
Initrd/initrd-5
Password--md5 $1$fsueu/$uhUUc 8usbk5qaxc.bfw4m.
The Grub-md5-crypt command is used to generate MD5 encrypted cipher strings
Kernel initialization
Stage2 the kernel image after it has finished loading, it transfers control to the kernel. The kernel initialization process is roughly three steps
1. Device detection
2. Load the device driver (may load the driver module from the INITRD (RHEL6 Initramfs) file)
3. Mount the root file system in read-only mode
4. Loading the first process init (pid=1)
Start the program
/sbin/init: (/etc/inittab)
Sysinit: The original init program, serial start, poor flexibility
Upstart:rhel6 under Use, Ubuntu develops, initiates multiple processes in parallel, and D-bus manages communication between processes
SYSTEMD: Provides a more aggressive parallel start-up capability than Upsart, using technologies such as Socket/d-bus activation to start services
RHEL5 under/etc/inittab's task:
1. Run the default run level;
2. Run the system initialization script;
3. Run the script in the directory corresponding to the specified run level;
4. Set the operation of the Ctrl+alt+del key combination;
5. Define the operation that the UPS power supply performs during power failure/recovery;
6. Start the virtual terminal (level 2,345);
7. Start the graphics terminal (level 5);
And RHEL6 only runs the default run level
RHEL5 under/etc/inittab file format
Id:runleves:action:process
ID: identifier
Runlevels: At which level does this line run
Action: Under what circumstances this line is executed
Process: The program to run
View the current operating level of the system
Runlevel:output Previous and current RunLevel
Who-r:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/71/48/wKioL1XKvMDwLG6lAABCX8QcUwo542.jpg "title=" Runlevels "alt=" Wkiol1xkvmdwlg6laabcx8qcuwo542.jpg "/>
Runlevels description
0:halt
1:single user mode, S,s,single directly as Administrator
2.multi User Mode,no NFS
3.multi User Mode,text Mode
4.reserved
5.multi User mode,graphic Mode
6.reboot
Action Description
Initdefault: Setting the default Run level
Sysinit: System Initialization
Wait: Execution when the waiting level switches to this level
Respawn: Once the program terminates, it starts once, such as logout in the control end, and then restarts a TTY
Tasks completed by/etc/rc.d/rc.sysinit
1. Activating Udev and SELinux
2. Set the kernel parameters according to the/etc/sysctl.conf file
3. Setting the Clock
4. Load Keyboard mapping
5. Start the swap partition
6. Set Host name
7. Root file system detection, re-mount after detection and read-write mode
8. Activating RAID and LVM devices
9. Enable disk quotas
10. Detect and mount other file systems according to/etc/fstab
11. Purge expired lock and PID files
Service class script in/etc/rc.d/init.d/
Usage/etc/rc.d/init.d/service Program {start|stop|restart|status|reload|configtest}
Each script has
#chkconfig runlevels SS KK-Represents a link that does not have a level that defaults to the beginning of s*
When the Chkconfig command is created for this script to create a link in the RC#.D directory, runlevels means that the link is created by default for the beginning of the s*, except that the level is created by default as a link starting with k*; ; K after the closing of the number of priorities for KK represented;
#description: A simple function for explaining this script, \ Continuation line break
Chkconfig
--list server_name: View the startup settings of all standalone daemons by default; Independent daemon
--add server_name: Added to the list of services, the corresponding link will be generated in the/etc/rc.d/rc#.d/directory
-del server_name: Delete
--level runlevels server_name {On|off}: defaults to level 2,345 if specified by default level
Type of daemon:
Independent Daemon Process
XINETD: Super Daemon, need to associate to RunLevel, transient daemon agent, manage transient daemon
Transient daemon: No need to correlate to runlevel
/etc/rc.d/rc.local:
The system finally starts a service that exactly says a script should be executed;
Linux Learning Notes < 17 >--linux system startup process