Ubuntu 11.04 / 10.10 双系统启动项管理及配置方法

  一、能上网情况下的最好方法:安装startupmanager——图形启动项管理器

  打开终端输入:sudo apt-get install startupmanager

  安装启动管理器

  系统——系统管理——启动管理器,选中默认开机操作系统即可。

  二、最方便的方法:调整Windows系统的默认启动顺序(不需要修改grub.cfg)

  /etc/grub.d 目录中的脚本文件的文件名都是以数字开头,这确定了在执行update-grub 时各文件内容被执行的顺序。

   1. 用 sudo nautilus 命令,以root权限打开文件浏览器。然后找到30_os-prober这个文件,把 30_os-prober这个文件名的数字30改为05到10之间的数字即可(没多少可选06、07、08、09),比如改为08_os-prober, 这样创建出来的grub.cfg内的菜单项,windows的排序就会自动在ubuntu之前;

  2. 运行 sudo update-grub 命令。就可以看到,windows7 已经排在了第一个的位置上。

  三、网上介绍最多的方法(修改grub.cfg)

  用 sudo gedit /boot/grub/grub.cfg 命令打开grub.cfg 这个文件,

  一种方法是并将文件中的 set default=”0″ 中的 0 改成对应欲默认启动的操作系统的序号(从0开始) 。然后保存;

  另一种方法是把Windows对应的启动说明那一段剪切到启动说明段最前面;

  用这2种方法都能默认启动Windows,但用修改grub.cfg 文件来实现修改默认启动项应注意:当使用update-grub 命令或者系统升级、grub升级等,grub.cfg文件将被复原。需要重新修改。

  如果懒于每次update-grub 之后都要修改grub.cfg 文件,则可以进行如下操作:

   用 sudo gedit /etc/grub.b/00_header 命令打开00_header 这个文件,找到 ser default =”${GRUB_DEFAULT}” 一行,将${GRUB_DEFAULT} 换成欲默认启动的操作系统的序号(从0开始),保存,再update-grub。这样每次update-grub之后生成的grub.cfg将自动改成我 们想要的样子。

四、如果你在硬盘中同时安装了不同的系统,或者由于Ubuntu更新/安装软件而产生了多个启动项,为了免去每次开机都要选择的麻烦,,可以把一些低版本的或是不需要的启动项注释掉,这样开机看起来就没那么乱了。

具体做法:sudo gedit /boot/grub/grub.cfg

然后找到 menuentry …,看准了要去掉的系统启动项,在menuentry这个单词前面加上”#”就然后保存就可以了。注意:至少要留一个,建议保留两个ubuntu的选 项,留下最高版本的两个不同类型的,其次再核对类型是不是各自一个:一个是正常的(没有注明“恢复模式”或:“recovery”),另一个是恢复模式的 (注明“恢复模式”或:“recovery”)。另外含有Window的项是不能加“#”进行注释的,否则你的就会找不到相关的系统入口了。还有内存测试 (menuentry “Memory test …..“),如果希望使用此功能留下一项,个人认为留下选项多的那个入口代表更多功能,但是内存测试的速度也会花更长的时间。

以下贴上本人机器启动项的配置情况,windows是最后一项,装的XP。

—————————————————————————————

