UEFI adds grub2 boot

Prepare materials:

Download grub-2.02-for-windows.zip

first step:

Unzip grub-2.02-for-windows.zip to the root directory of drive d. Run cmd as an administrator.

Enter the following command to switch the current path to the grub-2.02-for-windows folder.

cd /d d:\grub-2.02-for-windows

The second step:

Enter the following command to view the parameters of grub-mkimage.exe

grub-mkimage.exe --help

Output the following results:

d:\grub-2.02-for-windows>grub-mkimage.exe --help
Usage: grub-mkimage.exe [OPTION...] [OPTION]... [MODULES]
Make a bootable image of GRUB.
 
  -c, --config=FILE          embed FILE as an early config(此文件存储一些设置变量)
  -C, --compression=(xz|none|auto)
                             choose the compression to use for core image(选择内核的压缩模式)
  -d, --directory=DIR        use images and modules under DIR
                             [default=d:\grub-2.02-for-windows/<platform>](指定模块的路径,i386-efi,x86_64.efi,i386-pc等文件夹)
  -k, --pubkey=FILE          embed FILE as public key for signature checking(嵌入一个文件作为签名检查的公共密钥)
  -m, --memdisk=FILE         embed FILE as a memdisk image(嵌入文件作为一个内存镜像)。Implies `-p (memdisk)/boot/grub' and overrides
                             any prefix supplied previously, but the prefix itself can be overridden by later options(当加载内存镜像时,应用/boot/grub作为优先查找路径,并覆盖所有的以前提供的预配置文件,但是预配置文件可以被后边的选项重写)
  -n, --note                 add NOTE segment for CHRP IEEE1275(为CHRP IEEE1275添加备注)
  -o, --output=FILE          output a generated image to FILE [default=stdout](设置输出文件的名称)
  -O, --format=FORMAT        generate an image in FORMAT
                             available formats: i386-coreboot, i386-multiboot,
                             i386-pc, i386-pc-pxe, i386-pc-eltorito, i386-efi,
                             i386-ieee1275, i386-qemu, x86_64-efi, i386-xen,
                             x86_64-xen, mipsel-yeeloong-flash,
                             mipsel-fuloong2f-flash, mipsel-loongson-elf,
                             powerpc-ieee1275, sparc64-ieee1275-raw,
                             sparc64-ieee1275-cdcore, sparc64-ieee1275-aout,
                             ia64-efi, mips-arc, mipsel-arc,
                             mipsel-qemu_mips-elf, mips-qemu_mips-flash,
                             mipsel-qemu_mips-flash, mips-qemu_mips-elf,
                             arm-uboot, arm-efi, arm64-efi(设置输出文件的格式)
  -p, --prefix=DIR           set prefix directory(设置预先查找配置文件的路径)
  -v, --verbose              print verbose messages.
  -?, --help                 give this help list
      --usage                give a short usage message
  -V, --version              print program version
 
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
 
Report bugs to <[email protected]>.

third step:

Create a new configuration file in the current directory of grub-2.02-for-windows, corresponding to grub-mkimage.exe -c, --config=file.

The 32-bit configuration file is named i386-efi.cfg, the text content:

search.file /EFI/grub/ia32.cfg root (The name of the search configuration file is ia32.cfg, and the path is under the /EFI/grub path)
set prefix=( root) / EFI / grub (Set / EFI / grub as the prefix Directory) configfile (root)/EFI/grub (Set /EFI/grub as the prefix directory) configfile (R & lt O O T ) / E F. the I / G R & lt U B ( provided set / E F. the I / G R & lt U B to P R & lt E F I X mesh catalog ) C O n- F I G F I L E ( the root) / EFI/grub/ia32.cfg (Set the path and name of the configuration file)

The 64-bit configuration file is named x86_64-eif.cfg, the text content:

search.file /EFI/grub/x64.cfg root  
set prefix=($root)/EFI/grub  
configfile ($root)/EFI/grub/x64.cfg  

Later, i386-efi.cfg and x86_64-eif.cfg will be used instead of the file name.

the fourth step:

For 32-bit, run the following command:

grub-mkimage.exe -d i386-efi -c i386-efi.cfg -p /EFI/grub -o bootia32.efi -O i386-efi part_gpt part_msdos disk fat exfat ext2 ntfs xfs appleldr hfs iso9660 normal search_fs_file configfile linux linux16 chain loopback echo efi_gop efi_uga video_bochs video_cirrus file gfxmenu gfxterm gfxterm_background gfxterm_menu halt reboot help jpeg ls png true

grub-mkimage.exe

-d i386-efi (specify path)

-c i386-efi.cfg (specify configuration file)

-p /EFI/grub (Specify the pre-configuration file path)

-o grubia32.efi (name of the generated file)

-O i386-efi part_gpt part_msdos disk fat exfat ext2 ntfs xfs appleldr hfs iso9660 normal search_fs_file configfile linux linux16 chain loopback echo efi_gop efi_uga video_bochs video_cirrus file gfxmenu gfxterm gfxterm_background gfxterm_menu halt reboot help jpeg ls png true(集成的模块)

For 64-bit, run the following command:

grub-mkimage.exe -d x86_64-efi -c x86_64-efi.cfg -p /EFI/grub -o bootx64.efi -O x86_64-efi part_gpt part_msdos disk fat exfat ext2 ntfs xfs appleldr hfs iso9660 normal search_fs_file configfile linux linux16 chain loopback echo efi_gop efi_uga video_bochs video_cirrus file gfxmenu gfxterm gfxterm_background gfxterm_menu halt reboot help jpeg ls png true

grub-mkimage.exe

-d x86_64-efi

-c x86_64-efi.cfg

-p /EFI/grub

-o bootx64.efi

-O x86_64-efi part_gpt part_msdos disk fat exfat ext2 ntfs xfs appleldr hfs iso9660 normal search_fs_file configfile linux linux16 chain loopback echo efi_gop efi_uga video_bochs video_cirrus file gfxmenu gfxterm gfxterm_background gfxterm_menu halt reboot help jpeg ls png true

After running, the following files will be generated in the current directory:

32nd place: grubia32.efi

64-bit: grubx64.efi

the fifth step:

Copy the bootmgr.efi file from the windows native system image to the root directory of the disk where /EFI is located, and copy the generated bootia32.efi and bootx64.efi to the /EFI/boot folder, and copy other folders to /EFI/ In the grub folder.

For 32-bit, you need to create a new ia32.cfg configuration file, which is the same as the name defined in the i386-efi.cfg file during the generation process:

i386-efi

locale

themes

fonts

For 64-bit, you need to create a new x64.cfg configuration file, which is the same as the name defined in the x86_64-efi.cfg file during the generation process:

i386-efi

locale

themes

fonts

Among them, the locale, themes and fonts folders can be shared between 32-bit and 64-bit.

File structure diagram:

bootmgr.efi
/EFI
├───boot
│       bootia32.efi
│       bootx64.efi
│
└───grub
    │   ia32.cfg
    │   x64.cfg
    │
    ├───i386-efi
    │       acpi.mod
    │		........  
    │
    ├───fonts
    │       unicode.pf2
    │
    ├───locale
    │   ├───ast
    │   ├───...... 	
    │   └───zh_TW
    │           grub.mo
    │
    ├───themes
    │   └───starfield
    │           blob_w.png
    │           boot_menu_c.png
    │ 			.........	
    │           theme.txt
    │
    └───x86_64-efi
            acpi.mod

The sixth step:

UEFI file calling sequence:

1. After booting, first search for FAT, FAT16, FAT32 partitions, read bootmgr.eft in the root directory of the partition, and transfer the control authority to bootia32.efi or bootx64.efi in the /EFI/boot directory.

2. The paths of the configuration files ia32.cfg and x64.cfg have been compiled in the bootia32.efi and bootx64.efi files, and ia32.cfg and x64.cfg will be called under the path of the /EFI/grub folder.

3. You can edit the content in the ia32.cfg and x64.cfg files, define menus, load modules, set styles, and set themes.

4. If the theme style has been set through set theme=$prefix/themes/starfield/theme.txt, theme.txt will be called and the theme will be output.

Guess you like

Origin blog.csdn.net/seaship/article/details/111401398