修改Fedora 25與Windows 10的默認啟動順序


首先貼出Fedora25下/boot/grub2/grub.cfg的內容:

  1 #
  2 # DO NOT EDIT THIS FILE
  3 #
  4 # It is automatically generated by grub2-mkconfig using templates
  5 # from /etc/grub.d and settings from /etc/default/grub
  6 #
  7 
  8 ### BEGIN /etc/grub.d/00_header ###
  9 set pager=1
 10 
 11 if [ -s $prefix/grubenv ]; then
 12   load_env
 13 fi
 14 if [ "${next_entry}" ] ; then
 15    set default="${next_entry}"
 16    set next_entry=
 17    save_env next_entry
 18    set boot_once=true
 19 else
 20    set default="${saved_entry}"
 21 fi
 22 
 23 if [ x"${feature_menuentry_id}" = xy ]; then
 24   menuentry_id_option="--id"
 25 else
 26   menuentry_id_option=""
 27 fi
 28 
 29 export menuentry_id_option
 30 
 31 if [ "${prev_saved_entry}" ]; then
 32   set saved_entry="${prev_saved_entry}"
 33   save_env saved_entry
 34   set prev_saved_entry=
 35   save_env prev_saved_entry
 36   set boot_once=true
 37 fi
 38 
 39 function savedefault {
 40   if [ -z "${boot_once}" ]; then
 41     saved_entry="${chosen}"
 42     save_env saved_entry
 43   fi
 44 }
 45 
 46 function load_video {
 47   if [ x$feature_all_video_module = xy ]; then
 48     insmod all_video
 49   else
 50     insmod efi_gop
 51     insmod efi_uga
 52     insmod ieee1275_fb
 53     insmod vbe
 54     insmod vga
 55     insmod video_bochs
 56     insmod video_cirrus
 57   fi
 58 }
 59 
 60 terminal_output console
 61 if [ x$feature_timeout_style = xy ] ; then
 62   set timeout_style=menu
 63   set timeout=5
 64 # Fallback normal timeout code in case the timeout_style feature is
 65 # unavailable.
 66 else
 67   set timeout=5
 68 fi
 69 ### END /etc/grub.d/00_header ###
 70 
 71 ### BEGIN /etc/grub.d/01_users ###
 72 if [ -f ${prefix}/user.cfg ]; then
 73   source ${prefix}/user.cfg
 74   if [ -n "${GRUB2_PASSWORD}" ]; then
 75     set superusers="root"
 76     export superusers
 77     password_pbkdf2 root ${GRUB2_PASSWORD}
 78   fi
 79 fi
 80 ### END /etc/grub.d/01_users ###
 81 
 82 ### BEGIN /etc/grub.d/10_linux ###
 83 menuentry 'Fedora (4.8.8-300.fc25.x86_64) 25 (Twenty Five)' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-4.8.6-300.fc25.x86_64-advanced-3732e5b3-67be-4efa-a64e-08e51d341084' {
 84     load_video
 85     set gfxpayload=keep
 86     insmod gzio
 87     insmod part_msdos
 88     insmod ext2
 89     set root='hd0,msdos6'
 90     if [ x$feature_platform_search_hint = xy ]; then
 91       search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  3732e5b3-67be-4efa-a64e-08e51d341084
 92     else
 93       search --no-floppy --fs-uuid --set=root 3732e5b3-67be-4efa-a64e-08e51d341084
 94     fi
 95     linux16 /boot/vmlinuz-4.8.8-300.fc25.x86_64 root=UUID=3732e5b3-67be-4efa-a64e-08e51d341084 ro rhgb quiet LANG=zh_CN.UTF-8
 96     initrd16 /boot/initramfs-4.8.8-300.fc25.x86_64.img
 97 }
 98 menuentry 'Fedora (4.8.6-300.fc25.x86_64) 25 (Twenty Five)' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-4.8.6-300.fc25.x86_64-advanced-3732e5b3-67be-4efa-a64e-08e51d341084' {
 99     load_video
