1、CentOS 7 修改开机顺序在笔记本电脑安装了 win8 与 centOS 7。按照以往的惯例,安装完 centOS 时,会在bootgrubgrub.conf 里自动加入安装系统前其它系统的引导控制,但是实际上是没有的。此文不探讨如何将先系统引导加入 centOS 7 的/boot/grub2/grub.cfg 当中。先查看我电脑上 grub.cfg 当中的内容如下(注意加粗内容):rootlocalhost grub2# cat grub.cfg # DO NOT EDIT THIS FILE# It is automatically generated by grub2-mkconfi
2、g using templates# from /etc/grub.d and settings from /etc/default/grub# BEGIN /etc/grub.d/00_header #set pager=1if -s $prefix/grubenv ; thenload_envfiif “$next_entry“ ; thenset default=“$next_entry“set next_entry=save_env next_entryset boot_once=trueelseset default=“$saved_entry“fiif x“$feature_men
3、uentry_id“ = xy ; thenmenuentry_id_option=“-id“elsemenuentry_id_option=“fiexport menuentry_id_optionif “$prev_saved_entry“ ; thenset saved_entry=“$prev_saved_entry“save_env saved_entryset prev_saved_entry=save_env prev_saved_entryset boot_once=truefifunction savedefault if -z “$boot_once“ ; thensave
4、d_entry=“$chosen“save_env saved_entryfifunction load_video if x$feature_all_video_module = xy ; theninsmod all_videoelseinsmod efi_gopinsmod efi_ugainsmod ieee1275_fbinsmod vbeinsmod vgainsmod video_bochsinsmod video_cirrusfiterminal_output consoleif x$feature_timeout_style = xy ; thenset timeout_st
5、yle=menuset timeout=5# Fallback normal timeout code in case the timeout_style feature is# unavailable.elseset timeout=5fi# END /etc/grub.d/00_header # Begin with windows 8#menuentry CentOS Linux (3.10.0-123.13.2.el7.x86_64) 7 (Core) -class centos -class gnu-linux -class gnu -class os -unrestricted $
6、menuentry_id_option gnulinux-3.10.0-123.el7.x86_64-advanced-337b5933-c8eb-4c4e-8e7d-3a1f7aaa1e73 load_videoset gfxpayload=keepinsmod gzioinsmod part_msdosinsmod xfsset root=hd0,msdos2if x$feature_platform_search_hint = xy ; thensearch -no-floppy -fs-uuid -set=root -hint-bios=hd0,msdos2 -hint-efi=hd0
7、,msdos2 -hint-baremetal=ahci0,msdos2 -hint=hd0,msdos2 337b5933-c8eb-4c4e-8e7d-3a1f7aaa1e73elsesearch -no-floppy -fs-uuid -set=root 337b5933-c8eb-4c4e-8e7d-3a1f7aaa1e73filinux16 /boot/vmlinuz-3.10.0-123.13.2.el7.x86_64 root=UUID=337b5933-c8eb-4c4e-8e7d-3a1f7aaa1e73 ro vconsole.keymap=us vconsole.font
8、=latarcyrheb-sun16 rhgb quiet LANG=zh_CN.UTF-8initrd16 /boot/initramfs-3.10.0-123.13.2.el7.x86_64.imgmenuentry Windows 8(loader)(on /dev/sda1) -class windows -class or $menuentry_id_option osprober-chain-140E68540E6830C2insmod part_msdosinsmod ntfsset root=hd0,msdos1chainloader +1# BEGIN /etc/grub.d
9、/10_linux #menuentry CentOS Linux, with Linux 3.10.0-123.el7.x86_64 -class centos -class gnu-linux -class gnu -class os -unrestricted $menuentry_id_option gnulinux-3.10.0-123.el7.x86_64-advanced-337b5933-c8eb-4c4e-8e7d-3a1f7aaa1e73 load_videoset gfxpayload=keepinsmod gzioinsmod part_msdosinsmod xfss
10、et root=hd0,msdos2if x$feature_platform_search_hint = xy ; thensearch -no-floppy -fs-uuid -set=root -hint-bios=hd0,msdos2 -hint-efi=hd0,msdos2 -hint-baremetal=ahci0,msdos2 -hint=hd0,msdos2 337b5933-c8eb-4c4e-8e7d-3a1f7aaa1e73elsesearch -no-floppy -fs-uuid -set=root 337b5933-c8eb-4c4e-8e7d-3a1f7aaa1e
11、73filinux16 /boot/vmlinuz-3.10.0-123.el7.x86_64 root=UUID=337b5933-c8eb-4c4e-8e7d-3a1f7aaa1e73 ro vconsole.keymap=us vconsole.font=latarcyrheb-sun16 rhgb quiet LANG=zh_CN.UTF-8initrd16 /boot/initramfs-3.10.0-123.el7.x86_64.imgmenuentry CentOS Linux, with Linux 0-rescue-96f17ff7113c494a98433dd3c1be39
12、74 -class centos -class gnu-linux -class gnu -class os -unrestricted $menuentry_id_option gnulinux-0-rescue-96f17ff7113c494a98433dd3c1be3974-advanced-337b5933-c8eb-4c4e-8e7d-3a1f7aaa1e73 load_videoinsmod gzioinsmod part_msdosinsmod xfsset root=hd0,msdos2if x$feature_platform_search_hint = xy ; thens
13、earch -no-floppy -fs-uuid -set=root -hint-bios=hd0,msdos2 -hint-efi=hd0,msdos2 -hint-baremetal=ahci0,msdos2 -hint=hd0,msdos2 337b5933-c8eb-4c4e-8e7d-3a1f7aaa1e73elsesearch -no-floppy -fs-uuid -set=root 337b5933-c8eb-4c4e-8e7d-3a1f7aaa1e73filinux16 /boot/vmlinuz-0-rescue-96f17ff7113c494a98433dd3c1be3
14、974 root=UUID=337b5933-c8eb-4c4e-8e7d-3a1f7aaa1e73 ro vconsole.keymap=us vconsole.font=latarcyrheb-sun16 rhgb quietinitrd16 /boot/initramfs-0-rescue-96f17ff7113c494a98433dd3c1be3974.imgif “x$default“ = CentOS Linux, with Linux 3.10.0-123.el7.x86_64 ; then default=Advanced options for CentOS LinuxCen
15、tOS Linux, with Linux 3.10.0-123.el7.x86_64; fi;# END /etc/grub.d/10_linux # BEGIN /etc/grub.d/20_linux_xen # END /etc/grub.d/20_linux_xen # BEGIN /etc/grub.d/20_ppc_terminfo # END /etc/grub.d/20_ppc_terminfo # BEGIN /etc/grub.d/30_os-prober # END /etc/grub.d/30_os-prober # BEGIN /etc/grub.d/40_cust
16、om # 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.# END /etc/grub.d/40_custom # BEGIN /etc/grub.d/41_custom #if -f $config_directory/custom.cfg ; thensource $config_dire
17、ctory/custom.cfgelif -z “$config_directory“ -a -f $prefix/custom.cfg ; thensource $prefix/custom.cfg;fi细心查看上面的引导脚本,发现还有一个文件,就是 grub2 文件夹里面的文件grubenv。发现,开机引导那个系统是以这个文件里面的参数来确定的。再查看这个文件里面的内容是什么。rootlocalhost grub2# cat grubenv # GRUB Environment Blocksaved_entry=CentOS Linux (3.10.0-123.13.2.el7.x86_64) 7 (Core)#于是按照 grub.cfg 里面的内容来修改 grubenv 的内容,先注释原来的内容,再加上自己需要引导的标题,内容如下:rootlocalhost grub2# cat grubenv # GRUB Environment Block#saved_entry=CentOS Linux (3.10.0-123.13.2.el7.x86_64) 7 (Core)#saved_entry=Windows 8(loader)(on /dev/sda1)再保存一下文件。这样就可以自己的需要来改变开机引导顺序了。