修改Linux默认启动系统的方法之一


如何修改 grub 以更改Linux默认启动系统网上的说法主要有两种,分别是修改两个文件:/boot/grub/grub.conf   or  /boot/grub/menu.lst也有说是 /etc 目录下的相应文件的。这里介绍一下我的尝试。

在 Ubuntu-9.10 下面,具体文件是这样地:
/boot/grub/grub.cfg
至于更改的那个 set default=”x“, 那个x的意思,就拿我机器作为例子来说:

  1. [eg].> ls -l grub.cfg-r--r--r--    grub.cfg  
  2. > sudo chmod 244 grub.cfg> ls -l grub.cfg--w-r--r--    grub.cfg  
  3. > sudo vim grub.cfg  

修改之后,最后别忘了:> sudo chmod 444 grub.cfg    // 一定记得要改回来.
我晕,用过一段时间后竟然有这么多东西,那么就用彩色来突出一下重点吧,其他内容请自动跳过。如蓝色部分所示,grub里面一共分为这么几个部分,一般三个。再如红色部分所示,也就是 menuentry 项,所以 menuentry 项按顺序从 0 开始排列,如果想让哪个成为Linux默认启动系统,就将 set default=“x” 中的 x 改为那个 entry 的编号。eg,如果我的电脑想默认进 windows 虽然这是没门的事),就另 x 为 8. 体现为启动时到选择启动系统时光标默认定位在 windows 系统入口上。
至于将 windows 系统不仅设置为Linux默认启动系统, 而且要放在所有系统入口最顶端,还没试过。只是根据这个文件猜测:是不是将这个文件的 windows 的那个 menuentry 剪切到最前面就行? 使其 entry 编号为 0... 这个猜测暂不确定。

  1. -------------------------------------- grub.cfg, start ---------------------------------#  
  2. # DO NOT EDIT THIS FILE  
  3. #  
  4. # It is automatically generated by /usr/sbin/grub-mkconfig using templates  
  5. # from /etc/grub.d and settings from /etc/default/grub  
  6. #  
  7. ### BEGIN /etc/grub.d/00_header ###  
  8. if [ -s /boot/grub/grubenv ]; then  
  9.   have_grubenv=true 
  10.   load_env  
  11. fi  
  12. set default="0" 
  13. if [ ${prev_saved_entry} ]; then  
  14.   saved_entry=${prev_saved_entry}  
  15.   save_env saved_entry  
  16.   prev_saved_entry=  
  17.   save_env prev_saved_entry  
  18. fi  
  19. insmod ext2  
  20. set root=(hd0,8)  
  21. search --no-floppy --fs-uuid --set ab1eac76-a5d7-4656-8918-ffb406010912  
  22. if loadfont /usr/share/grub/unicode.pf2 ; then  
  23.   set gfxmode=640x480 
  24.   insmod gfxterm  
  25.   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 ###  
  26. ### 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 ###  
  27. ### BEGIN /etc/grub.d/10_linux ###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}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}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}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}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}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}### END /etc/grub.d/10_linux ###  
  28. ### BEGIN /etc/grub.d/20_memtest86+ ###menuentry "Memory test (memtest86+)" {  // 6    linux16 /boot/memtest86+.bin}menuentry "Memory test (memtest86+, serial console 115200)" {  // 7    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)" {  // 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 ###  
  29. ### 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 ###  
  30. --------------------------------- grub.cfg, end --------------------------------------------- 

以上是用grub修改Linux默认启动系统的一种尝试。

  1. Linux进程状态解析之T、Z、X
  2. Linux进程状态解析之R、S、D
  3. 简单概述Linux进程操作命令
  4. Linux分区方案深度讨论
  5. Linux系统优势六大方面

相关内容

    暂无相关文章