Boot Process and shutdown, File System

Source: Internet
Author: User
Tags dmesg
Boot Process
Importance:
Don't you just need to press the power button and shut down the system as long as you turn off the power button? What are university questions? This is true, but since Linux is a multi-person and multi-work operating system, it is difficult to ensure that no one is online when you shut down the system, if you happen to have a large group of people working online when you shut down, the people working online will be disconnected immediately! It's not killing people! Some materials are invaluable! In addition, unlike the DOS environment, during Linux execution, although you only see a piece of black pressure on the screen, there is no picture at all, but in fact, he runs many programs in the background, such as email programs and browser host programs, it can easily hurt hard disks and data transmission! So shutdown in Linux is a university question!
Process Analysis:
Since the boot process is very serious, please take a look at the entire boot process! This makes it easy for you to find out what went wrong during the boot process! However, during the boot process, the boot loader may use different software. For example, after Red Hat 7.2, the Lilo and grub boot drivers are provided at the same time, so the process may be a bit different. In this webpage, vbird is familiar with Lilo, so the boot loader mentioned in the future will be based on Lilo. So what is Lilo ?! To put it simply, he is short for Linux Loader, that is, he just loaded it during Linux boot! This is the lifeblood of your multiple boot! However, this article does not tell you how to make multiple boot times. You should read the previous articles first. After reading the Linux commands, you can set your multiple boot times, it will be easier! In addition, after you re-compile the core, you must re-install Lilo. At that time, I will tell you about it. ^_^! So I will not explain it to you here! Let's start talking about how Linux is started? The basic process is:
1. hardware information for loading BIOS;
2. Read the boot information of MBR kernel loader (that is, Lilo, grub, spfdisk, etc;
3. Load the core information of the kernel job system;
4. Run the INIT program in the kernel and obtain the Run-level information;
5. Run the/etc/rc. d/rc. sysinit file in init;
6. Start the external mounted modules (/etc/modules. conf) of the core );
7. init execute the Run-level various batches (scripts );
8. Run the/etc/rc. d/rc. Local file in init;
9. Run the/bin/login program;
10. After logging in, start using shell to control the host.
The general process is what we wrote above, and what is the main content of each program? Let's talk about it separately!
1. Search for BIOS hardware loading information: people with a little PC hardware experience probably know the role of BIOS (Basic Input/Output setup! He is the first computer to be loaded! CPU information of your host, boot sequence, hard disk size, working status of the chip group, enabling or not of the PNP, memory time, and so on... this is recorded in the BIOS! So, after the instance is started, the system will first look for this item;
  
2. Read the kernel Loader from the MBR on the hard drive? Haha! Of course, the hard drive boot information! After reading the bios, the personal computer system will first read the first magnetic zone (Master Boot Record, MBR) of the first boot hard drive !), This magnetic zone is mainly used to record boot information! Remember the Lilo mentioned above? His record is here! So now, the information recorded by Lilo will be read, and the system will start different systems based on lilo information. This is where multiple boot settings are located;
  
Vbird: Generally, the multi-boot software we know is to write their multi-boot information here (MBR). Then, when the system starts up, the system will first find this location, and then find the relevant boot settings! For example, Linux will find the/boot file, Windows will find/boot. ini and so on! If you want to kill this location, there is no way to kill this information because of the DOS format! Therefore, if you want to remove MBR data, you need to use the "fdisk/MBR" of the DOS system! Basically, we do not recommend killing Linux! Because of his good functions! Why do I need a loader? I think we have to discuss this topic first! I 'd like to know before that. Do you know that Windows and Linux have different file formats ?! Haha! Of course it's not the same, right? Well, let's talk about it again. How does your computer know what system your hard drive is? Haha! That is the main function of loader! Before you can use the system, you must load the core, right !? But how can you make your hardware understand the core? That is the main function of kernel Loader! Therefore, we need to propose that Linux Loader can recognize the core file of windows, but Windows does not know the core file of Linux. Therefore, as a loader with multiple boot configurations, you cannot use the loader provided by windows! To let the system know your kernel, you need kernel Loader! That's right!
3.
4. kernel loading: Now that you know which operating system to use to start up, the host will load its core under the magnetic zone of the operating system. In Linux systems, the core of boot is usually placed under/boot. Therefore, at this time, the system will go to/boot to find the relevant core (this will be mentioned again in the future !) Our kernel name is usually in the/boot/vmlinuz-XXXX format !;
  
