多重開機核心在於「誰佔據 MBR/EFI」與「如何移交控制權」。兩大引導鏈:
NTLDR (XP/2003) / BOOTMGR (Vista+) → BCD (儲存啟動項) → 載入 winload.exeGRUB2 (core.img + /boot/grub2/grub.cfg) → 載入 vmlinuz + initramfs兩者可互相鏈式載入:GRUB2 chainloader +1 呼叫 Windows BCD;Windows bootsect/bcdedit 可新增 GRUB2 項目。
# EasyBCD 圖形化:Add New Entry → Linux/BSD → Type: GRUB2 → Name: Ubuntu → Partition: 自動/手動選擇
# 或命令列 (需 Administrator):
bcdedit /create /d "Ubuntu 22.04" /application bootsector
bcdedit /set {GUID} device partition=C:
bcdedit /set {GUID} path \grub\grubx64.efi # UEFI
bcdedit /set {GUID} path \grub\core.img # BIOS MBR (需先將 core.img 複製到 C:\grub\)
bcdedit /displayorder {GUID} /addlast
/boot/efi),GRUB2 會自動偵測 /EFI/Microsoft/Boot/bootmgfw.efi 並新增菜單項ubuntu (或 debian, fedora)/dev/sda1 (NTFS, 啟動旗標 *)grub-install /dev/sda)grub-mkconfig -o /boot/grub/grub.cfg 自動偵測 Windows (需 os-prober 套件)/etc/grub.d/40_custom:
menuentry "Windows 10" --class windows --class os {
insmod part_msdos
insmod ntfs
set root='hd0,msdos1'
chainloader +1
}
| 參數 | 說明 | 範例 |
|---|---|---|
GRUB_DEFAULT | 預設啟動項 (編號、名稱、saved) | saved (搭配 GRUB_SAVEDEFAULT=true 記住上次選擇) |
GRUB_TIMEOUT | 菜單等待秒數 | 5 |
GRUB_CMDLINE_LINUX | 核心啟動參數 | rhgb quiet / nomodeset |
GRUB_DISABLE_OS_PROBER | 停用自動偵測其他 OS | false (預設啟用) |
修改後必須執行 grub2-mkconfig -o /boot/grub2/grub.cfg (或 update-grub) 重新生成。
# Linux Live 環境下 (掛載根分區至 /mnt,EFI 分區至 /mnt/boot/efi)
# BIOS/MBR
grub2-install --root-directory=/mnt /dev/sda
# UEFI
grub2-install --root-directory=/mnt --efi-directory=/mnt/boot/efi --bootloader-id=ubuntu /dev/sda
# Windows 修復 MBR (Windows 安裝媒體 → 修復電腦 → 命令提示字元)
bootrec /fixmbr
bootrec /fixboot
bootrec /rebuildbcd
grldr 為 GRUB Legacy 核心映像,menu.lst 內建菜單boot.ini 新增 C:\grldr="Linux" 鏈載雙系統引導配置的核心原則:先裝 Windows,再裝 Linux;UEFI 共用 ESP;GRUB2 為主引導器;善用 os-prober 自動偵測。避免使用舊版 Grub4DOS、EasyBCD 等變通方案,原生 GRUB2 + UEFI 才是最穩定、最易維護、最符合標準的路徑。定期備份 /boot/efi/EFI/ubuntu/grubx64.efi 與 /boot/grub2/grub.cfg,配合 timeshift/snapper 快照,讓雙系統維護無憂。