免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3011 | 回复: 2
打印 上一主题 下一主题

[Ubuntu-9.10] 修改 grub 以更改默认启动系统 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-01-29 11:58 |只看该作者 |倒序浏览

                                                网上的说法主要有两种,分别是修改两个文件:
/boot/grub/grub.conf   or  /boot/grub/menu.lst
也有说是 /etc 目录下的相应文件的,但是在 Ubuntu-9.10 下面,具体文件是这样地:
/boot/grub/grub.cfg
至于更改的那个 set default=”x“, 那个x的意思,就拿我机器作为例子来说:
[eg].> ls -l grub.cfg-r--r--r--    grub.cfg
> sudo chmod 244 grub.cfg> ls -l grub.cfg--w-r--r--    grub.cfg
> sudo vim grub.cfg
修改之后,最后别忘了:> sudo chmod 444 grub.cfg    // 一定记得要改回来.
我晕,用过一段时间后竟然有这么多东西,那么就用彩色来突出一下重点吧,其他内容请自动跳过。如蓝色部分所示,grub里面一共分为这么几个部分,一般三个。再如红色部分所示,也就是 menuentry 项,所以 menuentry 项按顺序从 0 开始排列,如果想让哪个被默认启动,就将 set default=“x” 中的 x 改为那个 entry 的编号。eg,如果我的电脑想默认进 windows (虽然这是没门的事),就另 x 为 8. 体现为启动时到选择启动系统时光标默认定位在 windows 系统入口上。
至于将 windows 系统不仅设置为默认启动, 而且要放在所有系统入口最顶端,还没试过。只是根据这个文件猜测:是不是将这个文件的 windows 的那个 menuentry 剪切到最前面就行? 使其 entry 编号为 0... 这个猜测暂不确定。
-------------------------------------- grub.cfg, start ---------------------------------#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
if [ -s /boot/grub/grubenv ]; then
  have_grubenv=true
  load_env
fi
[color="#FF0102"]set default="0"
if [ ${prev_saved_entry} ]; then
  saved_entry=${prev_saved_entry}
  save_env saved_entry
  prev_saved_entry=
  save_env prev_saved_entry
fi
insmod ext2
set root=(hd0,8)
search --no-floppy --fs-uuid --set ab1eac76-a5d7-4656-8918-ffb406010912
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=640x480
  insmod gfxterm
  insmod vbe  if terminal_output gfxterm ; then true ; else    # For backward compatibility with versions of terminal.mod that don't    # understand terminal_output    terminal gfxterm  fifiif [ ${recordfail} = 1 ]; then  set timeout=-1else  set timeout=10fi### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/05_debian_theme ###set menu_color_normal=white/blackset menu_color_highlight=black/white### END /etc/grub.d/05_debian_theme ###