## DO NOT EDIT THIS FILE## It is automatically generated by grub-mkconfig using templates# from /etc/grub.d and settings from /etc/default/grub#### BEGIN /etc/grub.d/00_header ###if [ -s $prefix/grubenv ]; then set have_grubenv=true load_envfiset default=”2″if [ “${prev_saved_entry}” ]; then set saved_entry=”${prev_saved_entry}” save_env saved_entry set prev_saved_entry= save_env prev_saved_entry set boot_once=truefifunction savedefault { if [ -z “${boot_once}” ]; then saved_entry=”${chosen}” save_env saved_entry fi}function recordfail { set recordfail=1 if [ -n “${have_grubenv}” ]; then if [ -z “${boot_once}” ]; then save_env recordfail; fi; fi}function load_video { insmod vbe insmod vga}insmod part_msdosinsmod ext2set root='(hd1,msdos8)’search –no-floppy –fs-uuid –set c825786c-e42c-4fed-8cc2-fd2a610a183bif loadfont /usr/share/grub/unicode.pf2 ; thenset gfxmode=1280×1024 load_video insmod gfxtermfiterminal_output gfxterminsmod part_msdosinsmod ext2set root='(hd1,msdos8)’search –no-floppy –fs-uuid –set c825786c-e42c-4fed-8cc2-fd2a610a183bset locale_dir=($root)/boot/grub/localeset lang=zhinsmod gettextif [ “${recordfail}” = 1 ]; then set timeout=-1else set timeout=3fi### END /etc/grub.d/00_header ###### BEGIN /etc/grub.d/05_debian_theme ###set menu_color_normal=white/blackset menu_color_highlight=black/light-gray### END /etc/grub.d/05_debian_theme ###### BEGIN /etc/grub.d/10_linux ####menuentry ‘Ubuntu, with Linux 2.6.35-22-generic’ –class ubuntu –class gnu-linux –class gnu –class os{ recordfail insmod part_msdos insmod ext2 set root='(hd1,msdos8)’ search –no-floppy –fs-uuid –set c825786c-e42c-4fed-8cc2-fd2a610a183b linux /boot/vmlinuz-2.6.35-22-generic root=UUID=c825786c-e42c-4fed-8cc2-fd2a610a183b ro vga=775 quiet splash initrd /boot/initrd.img-2.6.35-22-generic}#menuentry ‘Ubuntu, with Linux 2.6.35-22-generic (recovery mode)’ –class ubuntu –class gnu-linux –class gnu –class os{ recordfail insmod part_msdos insmod ext2 set root='(hd1,msdos8)’ search –no-floppy –fs-uuid –set c825786c-e42c-4fed-8cc2-fd2a610a183b echo ‘Loading Linux 2.6.35-22-generic …’ linux /boot/vmlinuz-2.6.35-22-generic root=UUID=c825786c-e42c-4fed-8cc2-fd2a610a183b ro single vga=775 echo ‘Loading initial ramdisk …’ initrd /boot/initrd.img-2.6.35-22-generic}menuentry ‘Ubuntu, with Linux 2.6.32-25-server’ –class ubuntu –class gnu-linux –class gnu –class os{ recordfail insmod part_msdos insmod ext2 set root='(hd1,msdos8)’ search –no-floppy –fs-uuid –set c825786c-e42c-4fed-8cc2-fd2a610a183b linux /boot/vmlinuz-2.6.32-25-server root=UUID=c825786c-e42c-4fed-8cc2-fd2a610a183b ro vga=775 quiet splash initrd /boot/initrd.img-2.6.32-25-server}menuentry ‘Ubuntu, with Linux 2.6.32-25-server (recovery mode)’ –class ubuntu –class gnu-linux –class gnu –class os{ recordfail insmod part_msdos insmod ext2 set root='(hd1,msdos8)’ search –no-floppy –fs-uuid –set c825786c-e42c-4fed-8cc2-fd2a610a183b echo ‘Loading Linux 2.6.32-25-server …’ linux /boot/vmlinuz-2.6.32-25-server root=UUID=c825786c-e42c-4fed-8cc2-fd2a610a183b ro single vga=775 echo ‘Loading initial ramdisk …’ initrd /boot/initrd.img-2.6.32-25-server}#menuentry ‘Ubuntu, with Linux 2.6.32-25-generic’ –class ubuntu –class gnu-linux –class gnu –class os{ recordfail insmod part_msdos insmod ext2 set root='(hd1,msdos8)’ search –no-floppy –fs-uuid –set c825786c-e42c-4fed-8cc2-fd2a610a183b linux /boot/vmlinuz-2.6.32-25-generic root=UUID=c825786c-e42c-4fed-8cc2-fd2a610a183b ro vga=775 quiet splash initrd /boot/initrd.img-2.6.32-25-generic}#menuentry ‘Ubuntu, with Linux 2.6.32-25-generic (recovery mode)’ –class ubuntu –class gnu-linux –class gnu –class os{ recordfail insmod part_msdos insmod ext2 set root='(hd1,msdos8)’ search –no-floppy –fs-uuid –set c825786c-e42c-4fed-8cc2-fd2a610a183b echo ‘Loading Linux 2.6.32-25-generic …’ linux /boot/vmlinuz-2.6.32-25-generic root=UUID=c825786c-e42c-4fed-8cc2-fd2a610a183b ro single vga=775 echo ‘Loading initial ramdisk …’ initrd /boot/initrd.img-2.6.32-25-generic}#menuentry ‘Ubuntu, with Linux 2.6.32-25-preempt’ –class ubuntu –class gnu-linux –class gnu –class os{ recordfail insmod part_msdos insmod ext2 set root='(hd1,msdos8)’ search –no-floppy –fs-uuid –set c825786c-e42c-4fed-8cc2-fd2a610a183b linux /boot/vmlinuz-2.6.32-25-preempt root=UUID=c825786c-e42c-4fed-8cc2-fd2a610a183b ro vga=775 quiet splash initrd /boot/initrd.img-2.6.32-25-preempt}#menuentry ‘Ubuntu, with Linux 2.6.32-25-preempt (recovery mode)’ –class ubuntu –class gnu-linux –class gnu –class os{ recordfail insmod part_msdos insmod ext2 set root='(hd1,msdos8)’ search –no-floppy –fs-uuid –set c825786c-e42c-4fed-8cc2-fd2a610a183b echo ‘Loading Linux 2.6.32-25-preempt …’ linux /boot/vmlinuz-2.6.32-25-preempt root=UUID=c825786c-e42c-4fed-8cc2-fd2a610a183b ro single vga=775 echo ‘Loading initial ramdisk …’ initrd /boot/initrd.img-2.6.32-25-preempt}### 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_memtest86+ ####menuentry “Memory test (memtest86+)”{ insmod part_msdos insmod ext2 set root='(hd1,msdos8)’ search –no-floppy –fs-uuid –set c825786c-e42c-4fed-8cc2-fd2a610a183b linux16 /boot/memtest86+.bin}menuentry “Memory test (memtest86+, serial console 115200)”{ insmod part_msdos insmod ext2 set root='(hd1,msdos8)’ search –no-floppy –fs-uuid –set c825786c-e42c-4fed-8cc2-fd2a610a183b linux16 /boot/memtest86+.bin console=ttyS0,115200n8}### END /etc/grub.d/20_memtest86+ ###### BEGIN /etc/grub.d/30_os-prober ###menuentry “Microsoft Windows XP Professional (on /dev/sda1)” { insmod part_msdos insmod ntfs set root='(hd1,msdos1)’ search –no-floppy –fs-uuid –set 22a89599a8956bd3 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 ###### BEGIN /etc/grub.d/41_custom ###if [ -f $prefix/custom.cfg ]; then source $prefix/custom.cfg;fi### END /etc/grub.d/41_custom ###