100     set gfxpayload=keep
101     insmod gzio
102     insmod part_msdos
103     insmod ext2
104     set root='hd0,msdos6'
105     if [ x$feature_platform_search_hint = xy ]; then
106       search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  3732e5b3-67be-4efa-a64e-08e51d341084
107     else
108       search --no-floppy --fs-uuid --set=root 3732e5b3-67be-4efa-a64e-08e51d341084
109     fi
110     linux16 /boot/vmlinuz-4.8.6-300.fc25.x86_64 root=UUID=3732e5b3-67be-4efa-a64e-08e51d341084 ro rhgb quiet LANG=zh_CN.UTF-8
111     initrd16 /boot/initramfs-4.8.6-300.fc25.x86_64.img
112 }
113 menuentry 'Fedora (0-rescue-0c394733687b44ac9de7038631d76a55) 25 (Twenty Five)' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-0c394733687b44ac9de7038631d76a55-advanced-3732e5b3-67be-4efa-a64e-08e51d341084' {
114     load_video
115     insmod gzio
116     insmod part_msdos
117     insmod ext2
118     set root='hd0,msdos6'
119     if [ x$feature_platform_search_hint = xy ]; then
120       search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos6 --hint-efi=hd0,msdos6 --hint-baremetal=ahci0,msdos6 --hint='hd0,msdos6'  3732e5b3-67be-4efa-a64e-08e51d341084
121     else
122       search --no-floppy --fs-uuid --set=root 3732e5b3-67be-4efa-a64e-08e51d341084
123     fi
124     linux16 /boot/vmlinuz-0-rescue-0c394733687b44ac9de7038631d76a55 root=UUID=3732e5b3-67be-4efa-a64e-08e51d341084 ro rhgb quiet
125     initrd16 /boot/initramfs-0-rescue-0c394733687b44ac9de7038631d76a55.img
126 }
127 
128 ### END /etc/grub.d/10_linux ###
129 
130 ### BEGIN /etc/grub.d/20_linux_xen ###
131 
132 ### END /etc/grub.d/20_linux_xen ###
133 
134 ### BEGIN /etc/grub.d/20_ppc_terminfo ###
135 ### END /etc/grub.d/20_ppc_terminfo ###
136 
137 ### BEGIN /etc/grub.d/30_os-prober ###
138 menuentry 'Windows 10 Enterprise (loader) (on /dev/sdb1)' --class windows --class os $menuentry_id_option 'osprober-chain-10FF15F410FF15F4' {
139     insmod part_msdos
140     insmod ntfs
141     set root='hd1,msdos1'
142     if [ x$feature_platform_search_hint = xy ]; then
143       search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1  10FF15F410FF15F4
144     else
145       search --no-floppy --fs-uuid --set=root 10FF15F410FF15F4
146     fi
147     parttool ${root} hidden-
148     drivemap -s (hd0) ${root}
149     chainloader +1
150 }
151 
152 ### BEGIN /etc/grub.d/40_custom ###
153 # This file provides an easy way to add custom menu entries.  Simply type the
154 # menu entries you want to add after this comment.  Be careful not to change
155 # the 'exec tail' line above.
156 ### END /etc/grub.d/40_custom ###
157 
158 ### BEGIN /etc/grub.d/41_custom ###
159 if [ -f  ${config_directory}/custom.cfg ]; then
160   source ${config_directory}/custom.cfg
161 elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
162   source $prefix/custom.cfg;
163 fi
164 ### END /etc/grub.d/41_custom ### 

顯然,其中沒有找到傳說中的

1 # boot=/dev/sda
2 default=0
3 timeout=5

所以無法通過修改grub.cfg來調整系統的默認啟動順序。不過無意中,發現可以用三條命令解決這個問題,具體代碼如下:

1 # 首先找到windows的menuentry
2 cat /boot/grub2/grub.cfg | grep windows   
3 # 然后設置windows作為默認的啟動項
4 grub2-set-default "Windows *** " 
5 # 用第一步得到的結果執行第2步
6 # 驗證默認的啟動項
7 grub2-editenv list

修改前后使用第三條命令的結果也同樣貼出:

1 saved_entry=Fedora (4.8.8-300.fc25.x86_64) 25 (Twenty Five)
2 saved_entry=Windows 10 Enterprise (loader) (on /dev/sdb1)

這樣就可以在Fedora25中修改了grub啟動配置文件,下一次電腦啟動時Win10將會出現在第一條,即默認啟動系統。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM