What is the bootloader of a microcomputer?

bootloader

When the computer system is started, BIOS and UEFI initialize the system (ready to use state), and start the "boot loader". The OS starts from the boot loader. In other words, this is the "trigger to start".

When multiple OSs are installed on the HDD or SSD (these auxiliary storage media), the OS is specified from the boot loader and started. In the case of using the traditional MBR (MasterBootRecord) environment, the boot sector is loaded from the MBR, the subsystem is loaded, and the OS (Linux kernel) is finally loaded.

In the case of UEFI, UEFI itself forms a system, detects the partition of the FAT system through its own strength, and then loads GPT and reads the OS.

Unified Extensible Firmware Interface (UEFI) is a specification that defines the software interface between an operating system (OS) and platform firmware.

If it is a recent GRUB, there is no problem even if it operates under the UEFI environment. However, if there is any situation, the old boot loader must be used. For example, when LILO must be used, if UEFI is made to operate in the traditional mode, it will reproduce the same operation as the previous combination of BIOS and MBR.

bootloader installation

After the boot loader is installed once, almost no other boot loader is installed. In addition, if the setting is wrong, the OS will not start, etc., which can cause fatal accidents for beginners. In most cases, the installer will set up the boot loader appropriately at the initial stage.

In the case of replacing the boot loader, in order to increase understanding, as long as it is "aware of accidents" or "can manage the experimental machine" on the real machine, it is fine. If this is not the case, please use the virtual machine to experiment first.

In fact, if you know "GRUB2", you will rarely encounter trouble in the future, even if you only know "GRUB Legacy" and "LILO", there is no problem.

GRUB2

The boot loader "GRUB2" under contemporary Linux has become a standard.

Contemporary GRUB2 and the old GRUB before it are usually distinguished as "GRUB Legacy". It can be said that there is something in common with GRUB Legacy, because it comes with a shell, so even if you set the wrong settings, you can start the operating system from the GRUB shell.

However, modern GRUB2 has a more complicated structure than "GRUB Legacy". The configuration file is also automatically generated using commands. For CentOS 7, GRUB2 is installed by default.

If you want to reinstall the boot loader in the startup state, etc. If you use GRUB2 in combination with MBR

# grub2-install /dev/sda

GRUB2 is installed in the MBR of "/dev/sda"

Or on UEFI machines

# yum reinstall grub2-efi shim

In this way, it can be safely reinstalled.

GRUB Legacy

The configuration file is "/boot/grub/menu.lst" in the case of Debian, etc., and "/boot/grub/grub.conf" in the case of RedHat, etc.

The setting example is as follows

timeout=5
 
title Linux
 
root (hd0,0)
 
kernel /vmlinuz root=/dev/sda1
 
initrd /initrd.img
 
root (hd0,0) インストールされているディスクを指定
 
kernel /vmlinuz root=/dev/sda1 カーネルとパラメータを指定
 
initrd /initrd.img

LILO

When the LILO command is executed, LILO writes the MBR, and since the advanced shell is not used at startup, when the setting is wrong, a state such as "unable to start" will occur. The location of the configuration file is "/etc/lilo.conf"

The setting example is as follows

prompt
 
timeout=50
 
default=linux
 
boot=/dev/sda
 
map=/boot/map
 
install=menu
 
image=/boot/vmlinuz
 
  label=linux
 
  initrd=/boot/initrd.img
 
  read-only
 
  root=/dev/sda1

Boot=/dev/sda: Specify the actual installed HDD, etc.
Image=/boot/vmlinuz: The information setting where the kernel exists on the hard disk now.
Label=linux: The name displayed in the menu.
Initrd=/boot/initrd.img: Specify when there is an initial disk.
Root=/dev/sda1: is the root partition.
In terms of setting items, if you know so much, there will be almost no problem. After editing the settings, execute the following command

# lilo

In addition, there is a high possibility that lilo will not start if the settings are not complete. Therefore, please pay attention to the message when the lilo command is running.

Concluding remarks

A brief introduction to "Boot Loader" and "Boot Loader Installation Method". I hope people who are interested in Linux will help.

Guess you like

Origin blog.csdn.net/qq_18191333/article/details/107531331