Introduction to Linux system boot process

Source: Internet
Author: User
Tags generator ldap local time syslog system log time and date openssh server nfsd

Introduction to Linux system Boot process

Learning the operating system is necessary to understand the system startup process, so that in the face of various system failures can quickly locate the problem, the following CentOS to analyze the startup process of Linux system.

1, the BIOS self-test: When the boot, the system for the BIOS self-test work, when the first hard disk (IDE SCSI) and its space, the system control will be passed from the BIOS to the boot loader

2. Boot loader (grub Lilo): The Primary 512 bytes of the first hard disk are loaded in the physical data sector that is the main boot area MBR into memory, the boot loader at the beginning of this sector will take over the system control.

(It can also be understood that after the first step is completed, the MBR is loaded into memory, and the bootloader takes over the system control)

3. Load RAM Disk: Provides a minimal Linux environment to execute the program before loading the actual root file system.

4. RAM Disk Run INIT: This program performs all the operations required to load a real root file system.

Load kernel modules: To access the final root file system, the kernel needs to mount the appropriate file system driver

Manage RAID and LVM: If the system configuration holds the root file system under RAID or LVM, Init will set up LVM or RAID to support later access to the root file system

Load the final root file system: After locating the root file system, check it for error and mount it.

5. Run init on the root file system: If the above four steps are successful, the RAM disk will be cleared and the system boot profile /etc/inittab executed to execute the INIT program on the real root file system

Description of the terms:

First ,/etc/rc.d/rc.sysinit: Refers to the system initialization script

The relevant contents of the initialization are:

1. Mount the/proc file system

2. Set the system clock

3, general system environment variable setting

4. Initial make-up USB and HID

5. Set PnP

6. Loading keyboard mapping, loading system fonts, loading system modules

7. Initialize RAID, initialize volume mapping

8. Check file system, mount file system

9. Activate disk quotas, activate swap partitions

10. Initialize the serial device

11. Generate System Startup information log file

Second,/etc/rc.d/rcx.d/[ks]*: Configure the service according to the operation level

K means terminating services starting with K

s to start a service that starts with S

Third,/etc/rc.d/rc.local: Perform local special configuration

Other: Special services at different operating levels

Mingetty: In addition to run level 1

XDM/GDM/KDM: Run Level 5

The init process is run by the Linux kernel and is the first process in the system running, and its process number is always 1. After the Init process runs, it installs its configuration files, directs the other processes required to run the system, and the init process acts as the parent process for those processes.

The following is the configuration information in/etc/inittab:

Define various run levels

