Linux interview question: How does Linux start?

Source: Internet
Author: User

Linux interview question: How does Linux start?

During the written examination, I took a test on the Linux system startup process. I did not answer the question at the time. Now I have sorted it out (which is not complicated ).

After you press the power button until the welcome page is displayed, you can perform a total of five steps in Linux.

1. BIOS power-on self-check:

Power-on self-check to detect hardware devices. Then, search for the devices that can be guided in the active state in the order above the cmos. It can be an optical drive, a floppy disk, or a USB disk.

2. Load the Master Boot Loader (MBR ):

The Main Boot Program is a 512-byte image. Contains a machine code and a small partition.

The task of the primary boot program is to find and load the secondary boot program on the hard disk partition. Search for active partitions in the Partition Table and read the boot loader in the active partition to the memory for running.

3. Load the next boot recorder (GRUB)

The next Boot Loader only loads the Linux kernel.

After the last stage, the boot loader will run in the memory. The GRUB graphic interface appears, allowing users to choose the kernel to load.

4. Linux kernel image:

After you select the kernel to be loaded, the next boot Loader (GRUB) will be based on/boot/grub. the information set in the conf configuration file reads the Linux kernel image from the/boot/partition, loads the kernel image to the memory, and gives control to the Linux kernel.

After the Linux kernel obtains control, it starts to do its own work.

1. Hardware Detection

2. Decompress yourself and install necessary drivers

3. initialize Virtual Devices related to the file system, LVM or RAID

4. Load the root file system and mount it under the root directory.

5. After the process is completed, linux loads the init program in the process space, and the next task is init.

5. init process

Init is the initiator and controller of all processes, and all processes are derived from this.

After the init process obtains control, it will execute/etc/rc. d/rc. the sysinit script sets the environment variables, network, starts swap, checks and mounts the file system, and executes other initialization tasks according to the code.

So far, linux has been started.

Let's make a summary:

First, BIOS power-on self-check, then load the Main Boot Loader, the next boot loader, and finally the Linux kernel image. After that, the control is handed over to the init process to complete initialization.

What is a swap partition?

Similar to the virtual memory in Windows, the memory in swap is used when the physical memory is insufficient.

Describes the Linux Startup Process and the configuration files and scripts used for Linux Startup.

Detailed analysis of Linux Startup Process

Red Hat Linux Startup Process details

Linux Startup Process details

This article permanently updates the link address:

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.