Grub编译与调试

470 阅读1分钟

Grub编译与调试

[toc]

1. Grub编译

git clone https://github.com/loongarch64/grub.git
cd grub
./bootstrap
./configure --with-platform=efi --target=loongarch64 --prefix=$(pwd) --disable-werror

2. Grub文件生成

2.1 grub.efi

./grub-mkimage -p . -c /boot/mxd.cfg -d ./grub-core/ -O loongarch64-efi -o /boot/mxd.efi $(ls grub-core/ | grep -E "\.mod$" | cut -d "." -f 1 | uniq)

各参数可在help信息中查看.

2.2 grub.cfg

./grub-mkconfig -o /boot/mxd.cfg

除了生成grub.cfg外, 系统下还有一些用于参考的grub默认配置选项, 如: /etc/default/grub, /etc/grub.d等. 倘若修改这些文件, 还需要更新/boot/grub/grub.cfg, 有命令可以做到:

update-grub

2.3 将grub安装至UEFI引导界面

grub-install --boot-directory=/boot --efi-directory=/boot/efi --bootload-id=mxd /dev/sda

--boot-directory指定在/boot作为根目录, 下寻找grub.cfg和模块.

--efi-directory指定在/boot/efi下寻找grub