製作 GRUB4DOS/GRUB2 引導的 USB 開機隨身碟 (PE/維護盤/多系統安裝盤) 時,啟動選單出現亂碼、方塊字、問號,嚴重影響可讀性與操作。核心成因通常是 **選單設定檔編碼與 GRUB 運行環境編碼不匹配**。本文提供從編碼轉換、選單寫法、參數調整到進階除錯的完整解決方案。
timeout 10 default 0 gfxmenu (bd)/BOOT/MESSAGE || find --set-root /BOOT/MESSAGE && gfxmenu (bd)/BOOT/MESSAGE title [01] WinPE 2003 (Legacy) map --mem (bd)/BOOT/WINPE.ISO (0xff) || find --set-root /BOOT/WINPE.ISO && map --mem (bd)/BOOT/WINPE.ISO (0xff) map --hook chainloader (0xff) title [02] WinPE 10 x64 (UEFI/Legacy) chainloader /BOOT/BOOTX64.EFI title [03] DiskGenius DOS Edition kernel /BOOT/DOS/MEMDISK raw initrd /BOOT/DOS/DISKGEN.IMG title [04] MemTest86+ v6.10 kernel /BOOT/MEMTEST86/MEMTEST.ELF title [05] Shutdown halt title [06] Reboot reboot
**優點:** 完全避開編碼問題,任何 GRUB4DOS 版本皆完美顯示。**缺點:** 失去中文直觀性。
# /EFI/BOOT/grub.cfg 或 /BOOT/GRUB/grub.cfg
insmod all_video
insmod font
insmod png
insmod gfxterm
insmod gfxmenu
# 載入 Unicode 字體 (必須隨 GRUB2 提供或自行編譯 unicode.pf2)
if loadfont /BOOT/GRUB/fonts/unicode.pf2 ; then
set gfxmode=auto
insmod efi_gop
insmod efi_uga
insmod gfxterm
terminal_output gfxterm
fi
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
set timeout=10
set default=0
menuentry "WinPE 10 x64" {
chainloader /EFI/BOOT/BOOTX64.EFI
}
menuentry "Ubuntu 22.04 Live" {
set isofile="/ISO/ubuntu-22.04-desktop-amd64.iso"
loopback loop $isofile
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet splash ---
initrd (loop)/casper/initrd
}
menuentry "System Shutdown" {
halt
}
menuentry "System Reboot" {
reboot
}
確保 `grub.cfg` 以 **UTF-8 無 BOM** 儲存,`unicode.pf2` 放在 `/BOOT/GRUB/fonts/` 或 `/EFI/BOOT/fonts/`。
原文提到的 `configfile (md)4+3` 限制內建選單最大 4KB (3 sectors × 512 bytes = 1.5KB? 實際 GRUB4DOS 內建選單緩衝區為 4KB,對應 8 sectors)。選單項目超過時會截斷顯示不全。
修正: 改為 `configfile (md)4+8` (8 sectors = 4KB),支援更多選單項目。若選單極大,建議改用圖形選單或外部配置檔 `configfile /BOOT/GRUB/CUSTOM.CFG`。
GRUB 選單亂碼本質是**編碼與字體支援不匹配**。GRUB4DOS 採「英文選單 + 圖形選單」雙保險最穩健;GRUB2 載入 `unicode.pf2` + UTF-8 設定檔即原生支援中文。現代製作開機盤,**首選 Ventoy**,徹底消除手寫 GRUB 設定檔的編碼、路徑、相容性諸多坑點。