Grub2的設定與以前有後大的分別,現在主要設定檔是自動生成的
grub.cfg是自動生成,所以直接編輯的話更新後就會失效
想要手動加入Windows開機選項的話,可以修改/etc/grub.d/40_custom
首先我們要知道目標Windows 7所在分區
$sudo blkid用blkid查看目標所在分區的UUID,大概會出現一個ntfs格式的分區
/dev/sda2: UUID="10AC99D8AC99B8A4" TYPE="ntfs"
之後在40_custom裹加入:
#!/bin/sh第一句menuentry意思是加入一個Windows的項目在開機選單裹
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Windows" {
insmod chain
insmod ntfs
search --fs-uuid --set 10ac99d8ac99b8a4
chainloader +1
}
然後insmod意思是啟用chain模塊和ntfs模塊,目的是使用chainloader命令和讀取ntfs格式的分區
(不過chain好像沒有也可以)
search就是用uuid去尋找目標分區,用uuid會比舊格式方便
原因是加入新硬碟後或者硬碟順序改變了,依然可以啟動而無修改
最後chainloader +1就會啟動Windows
完成編輯以後還要更新設定檔才能使修改生效
執行sudo update-grub便完成
重新開機看看效果吧~
另外附上修復Windows 7開機的小方法:
用Windows 7安裝光碟開機,打開一個cmd
BootRec /ScanOS使用BootRec命令來修復開機
BootRec /RebuildBcd
bcdedit
BootRec /FixBoot
BootRec /FixMbr
Via: http://grub.enbug.org/ChainLoadWindows