0-halt (do not set Initdefault to this)
1-single user mode 2-multiuser, without NFS (the same as 3, if you don't have networking)
3-full multiuser mode
4-unused

5-x11
6-reboot (do not set Initdefault to this)

Define the default run level
Id:3:initdefault:

System initialization
Si::sysinit:/etc/rc.d/rc.sysinit

Different levels of scripting calls
L0:0:WAIT:/ETC/RC.D/RC 0
L1:1:WAIT:/ETC/RC.D/RC 1
L2:2:WAIT:/ETC/RC.D/RC 2
L3:3:WAIT:/ETC/RC.D/RC 3
L4:4:WAIT:/ETC/RC.D/RC 4
L5:5:WAIT:/ETC/RC.D/RC 5
L6:6:WAIT:/ETC/RC.D/RC 6

Start 6 virtual Consoles in the 2, 3, 4, 5 run levels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty Tty2
3:2345:respawn:/sbin/mingetty Tty3
4:2345:respawn:/sbin/mingetty Tty4
5:2345:respawn:/sbin/mingetty Tty5
6:2345:respawn:/sbin/mingetty Tty6

Start the XDm manager in the 5 run level
X:5:respawn:/etc/x11/prefdm-nodaemon

6. Display source files

7. Login

I. Introduction of the CentOS boot process
The following is a brief description of the CentOS startup process:
1, BIOS self-test: When the first hard disk and its space is recognized, the system control will be passed from the BIOS to the boot loader.
2. Boot loader: Load the first 512 bytes of physical data sector (master boot record, MBR) into memory, and the boot loader at the beginning of this sector (e.g. GRUB) will take over the system control.
The commands executed by the boot loader determine the remainder of the boot process. The boot loader then passes control to the actual operating system (the Linux kernel).
3. Load RAM Disk: Provides a minimal Linux environment to execute the program before loading the actual root file system.
4. Run init in the RAM disk: This program performs all the operations required to load the real root file system.
Load kernel modules: Depending on the hardware configuration, some special drivers may be required to access the hardware parts of the computer (the most important part is the hard disk). To access the final root file system, the kernel needs to mount the appropriate file system driver.
Manage RAID and LVM: If the system configuration holds the root file system under RAID or LVM, Init will set up LVM or RAID to support later access to the root file system.
Load the final root file system: After locating the root file system, check it for error and mount it.
5. Run init on the root file system: If the above operation succeeds, the RAM disk will be cleared and the system boot profile/etc/inittab executed to execute the INIT program on the real root filesystem.
/etc/rc.d/rc.sysinit--System Initialization Script
Mount the/proc file system
Setting the system clock
System general environment variable settings (such as host name, etc.)
Initializing USB and HID devices
Set up PnP
Loading keyboard mappings
Loading system fonts
Loading system modules (e.g. sound modules, etc.)
Initialize RAID
Initializing volume mappings
Check the file system
Mount File System
Activating disk quotas
Activating swap partitions
Initializing the serial device
Log file to generate system boot information
Wait a minute
/etc/rc.d/rcx.d/[ks]*--Configure the service according to the RunLevel (X):
Terminating services that begin with "K"
Start a service that begins with "S"
/etc/rc.d/rc.local--performing Local Special configuration
Other-special services at different operating levels:
Mingetty (except run Level 1)
XDM/GDM/KDM (Run Level 5)


Ii. Description of document/etc/inittab
The behavior that begins with # comments the line, and each of the other lines includes the following four fields (each field is separated by a ":" Interval):
Id:runlevels:action:process
which
ID: is the identifier for each valid row. For each row that defines Getty, the identifier specifies the terminal that Getty runs (that is, the number character after the device file/dev/tty);
For other rows, there is no special requirement except for the length limit, but the field must be unique throughout the file.
Runlevels: Specifies the RunLevel, each run level is represented by a single number, you can specify multiple run levels, but you cannot include any spacers.
Action: Specifies the running state, which can be evaluated as follows
Respawn: Run the command again after the command specified in the next field finishes
Wait: Executes the command specified in the next field and waits for it to end before running another command
Once: Executes the command specified in the next field without waiting for it to end
Boot: Executes the command specified in the next field at system startup and ignores the RunLevel
Bootwait: Executes the command specified in the next field after the boot completes and waits for it to end
OFF: Instructs Init to undo the process that corresponds to the command specified in the next field
Initdefault: Specifies the state of the RunLevel entered at first boot
Sysinit: Executes the command specified in the next field when communicating with the system console
Powerwait: Executes the command specified in the next field when a power error occurs and waits for it to end
Powerfail: Executes the command specified by the next field when a power error occurs, without waiting for it to end
Powerokwait: Executes the command specified by the next field when power is restored
Ctrlaltdel: Executes the command specified by the next field when the Ctrl+alt+del key combination is pressed
Process: This field specifies the command to run


Iii. Introduction to common system processes
1. Hardware Management daemon
APMD (Advanced Power Management) is a premium management. Traditional power management standards, for notebook computers are more useful, you can understand the system's battery power information. and writes the relevant information to the log through SYSLOGD. can also be used to shut down when power is low.
Acpid (Advanced Configuration and Power Interface) is a new power management standard that has been introduced to replace traditional APM power management standards. Usually laptops need to be powered up for management.
Alsasound Alsa sound card driver daemon. Alsa and Oss/free and Oss/linux are compatible, but have their own interfaces, even better than OSS.
Cups cups (Common Unix Printing System) is a generic UNIX print daemon that provides third-generation printing capabilities for Linux.
The cups print system switches daemons.
CUPS-LPD the cups row print daemon.
LPD LPD is an old-fashioned print daemon responsible for submitting programs such as LPR to a print job.
The GPM gpm (General Purpose Mouse Daemon) daemon provides mouse support for Linux programs in text mode such as MC (Midnight Commander). It also supports copy, paste, and pop-up menus for mouse under the console.
Irqbalance a daemon that load balances system interrupt requests in multiple system processor environments. If you have only one CPU installed, you do not need to load this daemon.
Kudzu Hardware Automatic detection program, will automatically detect whether the hardware changes, and the corresponding hardware additions, deletions work.
When the system starts, Kudzu detects the current hardware and controls the hardware information stored in the/etc/sysconfig/hwconf, and if a hardware is added or removed from the system,
Then Kudzu will be aware of, and inform the user whether the configuration, and then modify the/etc/sysconfig/hwconf, so that the hardware data and the system to keep in sync.
If/etc/sysconfig/hwconf This file does not exist, then kudzu will be from/etc/modprobe.conf,/etc/sysconfig/network-scripts/, and/etc/x11/ Detects existing hardware in the xf86config.
If you do not intend to add new hardware, you can turn off the startup service to speed up the system startup time.
Lm_seroems Detection of motherboard work daemon.
Mdmonitor the daemon for RAID-related devices.
Microcode_ctl can encode and send new micro-code to the kernel to update the Intel IA32 Series Processor Daemon.
PCMCIA is primarily used to support the laptop interface daemon.
Rawdevices the daemon used to load raw devices when using a clustered file system.
SMARTD Self Monitor Analysis and Reporting technology System, monitor your hard drive for failure.
2. System Management Daemon
ATD the AT and Batch command daemons, the user dispatches the task with the AT command. Batch is used to run batch tasks when the system load is low.
Anacron an automated running task daemon. CentOS comes with four automated task tools: Cron, Anacron, at, and batch. When your Linux server is not running all day, this anacron can help you perform the work that you did not do during the "crontab" time set.
Crond Cron periodically runs user scheduling tasks.
Cpuspeed monitors System idle percentages, reduces or accelerates CPU clock speed and voltage to minimize energy consumption when the system is idle, and maximizes system execution speed when the system is busy.
Iiim Chinese Input Method Server daemon.
Psacct The daemon includes several tools for monitoring process activity, including Ac,lastcomm, Accton, and SA.
The random number generator that saves and restores the system's high-quality random numbers is provided by some random behavior of the system.
Syslog a script that allows the system to boot Syslog and klogd the system log waiting process.
XFS x Window Font Server daemon that provides font sets for local and remote X servers.
YUM-UPDATESD RPM OS automatic upgrade and package management daemon.
AMD automatically installs the NFS daemon.
Atalk AppleTalk the network daemon. Be careful not to run the program in the background, the program's data structure must be initialized before running other processes.
AutoFS automatically installs the management process AutoMount, which is related to NFS and relies on Server for NIS.
Netdump Remote network backup server daemon.
Diskdump Server disk Backup daemon.
Portmap The daemon is used to support RPC connections, and RPC is used for services such as NFS and NIS.
Netfs network Filesystem Mounter, which installs and uninstalls NFS, samba, and NCP networking file systems.
NFS Network File System daemon.
Nfslock NFS is a popular protocol for sharing files over a TCP/IP network, and this daemon provides the NFS file locking feature.
rsync Remote sync Data backup daemon.
3. Database Management daemon
ARPTABLES_JF controls the filtering daemon for users of the Arptables network.
Arpwatch logs and builds an Ethernet address and IP address pair database that you see on the LAN interface.
The BOOTPARAMD boot parameter server provides the information needed to boot the diskless workstation on the LAN.
The LDAP LDAP (Lightweight Directory Access Protocol) directory accesses the protocol server daemon.
Mysqld a fast, efficient and reliable lightweight SQL database engine daemon.
PostgreSQL PostgreSQL relational database engine.
Ypbind activates the Ypbind service process for NIS (Network Information System) clients.
YPPASSWDD NIS password Server daemon.
Ypserv NIS master server daemon.
4, network Equipment daemon Process
Bluetooch the Bluetooth server daemon.
NETPLUGD (Network cable hotplug Management daemon) daemon, which monitors the state of one or more network interfaces and runs an external script program when certain events are triggered.
Messagebus D-bus is a library that provides one-to-two communication for two or more applications. Dbus-daemon-1 is an application that uses this library to implement the Messagebus daemon. Multiple applications can exchange information with other programs by connecting the Messagebus daemon.
PPPoE ADSL Connection daemon.
IrDA Infrared Port Daemon.
ISDN ISDN starts and aborts the service daemon.
SNMPD Local Simple Network management daemon.
Network activates/shuts down the various web interface daemons at startup.
Iptables iptables Firewall daemon.
5. Network SERVICE Daemon
Chargen uses the TCP protocol Chargen Server,chargen (Character Generator Protocol) is a network service, the main function is to provide similar remote typing capabilities.
CHARGEN-UDP Chargen server that uses the UDP protocol.
DHCPD the service daemon for Dynamic Host Control Protocol (PROTOCOL).
Daytime uses the TCP protocol's daytime daemon, which provides the client with the ability to obtain the date and time from a remote server. Default port: 13.
DAYTIME-UDP uses the daytime daemon of the UDP protocol.
Time the daemon obtains the times and dates from the remote host, using the TCP protocol.
TIME-UDP The daemon obtains the time and date from the remote host, using the UDP protocol.
Dc_server the proxy server daemon that uses SSL Secure sockets.
Dc_client the client daemon using SSL Secure sockets.
Echo Server echoes the customer data Service daemon.
ECHO-UDP the Client Data Service daemon is echoed by the server using the UDP protocol.
The named DNS (BIND) server daemon.
Gated Gateway Routing daemon. It supports a variety of routing protocols, including RIP versions 1 and 2, the DCN Hello Protocol, OSPF version 2, and EGP versions 2 through 4.
The HTTPD Web server Apache daemon can be used to provide HTML files as well as CGI dynamic content services.
Innd Usenet news server daemon.
The NTPD Network time Protocol daemon (NET Temporal correction protocol). NTPD is the protocol daemon used to keep the system and an accurate time source in sync with time.
PROFTPD PROFTPD is a daemon that configures a flexible FTP server under UNIX.
ReadAhead, Readahead_early ReadAhead, and Readahead_early are the latest two daemons running in the background in Fedora Core 2. The function is to start the system, the file to be used to start the system to read into memory, and then execute in memory to speed up the system.
Routed the daemon supports automatic IP routing table maintenance for RIP protocols. RIP is primarily used on small networks where a larger network requires a more complex protocol.
Rsh starts a shell on the remote host and executes the user command.
Rwhod allows a remote user to obtain a list of all logged-in users on the machine running the rwho daemon.
RSTATD a waiting process for collecting and providing system information for other machines on the LAN.
Ruserd Remote User Location service. This is an RPC-based service that provides user information about the current record to a machine log in the LAN
RWALLD Remote User Message delivery service. This is an RPC-based service that allows users to write messages to each other terminal that is registered on the LAN machine.
The Rwhod rwhod service process, which supports LAN rwho and ruptime services.
SASLAUTHD uses the SASL authentication daemon.
SendMail sendmail MTA Daemon.
postfix postfix MTA Daemon.
SMB Samba File share/Print Service daemon.
Squid Agent Server Squid daemon process.
sshd OpenSSH Server daemon. Secure Shell protocol enables remote management of hosts safely.
Tux running the Apache server daemon in the Linux kernel.
VSFTPD The daemon of the VSFTPD server.
Vncserver VNC (Virtual network Computing), which provides a lightweight protocol that displays the entire "desktop" of a remote computer on a local system.
inetd Internet Operation Daemon. Monitor the network's needs for the various services it manages, and start the appropriate service programs when necessary. Replaced by xinetd in Redhat and Mandrake. Debian, Slackware, and SuSE are still used.
XINETD a Super server daemon that supports multiple network services.
Eklogin a rlogin session forensics daemon that uses Kerberos 5 encryption.
Gssftp FTP daemon with Kerberos 5 authentication
Krb5-telnet uses the Kerberos 5-certified Telnet daemon.
The Klogin uses the Kerberos 5 authentication remote login daemon.
Kshell a remote Shell daemon that uses Kerberos 5 authentication.

Vi. LVM Command Set
LVM has a complete set of commands, and the following table lists common commands.
Task PV VG LV
Create Pvcreate vgcreate lvcreate
Remove Pvremove vgremove lvremove
Scan list Pvscan Vgscan Lvscan
Display Properties Pvdisplay Vgdisplay lvdisplay
Display Information PVs VGS LVS
Change attribute Pvchange Vgchange Lvchange
Extended Vgextend Lvextend
Reduced Vgreduce Lvreduce
Renaming Vgrename Lvrename
Change capacity Pvresize lvresize
Check Conformance Pvck Vgck


Vii. command common options for SAR
Option description
-a equivalent to-bbcdqrruvwwy-i sum-i xall-n all-p All
-B Display statistics for I/O and transfer rates
-B Output Memory page statistics
-C Output Process statistics, number of processes created per second
-D output activity information for each block device
-I interval specify the interval length in seconds
-p displays friendly device names for easy viewing, and can be used in conjunction with the-D and-n parameters, such as-DP or-NP
-Q Output Process queue Length and average load status statistics
-R output memory and swap space statistics
-R Output Memory page statistics
-T reads the/VAR/LOG/SA/SADD data when the original time of the record is displayed, and if there is no this parameter uses the user's local time
-U Output CPU usage statistics
-V Output statistics for inode, files, and other kernel tables
-V Output Version number information
-W output system exchange activity information
-W Output System exchange statistics
-Y output TTY device activity information
-N {dev| edev| nfs| nfsd| sock| All} analyzes output network device status statistics.
DEV reports statistics about network devices
Edev reporting error statistics for network devices
NFS Reports activity Statistics for NFS clients
NFSD reporting activity statistics for NFS servers
SOCK Reporting Network sockets (sockets) Usage statistics
All reports all types of network activity statistics
-X {pid| Self| All} outputs statistics for the specified process.
PID specifies a specific process with PID
Self means that the SAR itself
All indicates that all processes
-X {pid| Self| All} outputs statistics for the child processes of the specified process
-I. {irq| sum| all| Xall} outputs the statistics that specify interrupts.
IRQ Specifies the interrupt number
SUM specifies the total number of interrupts that the output receives per second
All specifies the first 16 interrupts of the output
Xall Specifies the output of all interrupt information
-P {cpu| All} outputs the statistics for the specified CPU
-o filename Saves the output information to the file filename
-f filename Reads data information from the file filename. FileName is the file that is generated when you use the-o option.
-S Hh:mm:ss Specify the starting time for the output statistics
-e HH:MM:SS Specifies the end time of the output statistic, which defaults to 18:00:00


Viii. Miscellaneous
1. Viewing and switching the run level
The user can use the following command to view the current system's run level:
$ runlevel
The user can switch the run level using the following command:
# init [0123456Ss]
After the init command, there is a parameter, which is the code of the run level to switch to, such as:
The init 0 command indicates switching to run level 0, which is shutdown.
The init 1 command represents a switch to run Level 1, which is entered into single-user run mode.
The init 6 command indicates a switch to run Level 6, which is a reboot.

2. Single user mode
The root file system in single-user mode enters the "Read-only file system" read-only state, where you can re-mount the root filesystem using the following command:
sh-3.1 # mount-o remount rw-t ext3/
When the user enters Repair mode, it will get root user rights, the entire root file system on the hard disk is mounted to the directory "/mnt/sysimage"

3. View the encoding that supports conversion
$ iconv-l
Encoding Conversion
$ iconv-f iso-8859-1-T UTF-8-o outputfile inputfile
Convert a DOS-formatted text file into a UNIX-formatted text file
$ Dos2unix Dosfile
$ Unix2dos Linuxfile

4. Input/Output redirection
STDIN 0 Standard Input Keyboard command the input data to be obtained when executing
STDOUT 1 standard output monitor command execution output from this port
STDERR 2 standard error message when the display command executes is sent through the port
<<!......! A special case for implementing input redirection, the here file
2> or 2>> Implementing error redirection
&> simultaneous output redirection and error redirection

5. Incremental backup with the Find tar command
The first way:
Find a list of files that have been modified before a certain time through the Find command-mtime option Etc.txt
# find/etc-mtime-1-print | Grep-v '/$ ' > Etc.txt

Use the-t option of the TAR command to package the files in the C.txt list to enable incremental backup functionality
# tar ZCVF etc.tar.gz-t etc.txt

The second way:
Find a new file than/etc/passwd by finding it first.
# FIND/ETC-NEWER/ETC/PASSWD
A new file is displayed for mtime than/etc/passwd.
# LL/ETC/PASSWD
-rw-r--r--1 root root 6 June 20:31/etc/passwd
Use tar to package the date as seen above 2011-06-27 20:31:00
# tar zcvf etc.newer.tar.gz--newer-mtime= ' 2011-06-27 20:31:00 '/etc/*

Introduction to Linux system boot process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.