5 DERECHA
Concept of Kernel Loading (GRUB) 본문
1. Real Mode
When a computer boots up, the CPU starts executing code from a specific memory location called the reset vector. This location is typically set to the beginning of the system's BIOS firmware, which is responsible for initializing hardware devices and providing basic system services.
During the boot process, the CPU starts in a mode called real mode. In this mode, the processor is limited to accessing a maximum of 1 megabyte of memory directly. The CPU uses 20-bit memory addressing, which can access up to 2^20 (or 1,048,576) individual memory locations.
The real mode was the original mode of operation for the Intel x86 processors, which were first introduced in 1978. It was designed to be backward-compatible with the 16-bit processors of the time and to support the early operating systems and applications that were developed for those systems.
Real mode is not used in modern operating systems such as Windows, macOS, or Linux. However, it is still used by some specialized applications, such as bootloaders, firmware, and some low-level system utilities.
When transitioning from real mode to protected mode, the operating system gains access to additional memory and processor features, such as virtual memory, paging, and multitasking. This allows for more advanced operating system features and improved performance.
2. GRUB
GRUB (GRand Unified Bootloader) is a popular boot loader used in many Linux-based operating systems. It is responsible for loading the operating system kernel into memory and starting the boot process.
Here are some of the main functions of GRUB:
* Detecting Operating Systems: GRUB can detect the available operating systems installed on a system and display them in a menu. This allows users to choose which operating system they want to boot into, in case there are multiple operating systems installed on the same machine.
* Loading the Kernel: Once a user selects an operating system to boot into, GRUB is responsible for loading the kernel into memory. The kernel is the core of the operating system that manages hardware resources and provides system services.
* Passing Parameters to the Kernel: GRUB can pass parameters to the kernel when it is loaded, such as the root file system, initial RAM disk, and other configuration settings. This allows the kernel to be customized for different system configurations.
* Supporting Multiboot: GRUB supports the Multiboot specification, which allows for booting of multiple operating systems from a single boot loader. This is useful for systems with multiple operating systems installed, or for booting from removable media such as USB drives.
* Providing a Command Line Interface: GRUB provides a command line interface that allows users to manually configure the boot process or modify the kernel parameters.
* Supporting Encryption: GRUB can support encryption for the boot process, which adds an additional layer of security to the system. This is particularly important for systems that handle sensitive data or are exposed to security threats.
=> GRUB plays a critical role in the boot process of many Linux-based operating systems. Its ability to detect operating systems, load kernels, and pass parameters to the kernel make it a powerful tool for managing the boot process of a system.
3.The boot process through GRUB
1) BIOS Initialization: When a computer is powered on or restarted, the Basic Input/Output System (BIOS) initializes the hardware components of the system. This includes checking the hardware configuration and performing a Power On Self Test (POST) to ensure that all hardware is functioning properly.
2) Boot Loader Location: Once the BIOS initialization is complete, the system looks for a boot loader on the boot device specified in the BIOS boot order. If GRUB is installed on the system, it will be located on the boot device.
3) GRUB Stage 1: The first stage of GRUB is loaded into memory by the BIOS. This stage is responsible for locating the second stage of GRUB, which contains the main functionality of the boot loader.
4) GRUB Stage 1.5: If GRUB is installed on a disk that uses a disk partitioning scheme, such as MBR or GPT, GRUB stage 1.5 is loaded. This stage is used to load GRUB stage 2 from a partition on the disk.
5) GRUB Stage 2: The main functionality of GRUB is located in stage 2. This stage provides the user with a menu of available operating systems to boot, as well as options for modifying kernel parameters and boot settings.
6) Kernel Loading: Once an operating system is selected from the GRUB menu, GRUB loads the kernel into memory. The kernel is the core of the operating system and is responsible for managing hardware resources and providing system services.
7) Initial RAM Disk: In some cases, an initial RAM disk (initrd) is loaded along with the kernel. This contains temporary file systems and device drivers that are necessary for booting the system.
8) Operating System Initialization: Once the kernel and initrd are loaded, the operating system begins initializing hardware devices and loading system services. This includes mounting the root file system, starting system daemons, and loading system libraries and utilities.
9) Login Screen: Finally, the login screen is displayed, allowing the user to log in and begin using the operating system.
That's a high-evel overview of the boot process through GRUB. Depending on the specific system configuration, there may be additional steps involved in the boot process.