因為分割作業的關係,我們是先裝 Linux 再裝 Windows。代價是整顆硬碟的 MBR 被 Windows 的開機管理程式占走,Linux 的 GRUB 就此消失。所以裝好 Windows 之後,接下來要做的兩件事就是:救援 MBR,以及編輯開機選單。
流程並不難。放入原版光碟重新開機,進入安裝程式的初始畫面後選擇「Troubleshooting」,再選「Rescue a CentOS system」,等待幾秒鐘的開機過程,系統會詢問要如何掛載找到的 Linux 系統,這裡請選「Continue」。

圖 3.3.4:建議採用 Continue(可讀寫)模式掛載既有系統。
若確實找到了原本的 Linux 作業系統,畫面會告訴你它被掛在 /mnt/sysimage。

圖 3.3.5:找到 CentOS 後即可進行救援任務。
接著把 GRUB 重新寫回 MBR:
sh-4.2# chroot /mnt/sysimage sh-4.2# grub2-install /dev/vda Installing for i386-pc platform. Installation finished. No error reported. sh-4.2# exit sh-4.2# reboot
此時開機選單裡只有 Linux,得自己把 Windows 加回去。以正常流程登入 Linux、切換為 root 後:
[root@study ~]# vim /etc/grub.d/40_custom
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.
menuentry "Windows 7" {
set root='(hd0,3)'
chainloader +1
}
[root@study ~]# vim /etc/default/grub
GRUB_TIMEOUT=30
[root@study ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
注意 exec tail -n +3 $0 那一行不要更動,自行定義的項目加在註解之後即可;set root 要指向 Windows 所在的分割。重新產生設定檔後重開機測試。

圖 3.3.6:多重開機的開機選單示意。
多重開機設定完成後,有兩件事務必注意:
/boot/,一旦把 Linux 移除,開機選單整個消失,連 Windows 也進不去了。