Linux system startup related knowledge

  

The PC starts the Linux system from the hard disk in two phases:

1. The BIOS performs a self-test on the hardware and finds the bootstrap in the MBR. [This step has the BIOS program that is solidified in the motherboard.]

2. After the control is given to the bootstrap, the length of the MBR in the hard disk is fixed to 512 bytes. The MBR itself is divided into two parts: the first 446 bytes is the bootstrap program, and the rest is the partition table. The purpose of the Bootstrap program is to find the boot parameters, get the kernel image on the disk, load it into memory, and pass in the boot parameters, and finally pass the control of the CPU to the kernel.

Two common BootLoaders: LILO, GRUB

Two files used in startup: vmlinux and initrd

Vmlinux

Wikipedia's explanation
>

On Linux systems, vmlinux is a statically linked executable file that contains the Linux kernel in one of the object file formats supported by Linux, which includes ELF, COFF and a.out. The vmlinux file might be required for kernel debugging , symbol table generation or other operations, but must be made bootable before being used as an operating system kernel by adding a multiboot header, bootsector and setup routines.

Vmlinux is a compiled executable file in the format Linux supports, such as: ELF, COFF, a.out, usually used for kernel debugging, symbol table generation. If you want to put it in the kernel as an executable file, you need to add the relevant part of the boot to be a bootable file.

Initrd:

Like other Unix systems, the Linux operating system first boots the kernel into memory. The kernel resides throughout the entire lifecycle of the operating system and applications, where the application (software) runs within "userspace" and is under kernel control.

In order to minimize the load memory, some core Linux programs are converted into modules and can be dynamically loaded into the system.

The files in the initrd system can be accessed by the kernel during the boot process. The contents of the file are mounted as a loop file. In the early days, the initrd was placed in a small floppy disk. The initrd is usually compressed into a gzip type, and the bootloader (LILO, GRUB) tells the location of the core initrd at boot time.

The difference between Vmlinux and image

Vmlinux is a file in elf format, image is a file that vmlinux only retains the data segment and text segment after objcopy operation, usually will be image Stored after compression, such as zimage.Uimage is based on zimage plus the head of 0x40 that uboot can provide, and used with uboot.



Copyright © Windows knowledge All Rights Reserved