grub2 设置Windows为默认启动系统

1. 首先找到Windows的菜单menuentry.
<blockquote># cat /boot/grub2/grub.cfg | grep Windows

结果: menuentry 'Windows 7 (loader) (on /dev/sda1)' --class windows --class os {</blockquote>
2. 设置Windows 作为默认的启动项(这儿只能使用上面命令输出中双引号 " " 或 者单引号 '' 中的内容)。
<blockquote># grub2-set-default 'Windows 7 (loader) (on /dev/sda1)'
这里最好是复制上面输出的内容,连同单引号一起复制,不然可能不成功哦~~</blockquote>
(3). 验证默认启动项
<blockquote># grub2-editenv list
输出:saved_entry=Windows 7 (loader) (on /dev/sda1)</blockquote>
4.写入配置文件中
<blockquote>grub2-mkconfig -o /boot/grub2/grub.cfg</blockquote>
&nbsp;
<blockquote>[sbso@localhost ~]$ cat /boot/grub2/grub.cfg | grep Windows
menuentry 'Windows 7 (loader) (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-9278835A78833C4B' {

[sbso@localhost ~]$ sudo grub2-set-default "Windows 7 (loader) (on /dev/sda1)"
[sbso@localhost ~]$ grub2-editenv list
saved_entry=Windows 7 (loader) (on /dev/sda1)
[sbso@localhost ~]$
[sbso@localhost ~]$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.1.6-201.fc22.x86_64
Found initrd image: /boot/initramfs-4.1.6-201.fc22.x86_64.img
Found linux image: /boot/vmlinuz-4.0.4-301.fc22.x86_64
Found initrd image: /boot/initramfs-4.0.4-301.fc22.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-75741f182de6460990f27c895f165f1f
Found initrd image: /boot/initramfs-0-rescue-75741f182de6460990f27c895f165f1f.img
Found Windows 7 (loader) on /dev/sda1
done
[sbso@localhost ~]$</blockquote>
&nbsp;

PS: 如果不成功,可以手动修改 /etc/default/grub 文件,将里面的DEFAULT=0 OR DEFAULT=saved;改为DEFAULT=3 我的windows是3,就可以。

posted on 2015-11-21 19:39  liweilijie  阅读(2176)  评论(0编辑  收藏  举报

导航