CentOS 6 Start-up process | Root Password Reset | Adding system Services
First, the CentOS 6 startup process:
1) Post power -on self-test
Power-on-self-test, the motherboard in the power supply, the system first by the BIOS program to the CPU, motherboard, memory, hard disk subsystem, display subsystem, serial parallel interface, keyboard, CD-ROM drive and other hardware conditions detection.
If an error is found in the self-test, it will be handled in two cases: for a serious fault, or for a non-critical fault, a prompt or audible alarm signal is waiting for the user to process.
Motherboard ROM: Saved BIOS program RAM: Save various parameter settings
The BIOS locates the boot device in a set order, and the first device with the boot program is the boot device.
2) Read MBR
Read the first boot device MBR bootloader(first 446 bytes), CentOS 6 is the Grub program , bootloader Space Limited only saved the first phase of Grub Stage1.
3) boot loader GRUB
stage1: exists in the first 446 bytes of MBR, loading stage1_5,stage2,initramfs*.img
stage1_5: In the 62 sectors after the MBR, the necessary file system drivers are saved, so that stage1 can identify the file system on the Stage2 partition;
stage2: Provides a menu interface that allows the user to load the kernel with options, change parameters, modify options, and get the contents of files such as grub.conf and Menu.lst, to provide authentication protection mechanisms.
4) Loading the kernel
Self-initialization:
Detect all hardware devices that can be identified
Load the hardware driver (possibly with RAMDisk load driver)
The kernel does not recognize the device on the drive on the hard disk, with the initramfs-version-release.img file in the recognized boot partition (a small, compact root directory containing the driver modules that are necessary for the start-up phase, Executable files and startup scripts),
Mount it as a temporary root directory, execute a startup script, load the real file system to mount the real root directory, and switch the root directory.
Mount the root file system as read-only
The first application running user space:/sbin/init
5) Start init
The kernel is loaded, the INIT program is run, and the system-initiated control is transferred to the INIT process
The init process is the parent process for all processes, and it reads the configuration file/etc/inittab to do the following:
1. Execute the System initialization script (/etc/rc.d/rc.sysinit), Carry on basic configuration to the system, mount the root file system and other file system in read-write mode, carry on the determination of operation level and start the corresponding service;
2. Determine the operating level entered after startup, a total of 7, the default 3, 5;
3. Implementation/ETC/RC.D/RC, the order in which services are started is first k after S, and the service state for each runlevel is placed in the/etc/rc.d/rc#.d (#=0~6)directory, all files are linked to the corresponding file under/ETC/INIT.D.
4. Settings for key sequence
5. Script definitions for UPS
6. Start the virtual terminal/sbin/mingetty
7. Run X on Run level 5
System initialization:
Post-->bootsequence (BIOS)-->bootloader (MBR)-->kernel (RAMDisk)-->rootfs-->/sbin/init
To add a custom boot run script in Rc.loacl:
At normal level, the last service s99local is not linked to a script under/ETC/INIT.D, but is linked to/etc/rc.d/rc.local (/etc/ rc.local) script, so that a program that is inconvenient or does not need to be written as a service script can be placed directly in this script file when it is expected to run automatically.
Second, root Password reset
1. Enter single-user mode
Type E at power-on, enter the Grub menu page, type A, add 1,s,s,sigle any one at kernel end, that is, single user mode, enter boot system
2. Change your password directly with passwd
You can change your password by typing passwd directly after entering the command line
Third, add system services
The system service scripts in CentOS 6 are placed in the/ETC/INIT.D directory, and when a user operates on a service using the Services command, the script is actually called, so we can add our own service scripts.
1. Writing Service Scripts
First three lines basic format: VI testsrv
#!bin/bash
#chkconfig: 35 91 09
#description: Testsrv.
Script first Behavior Shellbang
The second line chkconfig followed by 3 digits, the 1th number is the level to start , the 35 table runs at 3 or 5 o'clock, and the 2nd number is the start priority , the higher the number, the lower the priority, the more it starts at the back, and the 3rd number is the off priority , the smaller the number, the higher the priority, the more the first is closed;
General after two number of the sum of 100, the service is not high dependent can be started after the start, after the first shutdown; the next two bits are one digit (0-9), should be written in 08 format
The third behavior describes the information, which can be modified as needed.
The service script should be able to recognize the basic parameters [Start|stop|restart|status]
Put the written script in the/ETC/INIT.D directory.
2. Add As System service
Chkconfig--add/etc/init.d/testsrv
This command adds the script as a system service, allows Chkconfig to manage it, and creates a corresponding symbolic link k/s entry in each run-level startup service (/ETC/RC.D/RC#.D) directory, the K-Start table closes, and the S-Start table starts
3. Service Operation
Chkconfig--level testsrv on modify default boot level for service
Service Testsrv Restart Restart services
This article is from the "mediocre" blog, please be sure to keep this source http://zzjasper.blog.51cto.com/9781564/1850571
CentOS6 system Start-up process