——————————————————————

对以上启动项配置修改的简要说明:

红色语句前面都是加了”#“就是不再显示的启动项,如果以后需要再次重新启用,那么只要能够进入编辑/boot /grub/grub.cfg这个文件,把”#“号去掉就可以了。绿色的项目是保留的启动项,在系统启动时候会显示。万一你对分辨这红和绿这两种颜色有困 难的话,可以数一下,启动代码中红色的语句共7句,绿色的3句。

五、关于系统启动时默认等待时间的设置:

Ubuntu默认是显示启动列表10秒以后自动进入第一个显示的启动项。要修改这个启动等待时间也是可以在/boot/grub/grub.cfg这个文件里面修改的,找到以下代码段:

—————————————————————

search –no-floppy –fs-uuid –set c825786c-e42c-4fed-8cc2-fd2a610a183bset locale_dir=($root)/boot/grub/localeset lang=zhinsmod gettextif [ “${recordfail}” = 1 ]; then set timeout=-1else set timeout=3fi

————————————————————–

修改else语句后面这个”timeout“的值,比如这里是3表示等待3秒后自动进入系统。改为其他值比如5就等待5秒。

如果你不熟悉代码的意思或者怕改错,那么建议你安装一个启动管理器在里面进行可视化设置。这样比较保险。

方法见上述第”一“部分。再帖一下:

  打开终端输入:sudo apt-get install startupmanager #需要能上网哦

  安装启动管理器

  系统——系统管理——启动管理器,选中默认开机操作系统即可。

可是我要如何在浅薄的纸上为你画上我所有的命轮?

Ubuntu 11.04 / 10.10 双系统启动项管理及配置方法

相关文章:

你感兴趣的文章:

标签云: