Windows 7系统上安装CentOS 7后通过修改grub2添加Windows 7启动引导项

按照以往的经验,先安装Windows 7之后,再装CentOS 7,那么CentOS 7应该会自动添加Windows 7启动项。但是安装完成后,发现启动项里没有Windows 7

我们需要手动添加Windows 7的启动项。

我们需要修改grub2的模版文件,然后执行grub2-mkconfig自动重建grub2引导列表。

$ sudo cp /etc/grub.d/40_custom /etc/grub.d/41_win7_custom

$ sudo vi /etc/grub.d/41_win7_custom

#!/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 'Windows 7'{
set root=(hd0,1)
chainloader +1
}

$ grub2-mkconfig -o /boot/grub2/grub.cfg
$ reboot

至于set root=(hd0,1),还是set root=(hd0,msdos1),或者set root=(hd0,msdosX),请在启动列表中按下e键,进入grub rescue模式,执行ls命令列出分区,如果第一个启动不了,请逐个分区都试试。

参考链接


Centos7 + Windows7 双系统,通过修改grub2,重新添加 Win7 启动引导项