剛剛在win7上裝完centos後,重啓電腦直接進入linux系統。需要在centos中重新配置win7啓動引導。有兩種方法,推薦使用方法二。
方法一
1、使用root用戶登錄,執行
vim /boot/grub2/grub.cfg
grub2從1計數,win7裝在C盤上的可以在終端裏輸入 fdisk -l來確定下,一般win都是裝在C的吧
2、找到 ### BEGIN /etc/grub.d/30_os-prober ### 在後面添加
menuentry “Windows 7” {
insmod ntfs
set root=(hd0,1)
chainloader +1
}
3、保存文檔後重啓電腦。
4、但是這個文件是不推薦直接手動改的,因爲系統更新會執行grub更新操作,這個文件就會被刷新,添加的內容就沒了。
方法二
1、使用root用戶登錄,執行
vim /etc/grub.d/40_custom
2、寫入以下內容
#!/bin/sh
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 ‘Windows7’{
set root=(hd0,1)
chainloader +1
}
3、再刷進boot下的文件,重啓即可:
grub2-mkconfig -o /boot/grub2/grub.cfg
* 調整默認啓動系統*
設置完win7引導後,每次需要手動選擇window7啓動,需要修改grub默認啓動設置。
1、使用下面命令查看 /boot/grub2/grub.cfg中的啓動項有幾個啓動項
grep ^menuentry /boot/grub2/grub.cfg | cut -d “’” -f2
列出三個啓動項,第三個是win7。grub2將啓動項從0開始編號,win7就是2
2、接下來,修改grub的配置文件,將默認啓動設置爲2
sudo vi /etc/default/grub
修改GURB_DEFAULT=2
3、使配置生效,重啓計算機
grub2-mkconfig -o /boot/grub2/grub.cfg
4、查看當前啓動項
grub2-editenv list
5、也可以使用下面命令修改
grub2-set-default ‘Windows7’