您的位置:首页 > 运维架构 > Linux

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

2015-10-11 20:23 639 查看
我们可以直接修改grub的配置文件 /boot/grub2/grub.cfg 。但是看到里面有警告:不要编辑这个文件,他是通过grub2-mkconfig 使用配置文件模版和设置自动生成的。




so、修改这个文件虽然可以达到效果,但是在系统执行grub2-mkconfig之后你修改的配置就会失效。

所以,我们要去修改模版文件,然后执行 grub2-mkconfig 自动重建grub2引导。

$ sudo vi /etc/grub.d/40_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 'Windows7'{
set root=(hd0,1)
chainloader +1
}

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

注意,grub2中第一块磁盘的第一个分区是(hd0,1),而不是(hd0,0),这一点跟grub有稍许不同,还有不要自作聪明的改sda什么的。。。

转载:http://www.ruesin.com/system/centos/centos7-grub2-193.html

更详细请参考 http://blog.sina.com.cn/s/blog_5a6dca940102vsxr.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: