Linux System Boot Process

Source: Internet
Author: User

The boot process for Linux is not as complex as you might think, and the process can be divided into 5 phases:

1. Boot the kernel.

2. Run init.

3. Initialization of the system.

4. Set up the terminal.

5. User Login System.

Kernel boot

when the computer is powered on, it is the BIOS post that starts with the boot device (usually the hard disk) set up in the BIOS. after the operating system takes over the hardware, it first reads the kernel file in the/boot directory.

Run initThe init process is the starting point for all processes in the system, and you can compare it to the ancestor of all processes in the system, without which any process in the system will not start. the INIT program first needs to read the configuration file/etc/inittab.

Run Level

Many programs need to boot up. They are called "services" in Windows, and in Linux they are called "daemons" (daemon). One of the major tasks of the Init process is to run these boot-up programs. However, different applications need to start different programs, such as when serving as a server, the need to start Apache, as a desktop is not required. Linux allows different start-up programs to be assigned for different occasions, which is called "RunLevel" (runlevel). That is, at startup, depending on the runlevel, determine which programs to run.

The Linux system has 7 runlevel (runlevel):

<span style= "FONT-SIZE:14PX;" > Operation Level 0: System shutdown status, the system default RunLevel cannot be set to 0, otherwise it will not start the run Level 1: Single user working status, root permissions, for system maintenance, prohibit remote login run Level 2: Multi-User State (no NFS) RunLevel 3: Full multiuser State (NFS ), log in to the console command line mode run Level 4: The system is not in use, keep the RunLevel 5:x11 console, log in to the GUI mode run Level 6: The system shutdown and restart, the default RunLevel cannot be set to 6, otherwise it will not start normally <span class= "St" >0 System shutdown Status 1 single user or system maintenance status 2~5 Multi-user status 6 restart </span></span>

initialization of the systemthere is a line in the init configuration file: Si::sysinit:/etc/rc.d/rc.sysinit It calls execution/etc/rc.d/rc.sysinit, and Rc.sysinit is a bash Shell script, it is mainly to complete some system initialization work, Rc.sysinit is each run level to first run the important script.

Its main tasks are: Activating the swap partition, checking the disk, loading the hardware modules, and some other priorities that need to be performed.

<span style= "FONT-SIZE:14PX;" >L5:5:WAIT:/ETC/RC.D/RC 5</span>

This line indicates that running with the 5 parameter/ETC/RC.D/RC,/ETC/RC.D/RC is a shell script that accepts 5 as a parameter to execute all RC startup scripts under the/etc/rc.d/rc5.d/directory,/etc/rc.d/ These startup scripts in the rc5.d/directory are actually some connection files, not the actual RC startup scripts, and the actual RC startup scripts are actually placed in the/etc/rc.d/init.d/directory.

These RC startup scripts have a similar usage, and they generally accept start, stop, restart, status, and so on. The RC startup script in/etc/rc.d/rc5.d/is usually a connection file that starts with K or S, and will run with the start parameter for startup scripts starting with S. If you find that the corresponding script also has a K-link, and is already in the running state (the file under/var/lock/subsys/as the flag), the stop will be the first parameter to stop these started daemons, and then rerun. This is done to ensure that when Init changes the RunLevel, all associated daemons are restarted. As to which Daemons will be run at each run level, the user can be set from the row by using "System Services" in Chkconfig or Setup.
set up terminal

after the RC finishes executing, return to init. At this point the basic system environment has been set up, various daemons have been started.

Init then opens 6 terminals so that the user can log on to the system. The following 6 lines in Inittab define 6 terminals:

1:2345:respawn:/sbin/Mingetty tty12: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

from the above can be seen in the 2, 3, 4, 5 of the operating level will be respawn to run the Mingetty program, mingetty program can open terminal, set mode. At the same time it will display a text login interface, which is the login interface we often see, in this login screen will prompt the user to enter a user name, and the user input user will be passed as a parameter to the login program to verify the identity of the user.

User Login SystemIn general, there are three ways users sign in:

1. Command line Login

2.ssh Login

3. Graphical interface Login


How to switch between graphic mode and text mode

Linux presets provide six command window terminals let's log in.

By default we are logged in the first window, that is, Tty1, the six windows are Tty1,tty2 ... tty6, you can press CTRL + ALT + F1 ~ F6 to toggle them.

If you have a graphical interface installed, by default it is entered into the graphical interface, you can press CTRL + ALT + F1 ~ F6 to enter one of the command window interfaces.

When you go to the Command window interface and then return to the graphical interface just press CTRL + ALT + F7 to come back.

If you are using a VMware virtual machine, the shortcut keys for the command window switch are ALT + Space + f1~f6. If you are in the graphical interface, press ALT + Shift + Ctrl + F1~F6 to switch to the command window.


Linux shutdown

Most of the Linux domain is used on the server, and there are few shutdown operations. After all, running a service on the server is endless, unless in exceptional circumstances, the last resort will be turned off.

The correct shutdown process is: sysnc > Shutdown > Reboot > Halt

The shutdown instruction is: shutdown, you can look at the help document with man shutdown.

For example, you can run the following command to shut down:

Syncsynchronizes data from memory to the hard disk. shutdownshutdown instructions, you canMans shutdownTake a look at the help documentation. For example, you can run the following command to shut down:shutdown–hTen ' Thisserver would shutdown afterTenmins' This command tells you that the computer will beTenminutes and will be displayed in the current screen of the logged in user. Shutdown –H Nowturn off the machine immediatelyShutdown –h -: - the system will be today -: -turn off the machineShutdown –h+Ten shut down after 10 minutes .Shutdown –R Nowsystem restarts immediatelyShutdown –R+Ten system restarts after 10 minutesrebootis the restart, which is equivalent toshutdown–R Nowhaltshutting down the system is equivalent toshutdown–H Nowand thePoweroff

In conclusion, whether it is rebooting the system or shutting down the system, first run the sync command to write the data in memory to disk.

The command to shut down has shutdown–h now halt Poweroff and Init 0, and the command to restart the system has shutdown–r now reboot init 6.



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.