安裝 Grub2 到U盤
Windows下運行:
grub-install --boot-directory=E: --recheck --target=i386-pc \\.\PHYSICALDRIVE1 --removable
grub-install --boot-directory=E: --efi-directory=E: --recheck --target=i386-efi --removable
grub-install --boot-directory=E: --efi-directory=E: --recheck --target=x86_64-efi --removable
其中E改為你的盤符(一定要是FAT32 因為EFI分區只支持FAT32或FAT16)
其中\\.\PHYSICALDRIVE1改為命令
wmic diskdrive list brief
輸出的您的U盤對應編號
用Qemu或VMWare測試啟動成功
在 /boot/grub2 下創建文件 grub.cfg,參考 這個 配置
我的grub.cfg如下:
#加載字體需要的模塊
insmod font; #insmod 加載一個模塊
insmod gfxterm;
insmod jpeg;
insmod png;
insmod all_video;
# insmod vbe;
#-----加載中文界面---------
#加載字體
loadfont unicode;
set gfxmode=auto;
set gfxpayload=keep;
set gfxterm_font=unicode;
terminal_output gfxterm;
#設置語言
set locale_dir=$prefix/locale;
set lang=zh_CN;
#設置主題文件路徑
#注:$prefix 為 grub 所在目錄(即 X:/grub/)
#poly-light 修改為你下載的主題的文件夾名字
set theme=$prefix/themes/monterey-grub-theme/theme.txt;
background_image $prefix/themes/monterey-grub-theme/background.png
# background_image $prefix/themes/msi.jpg
#---------菜單項-----------
menuentry "[1]正常啟動(Windows)" --hotkey=1 { #--hotkey=某個按鍵 :設置快捷鍵
if [ 'pc' == $grub_platform ] ; then
if search --file --set /bootmgr ; then
chainloader +1
elif search --file --set /ntldr ; then
chainloader +1
fi
elif [ 'efi' == $grub_platform ] ; then
if search --file --set /EFI/Microsoft/Boot/bootmgfw.efi ; then
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
fi
fi
}
menuentry "[2]微PE" --hotkey=2 {
if [ 'pc' == $grub_platform ] ; then
insmod memdisk
linux16 $prefix/memdisk iso raw
initrd16 /iso/wepe.iso
elif [ 'efi' == $grub_platform ] ; then
chainloader /iso/wepe_efi/bootmgfw.efi
fi
}
menuentry "[3]GrubFM" --hotkey=3 {
if [ "${grub_platform}" = "pc" ]; then
linux /iso/grubfm/loadfm
initrd /iso/grubfm/grubfm.iso
else
if ["$grub_cpu" = "x86_64"]; then
chainloader /iso/grubfm/grubfm.efi
else
chainloader /iso/grubfm/grubfmia32.efi
fi
fi
}
menuentry "[4]Edgeless PE" --hotkey=4 {
if [ 'pc' == $grub_platform ] ; then
echo "Dosen't support Legacy"
elif [ 'efi' == $grub_platform ] ; then
chainloader /iso/Edgeless/bootmgfw.efi
fi
}
menuentry "重啟" { reboot; }
menuentry "關機" { halt; }
修改PE(只支持EFI)
附件中下載pe_efi.zip,解壓放到一個文件夾中,再把PE的wim文件解壓到該文件夾中,用BOOTICE修改BCD文件,添加菜單
menuentry "PE"{
if [ 'efi' == $grub_platform ] ; then
chainloader $pe_path/bootmgfw.efi
fi
}
若要Legacy下啟動,用grub2fm
附件 密碼:4jk0
