Linux Boot Process Analysis and research __linux

Source: Internet
Author: User
Tags uuid

Pre {font-family: "Times New Roman";} p {margin-bottom:0.08in;}

			Linux Boot Process Analysis and research author: Changuo (Huaiyin Teachers College) for Linux research is in full swing, stems from the interest in the system start-up, start to its START process comprehensive analysis, based on Before playing Linux on the basis of knowing that the Linux boot has grub can choose to start the system, start to start in-depth analysis.
   Don't worry, even if you know nothing about the startup process of your computer, you can look at the following article. When we press the Power-on power button, the system is in the process of starting, I believe that the use of Windows people more or less of their start speed some opinions, but the start of its process is ignorant, which makes people very depressed, oh, no hurry, the following into the text. When all computers are powered on, the BIOS (Basic Input and Output System) will perform a self-test of the computer, such as a memory test, and enumerate and initialize the local device, and then search for the active boot device that is set up in the BIOS and can boot. Typically, a Linux system is booted from a hard disk (or CD,DVD,USB), and the boot sector of the hard disk exists in each partition, but the primary boot sector is only one and is located in the first physical sector. The primary boot sector contains the master boot record (MBR) and hard disk partition table (DPT). The main boot sector of the hard disk contains the boot loader for the master Boot Record (MBR). The BIOS now hands control to the MBR.
   The Windows operating system is the same as Linux in this step. The primary boot sector size is 512B, contains MBR program code, partition table DPT (64KB), and end Flag (AA55). The MBR contains information about grub (or early Lilo). The MBR loads and executes the GRUB (Grand Unified Bootloader) boot loader.
   The following things are controlled by the Grub boot loader. In Windows, the MBR directly boots the Windows operating system, and if you have two versions of Windows, you must first install a lower version, or you can enter only one operating system! Simply put, Windows only recognize their own people, others do not recognize, it shows its overbearing place, So if you want to install dual systems such as Windows and Linux, install Windows First and then install the Linux system. Now go back to grub,grub load and basically do most of the work. The BIOS and MBR are hardware dongdong, I am not familiar with, to grub we can analyze its code, due to space restrictions, here is not to repeat, the source code everyonecan be downloaded to www.sourceforge.org. Grub's job is to display a splash screen, and if you do not enter or select it, it will start the default selected operating system (Ubuntu if you want to modify the startup option can modify the/boot/grub/grub.cfg, use caution ...) , which can also identify the file system, the following ' Ubuntu, with Linux 2.6.32-27-generic ' is the default option displayed by the system startup ### begin/etc/grub.d/10_linux ### menuentry ' Ubuntu , with Linux 2.6.32-27-generic '--class ubuntu--class gnu-linux--class GNU--class os {recordfail Insmo
        D ext2 set root= ' (hd0,10) ' Search--no-floppy--fs-uuid--set
        Linux/boot/vmlinuz-2.6.32-27-generic root=uuid=e36d89d9-ad79-467d-8acf-fadef717c6b7 ro Splash vga=758 quiet Splash Initrd/boot/initrd.img-2.6.32-27-generic}. As I focus on the Linux boot process, below is a set of Linux under a group bootstrap program (Bootsect-loader), in the Linux source tree Arch/i386/boot/bootsect.
S, it is CPU real mode of the assembler, in order to facilitate the analysis of its source code for a brief introduction. setupsects=4//Installation defaults bootseg =0x07c0//boot at the original address initsec =def_initseg//Mobile Bootstrapper setupseg = DEF_SETUPSEG//Starting from here Installation sysseg =DEF_SYSSEG//System load Syssize =def_syssize//system size in IThe macro definition in nclude/asm-i386/boot.h #define DEF_INITSEG 0x9000 #define DEF_SYSSEG 0x1000 #define DEF_SETUPSEG 0x9020 #de

    Fine Def_syssize 0x7f00 The following beginners can skip (excerpt from Linux system Analysis and practice). Bootsect. s generates the Bootsect module at kernel compile time, at the very front of the entire kernel-mirrored file. When the computer starts first into real mode, first executes the program code located at the 0XFFFF0 address, which is actually mapped to the computer ROM BIOS address, which means that the BIOS code is executed first, some tests are performed, and the interrupt vector table is set at the address 0x0000 location. and read the first sector into the memory absolute address 0x7c00 this position. The Bootsect code is in the first sector, so skip to this position to execute. Bootsect moves itself to the 0x90000 and carries the Setup module to the 0x90200 location, and executes the setup module after Bootsect execution. During setup, complete the necessary settings and move the system to the 0x10000 location. But after the head part of system is finished and then the system is moved to the 0x0000 address, the code address in the System module equals the physical address, which makes it easier to operate on the kernel. The reason for not moving the system module directly to the 0x0000 position at the beginning is that when the Setup module is not finished, 0x0000 This position also holds the BIOS information and some interrupt vector tables.
    If you start moving, it will overwrite the content and make an error. Setup. The main function of S is to copy system parameters (including memory, disk, etc., from BIOS return) to 0x90000~0x901ff memory. This position was originally bootsect. where s is stored, then it will be covered by system parameters. Later, these parameters will be read by code in protected mode. In addition, Setup. s also includes code in the VIDEO.S to detect and set the display and display modes. Finally, Setup.
    s converts the system to protection mode and jumps to the 0x100000 kernel boot code, bootloader the control over the system kernel. Kernel is responsible for loading the root file system, executing the programs in/sbin/init, and some drivers. It by head. s begins to perform initial address for 0x100000, mainly completes some initialization work, clears BSS, copy startup parameters, initialize registers, initialize GDT and IDT, and then execute Start_kernel ().
    Init is the core thread of Linux, completing the initialization of peripherals, including SMP (), and calling Do_basic_setup () to complete peripherals and drive addition and initialization. At this point, Linux has been started, although write so much, but its speed is amazing, only less than 30 seconds, haha, fast can reach more than 10 seconds, than Windows much better.

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.