5. The core executes init and the system logon status is obtained by/etc/inittab: After the core is loaded, the first program executed by the core is/sbin/init! The first goal of this program is, of course, to determine how the host will log on! In this case,/sbin/init must be used to load/etc/inittab information! In Linux, how many login modes are there? Well! It seems that you need to describe the logon status of Linux! If you enter the/etc/inittab file of Red Hat (you can use VI), you will see the following information:
   
1. The above shows the current login status (that is, run-level !), 0 ~ We usually use the logon status of "3" and "5", because we need multiple users in Linux, and the logon status is text and graphic interface! So set it to 3 or 5. Do not set it to 0 or 6! Otherwise, the system will be directly restarted or shut down directly... the default system login is recorded in the bottom line of the above table! Is the line "ID: 3: initdefault! Note! Vbird defaults to a text interface for logon, so it is only 3. If you want to change to a graphical interface for Logon (please make sure your X-Windows is correct ), in this case, change 3 to 5 in the line above/etc/inittab!
  
Vbird: If you have used Windows, if you press F8 during startup, isn't there any "safe mode", "normal boot" or "MS-DOS mode" and so on into the windows status? Especially when you do not shut down normally, Windows is started in "safe mode" by default! Windows's "safe mode" almost does not load some complex modules, so that your windows will be able to boot successfully! In Linux, the maintenance mode is in single-user mode (run_level is 1 !) So what is the login status in Linux? Haha! That's right. It's loaded here!
2.
3. the first execution content of init/etc/rc. d/RC. sysinit: after confirming the logon status, you must read the host information to the Linux system! The first file in Linux is/etc/rc. d/sysinit! If you are free to access this file, you will find that the file contains ==> set the default path (PATH) set the host name, run the network information recorded by/etc/sysconfig/network, Mount/proc, the basic host information stored in the memory, and the basic information of several other Linux operating systems several pieces of information! His basic work is:
  
O set the default path: (PATH)
O set the network status: the system reads/etc/sysconfig/network again, and stores the files in the file, such as networking, forward_ipv4, hostname, domainname, wary, gatewaydev and other settings are read into the system.
O swap space for the startup system (which can be thought of as virtual memory): Swapping
O check the file system: At this time, the system will check some possible directories, such as/fsckoptions and/forcfsck and/fastboot, when your system shuts down abnormally (such as sudden power outages), Linux will automatically force you to check the root file system (checking root filesystems ). Simply think about it, it seems like in windows, when you do not shut down normally, scanning the hard disk will happen during the boot process!
O peripheral settings and system settings parameters (/proc): in Linux or Unix systems, you will find a very strange magnetic zone in the root directory, that is/proc! In fact, this directory is recorded in the memory and will be built every time it is started. Its main function is to record the latest information about some peripheral devices on the host! For example, network perimeter, input and output perimeter, etc. The contents in this directory are fun! However, vbird is not very familiar! If it's okay, don't hack it! There will be problems
O set parameters for Plug and Play (PNP;
O clear/etc/mtab;
Omount root and/proc file system: Well, after setting up some materials, you must write down the materials! At this time, the root and/proc files will be mounted to him on the file system!
O determines whether to use modules and load modules
O check the file system: the same as the previous one. After the current/fastboot check flag is enabled, it will use fsck to check your other magnetic areas! (Use fsck)
O Mount other file systems
O set console font
O open quota
O clear unnecessary files, such as lock and PID
O set clock
Oserial port Initialization
O put the boot message in/var/log/dmesg through dmesg
  
In this way, the basic system settings have been written in/etc/rc. d/rc. sysinit, and the system information has been set completely! If you want to know what happened during the boot process? Then you can know how to use dmesg!
  
4. Start

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.