红联Linux门户
Linux帮助

grub2

发布时间:2010-10-12 14:16:11来源:红联作者:wucongdonglai
最近编译内核,发现ubuntu10.04里面grub变了,以前是menu.lst,现在改为grub.cfg了,而且里面多了一堆我看不懂的东西!如下:(这是前半部分,后半部分能看懂)
#
# 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判断是怎么回事,起什么作用?
if [ -s $prefix/grubenv ]; then
load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
set saved_entry=${prev_saved_entry}
#这set后面跟着的下面这行是什么意思?看不明白
save_env saved_entry
set prev_saved_entry=
#这里的set后面怎么=了2个,而且一个还是它自己,不懂
save_env prev_saved_entry
set boot_once=true
fi

function 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
}
insmod ext2
set root='(hd0,1)'
#这下面那行,这么长的一串数字是哪来的?干啥使的啊?
search --no-floppy --fs-uuid --set 8b465201-4909-4562-8a59-6b8d612c6bf6
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
fi
fi
insmod ext2
set root='(hd0,1)'
search --no-floppy --fs-uuid --set 8b465201-4909-4562-8a59-6b8d612c6bf6
set locale_dir=($root)/boot/grub/locale
set lang=en
insmod gettext
#这里为什么要搞个 ${recordfail} = 1的判断呢?有什么用吗?timeout=-1,那不是待机时间为-1秒了吗?不懂啊?
if [ ${recordfail} = 1 ]; then
set timeout=-1
else
set timeout=10
fi
### END /etc/grub.d/00_header ###
主要就这些问题,那位大大好心帮忙解答一下啊?
文章评论

共有 7 条评论

  1. shenhao0129 于 2010-10-13 11:46:05发表:

    grub2不是搞的这么麻烦,这都不是手动写的,根据配置文件,自动生成的,看起来当然就显得复杂点了

  2. wucongdonglai 于 2010-10-13 08:25:45发表:

    4# 相思爱文
    grub里面的确只要3行就可以了啊,不知道为什么这grub2里面搞得那么麻烦

  3. deepwhite 于 2010-10-13 08:24:39发表:

    引用:
    不用那么麻烦也能启动的。
    用三行就行了
    root……
    linux……
    initrd……
    相思爱文 发表于 2010-10-12 18:54


    Grub2 和 grub 的设置有区别的,可以看看这里:
    http://www.ibm.com/developerworks/linux/library/l-grub2/?ca=drs-

  4. wucongdonglai 于 2010-10-13 08:24:32发表:

    3# deepwhite
    -1是这么回事啊!有道理,脚本方面的知识的确比较欠缺,是要补补

  5. 相思爱文 于 2010-10-12 18:54:45发表:

    不用那么麻烦也能启动的。
    用三行就行了
    root……
    linux……
    initrd……

  6. deepwhite 于 2010-10-12 18:14:46发表:

    没看那么仔细,不过前面的四个问题看看脚本语言你就应该明白了,可以参考一个 Bash Reference.

    后面的“这么长的一串数字”是磁盘分区的 UUID , 你执行一下 ls -l /dev/disk/by-uuid 就会看到了。

    最后的 Timeout, GRUB 文档中有介绍:[code]
    ‘GRUB_TIMEOUT’
    Boot the default entry this many seconds after the menu is displayed, unless a key is pressed. The default is ‘5’. Set to ‘0’ to boot immediately without displaying the menu, or to ‘-1’ to wait indefinitely.
    [/code]你想了解更多的话,两个建议:
    1. 学学脚本语言,比如最常用的 bash
    2. 阅读下面的链接:
    http://www.gnu.org/software/grub/manual/grub.html

  7. 绿色圣光 于 2010-10-12 15:52:17发表:

    楼主学习一下GRUB2吧~