分享

永久修改grub2启动顺序

 simplelam 2014-04-30

grub2是通过/etc/grub.d/目录下的文件顺序来决定启动项顺序的:

  1. $cd /etc/grub.d  
  2. $ls -l  
  3.   
  4. -rwxr-xr-x 1 root root 6743  9月 13  2012 00_header  
  5. -rwxr-xr-x 1 root root 5522  4月 18  2012 05_debian_theme  
  6. -rw-r--r-- 1 root root 7603  4月 18  2012 08_os-prober  
  7. -rwxr-xr-x 1 root root 7780  1月 23  2013 10_linux  
  8. -rwxr-xr-x 1 root root 7603  9月 20 13:48 17_os-prober  
  9. -rwxr-xr-x 1 root root 6335  4月 18  2012 20_linux_xen  
  10. -rwxr-xr-x 1 root root 1588 11月 27  2011 20_memtest86+  
  11. -rwxr-xr-x 1 root root 1388  1月 23  2013 30_uefi-firmware  
  12. -rwxr-xr-x 1 root root  214  4月 18  2012 40_custom  
  13. -rwxr-xr-x 1 root root   95  4月 18  2012 41_custom  
  14. -rw-r--r-- 1 root root  483  4月 18  2012 README  

08_os-prober是我之前为了默认启动项为win8而改的,因为现在又改成ubuntu为默认启动了,所以将08_os-prober的权限修改为不可执行的。该目录下有个readme

翻译如下:

该目录下的可以执行文件的顺序是按照shell扩展来排列的(就是按首字符排列的意思,用来配置grub的顺序)。

00_开头的文件是预留给00_header的


10_开头的用于系统本身


20_开头的用于第三方程序

可以新建和改变文件的顺序来配置gurb2的启动顺序。

知道以上这些就好办了。我们只要把08_os-prober的顺序设置到10_linux之后就可以让windows的选项在linux之后了。

运行以下命令把08_os-prober复制一份并且重命名为17_os-prober:


  1. $sudo cp 08_os-prober 17_os-prober  
  1. $sudo chmod 644 08_os-prober   //去掉08_os-prober的可执行权限  
  2. $ls -l  
  3.   
  4.   
  5. -rwxr-xr-x 1 root root 6743  9月 13  2012 00_header  
  6. -rwxr-xr-x 1 root root 5522  4月 18  2012 05_debian_theme  
  7. -rw-r--r-- 1 root root 7603  4月 18  2012 08_os-prober  
  8. -rwxr-xr-x 1 root root 7780  1月 23  2013 10_linux  
  9. -rwxr-xr-x 1 root root 7603  9月 20 13:48 17_os-prober  
  10. -rwxr-xr-x 1 root root 6335  4月 18  2012 20_linux_xen  
  11. -rwxr-xr-x 1 root root 1588 11月 27  2011 20_memtest86+  
  12. -rwxr-xr-x 1 root root 1388  1月 23  2013 30_uefi-firmware  
  13. -rwxr-xr-x 1 root root  214  4月 18  2012 40_custom  
  14. -rwxr-xr-x 1 root root   95  4月 18  2012 41_custom  
  15. -rw-r--r-- 1 root root  483  4月 18  2012 README  


然后打开/etc/default/grub文件把默认启动项改成你要得那个:

  1. $sudo vim /etc/default/grub  

找到GRUB_DEFAULT=,改成9.(因为linux是从0开始计数的)


然后更新grub即可:sudo update-grub

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多