[color="#0001FF"]### BEGIN /etc/grub.d/10_linux ###[color="#FF0102"]menuentry "Ubuntu, Linux 2.6.31-18-generic" {  // 0        recordfail=1        if [ -n ${have_grubenv} ]; then save_env recordfail; fi    set quiet=1    insmod ext2    set root=(hd0,8)    search --no-floppy --fs-uuid --set ab1eac76-a5d7-4656-8918-ffb406010912    linux   /boot/vmlinuz-2.6.31-18-generic root=UUID=ab1eac76-a5d7-4656-8918-ffb406010912 ro   quiet splash    initrd  /boot/initrd.img-2.6.31-18-generic}[color="#FF0102"]menuentry "Ubuntu, Linux 2.6.31-18-generic (recovery mode)" { // 1        recordfail=1        if [ -n ${have_grubenv} ]; then save_env recordfail; fi    insmod ext2    set root=(hd0,8)    search --no-floppy --fs-uuid --set ab1eac76-a5d7-4656-8918-ffb406010912    linux   /boot/vmlinuz-2.6.31-18-generic root=UUID=ab1eac76-a5d7-4656-8918-ffb406010912 ro single     initrd  /boot/initrd.img-2.6.31-18-generic}[color="#FF0102"]menuentry "Ubuntu, Linux 2.6.31-17-generic" {  // 2        recordfail=1        if [ -n ${have_grubenv} ]; then save_env recordfail; fi    set quiet=1    insmod ext2    set root=(hd0,8)    search --no-floppy --fs-uuid --set ab1eac76-a5d7-4656-8918-ffb406010912    linux   /boot/vmlinuz-2.6.31-17-generic root=UUID=ab1eac76-a5d7-4656-8918-ffb406010912 ro   quiet splash    initrd  /boot/initrd.img-2.6.31-17-generic}[color="#FF0102"]menuentry "Ubuntu, Linux 2.6.31-17-generic (recovery mode)" {  // 3        recordfail=1        if [ -n ${have_grubenv} ]; then save_env recordfail; fi    insmod ext2    set root=(hd0,8)    search --no-floppy --fs-uuid --set ab1eac76-a5d7-4656-8918-ffb406010912    linux   /boot/vmlinuz-2.6.31-17-generic root=UUID=ab1eac76-a5d7-4656-8918-ffb406010912 ro single     initrd  /boot/initrd.img-2.6.31-17-generic}[color="#FF0102"]menuentry "Ubuntu, Linux 2.6.31-14-generic" {  // 4        recordfail=1        if [ -n ${have_grubenv} ]; then save_env recordfail; fi    set quiet=1    insmod ext2    set root=(hd0,8)    search --no-floppy --fs-uuid --set ab1eac76-a5d7-4656-8918-ffb406010912    linux   /boot/vmlinuz-2.6.31-14-generic root=UUID=ab1eac76-a5d7-4656-8918-ffb406010912 ro   quiet splash splash    initrd  /boot/initrd.img-2.6.31-14-generic}[color="#FF0102"]menuentry "Ubuntu, Linux 2.6.31-14-generic (recovery mode)" {  // 5        recordfail=1        if [ -n ${have_grubenv} ]; then save_env recordfail; fi    insmod ext2    set root=(hd0,8)    search --no-floppy --fs-uuid --set ab1eac76-a5d7-4656-8918-ffb406010912    linux   /boot/vmlinuz-2.6.31-14-generic root=UUID=ab1eac76-a5d7-4656-8918-ffb406010912 ro single     initrd  /boot/initrd.img-2.6.31-14-generic}[color="#0001FF"]### END /etc/grub.d/10_linux ###
[color="#0001FF"]### BEGIN /etc/grub.d/20_memtest86+ ###[color="#FF0102"]menuentry "Memory test (memtest86+)" {  // 6    linux16 /boot/memtest86+.bin}[color="#FF0102"]menuentry "Memory test (memtest86+, serial console 115200)" {  // 7    linux16 /boot/memtest86+.bin console=ttyS0,115200n8}[color="#0001FF"]### END /etc/grub.d/20_memtest86+ ###[color="#0001FF"]### BEGIN /etc/grub.d/30_os-prober ###[color="#FF0102"]menuentry "Microsoft Windows XP Professional (on /dev/sda1)" {  // 8    insmod ntfs    set root=(hd0,1)    search --no-floppy --fs-uuid --set 6044685444682f4a    drivemap -s (hd0) ${root}    chainloader +1}### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/40_custom #### 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 ###
--------------------------------- grub.cfg, end ---------------------------------------------
    shepherdFri,Jan/29/2010.
               
               
               
               
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/111146/showart_2163930.html

论坛徽章:
0
2 [报告]
发表于 2010-02-17 18:43 |只看该作者
这两个文件不用手工改的,是用工具生成的,很好用

论坛徽章:
0
3 [报告]
发表于 2010-04-30 14:36 |只看该作者
9.1以后grub升级为grub2
已经没有了menu.list了。
直接执行grub-update,系统会自动搜索所有安装的内核,然后自动增加启动项。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP