Linux 概念:grub2

GRUB 2是许多发行版的缺省efi模式引导加载程序。

grub2 与 grub 的区别

官方手册:https://www.gnu.org/software/grub/manual/grub/html_node/Changes-from-GRUB-Legacy.html#Changes-from-GRUB-Legacy

几个主要的区别:
1.配置文件的名称改变了。在grub中,配置文件为grub.conf或menu.lst(grub.conf的一个软链接),在grub2中改名为grub.cfg。
2.grub2增添了许多语法,更接近于脚本语言了,例如支持变量、条件判断、循环。
3.grub2使用img文件,不再使用grub中的stage1、stage1.5和stage2。

grub2 引导操作系统的方式

官方手册:https://www.gnu.org/software/grub/manual/grub/html_node/General-boot-methods.html#General-boot-methods

直接引导:(direct-load)直接通过默认的grub2 boot loader来引导写在默认配置文件中的操作系统
链式引导:(chain-load)使用默认grub2 boot loader链式引导另一个boot loader,该boot loader将引导对应的操作系统

rpm -qa | grep grub2

grub2-tools-2.02-73.oe1.aarch64
grub2-efi-aa64-2.02-73.oe1.aarch64
grub2-common-2.02-73.oe1.noarch

rpm -qc grub2-tools-2.02-73.oe1.aarch64

/etc/default/grub
/etc/grub.d/00_header
/etc/grub.d/01_menu_auto_hide
/etc/grub.d/01_users
/etc/grub.d/10_linux
/etc/grub.d/20_linux_xen
/etc/grub.d/20_ppc_terminfo
/etc/grub.d/30_os-prober
/etc/grub.d/30_uefi-firmware
/etc/grub.d/40_custom
/etc/grub.d/41_custom

rpm -ql grub2-efi-aa64-2.02-73.oe1.aarch64

/boot/efi/EFI/openEuler/fonts
/boot/efi/EFI/openEuler/grub.cfg
/boot/efi/EFI/openEuler/grubaa64.efi
/boot/efi/EFI/openEuler/grubenv
/boot/grub2/grubenv
/boot/loader/entries
/etc/grub2-efi.cfg

grubaa64.efi 这个是操作系统的引导文件

tree /boot/efi/EFI/

/boot/efi/EFI/
├── BOOT
│   ├── BOOTAA64.EFI
│   ├── fbaa64.efi
│   └── mmaa64.efi
└── openEuler
├── BOOTAA64.CSV
├── fbaa64.efi
├── fonts
├── grub.cfg
├── grubaa64.efi
├── grubenv
├── mmaa64.efi
├── shimaa64.efi
└── shimaa64.hash

EFI system partition(ESP)

EFI系统分区(也称为ESP)是一个操作系统独立分区,作为EFI引导加载程序、应用程序和驱动程序的存储空间,由UEFI固件启动。UEFI引导时必须配置。

fdisk -l /dev/sdb

Disk /dev/sdb: 447.13 GiB, 480103981056 bytes, 937703088 sectors
Disk model: SAMSUNG MZ7LH480
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 4FA243ED-88DE-4AFA-A008-E327FAB227D5

Device Start End Sectors Size Type
/dev/sdb1 2048 411647 409600 200M EFI System
/dev/sdb2 411648 2508799 2097152 1G Linux filesystem
/dev/sdb3 2508800 937701375 935192576 446G Linux LVM

The disk's partition table: it indicates Disklabel type: gpt if the partition table is GPT or Disklabel type: dos if it is MBR.
The list of partitions on the disk: Look for the EFI system partition in the list, it is usually at least 100 MiB in size and has the type EFI System or EFI (FAT-12/16/32). To confirm this is the ESP, mount it and check whether it contains a directory named EFI, if it does this is definitely the ESP.

efibootmgr 管理 UEFI 启动项

BootCurrent: 0003
Timeout: 10 seconds
BootOrder: 0003,0002,0004,0006,0008,000A,000C,000E,0010,0001,0000
Boot0000* BootManagerMenuApp
Boot0001* ByoUiApp
Boot0002* UEFI PXEv4 (MAC:5CE88331C870)
Boot0003* openEuler
Boot0004* UEFI PXEv4 (MAC:5CE88331C871)
Boot0006* UEFI PXEv4 (MAC:5CE88331C872)
Boot0008* UEFI PXEv4 (MAC:5CE88331C873)
Boot000A* UEFI PXEv4 (MAC:5CE88331C874)
Boot000C* UEFI PXEv4 (MAC:5CE88331C875)
Boot000E* UEFI PXEv4 (MAC:5CE88331C876)
Boot0010* UEFI PXEv4 (MAC:5CE88331C877)

posted @ 2022-01-25 11:59  武平宁  阅读(1140)  评论(0)    收藏  举报