1. 程式人生 > >centos7下修改windows預設啟動順序

centos7下修改windows預設啟動順序

#!/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
}
~
~
~
~
~
~
~
"/etc/grub.d/40_custom" 9L,272C

按Esc,在按ZZ(或者Shift+:並輸入wq),儲存編輯並退出。
2、執行:
grub2mkconfigo/boot/grub2/grub.cfggrub.cfg3: reboot
重啟既可以看到為windows10的引導了。

二、修改引導順序:
1. sudo vim /etc/default/grub
註釋掉GRUB_DEFAULT=saved,在這一行的下面插入GRUB_DEFAULT=’Windows 7’,儲存並退出。然後執行
下面的命令
2. sudo grub2-mkconfig –output=/boot/grub2/grub.cfg 上面這句命令不能省,因為此命令是重新生成/boot/grub2/grub.cfg,否則就算改了/etc/default/grub,也不會生效。

方法二(沒態看明白,隨便測試了一下,沒有收到效果)

一、修復引導win10:
1.使用root身份(必須)開啟 /boot/grub2/grub.cfg
2.找到 ### BEGIN /etc/grub.d/30_os-prober ###
在後面新增

menuentry 'Windows 7' {
insmod ntfs
set root=(hd0,2)
chainloader +1
}

說明:set root=(hd0,1) 其中 hd0 表示硬碟,1表示C盤 ,我的win10裝在C盤,它是sda1
3.儲存重啟

二、修改引導順序:
# grub2-set-default ‘Windows 7’ 驗證預設啟動項:
# grub2-editenv list
輸出: