grub2 のメモ

始めに.

lenny の install 時に, boot loader として grub2 か grub を選べるように なってました. とりあえず grub2 を install しました.

設定が変わっていたので, ちょっとメモ残しておきます.

設定

設定ファイルは /boot/grub/grub.cfg. 中身を見てみると冒頭にこんな事が書いてある.

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/update-grub using templates
# from /etc/grub.d and settings from /etc/default/grub
#
...

そんな訳で /etc/default/grub と /etc/grub.d を眺めてみる.

/etc/default/grub

中身は以下の様な感じ.

# This file is sourced by update-grub, and its variables are propagated
# to its children in /etc/grub.d/
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX=

GRUB の boot 時にパラメータを渡したい時には GRUB_CMDLINE_LINUX に渡すと良いだろう. とりあえず

GRUB_CMDLINE_LINUX="vga=791"

としてみる. その後で

$ sudo /usr/sbin/update-grub

で /boot/grub/grub.cfg が更新される.

/etc/grub.d/

画面サイズを変更.

 set gfxmode=1024x768

背景画像と文字色を設定. 使いたい画像を /boot/grub/splash.{png,tga} で指定する.

...
use_bg=false
if [ "$GRUB_TERMINAL" = "gfxterm" ]  then
  for i in /boot/grub/splash.{png,tga}  do
    if bg=`convert_system_path_to_grub_path $i`  then
      case ${bg} in
        *.png)          reader=png ;
        *.tga)          reader=tga ;
        *.jpg|*.jpeg)   reader=jpeg ;
      esac
      if test -e /boot/grub/${reader}.mod  then
        echo "Found Debian background: `basename ${bg}`" >&2
        use_bg=true
        break
      fi
    fi
  done
fi
...
# set the background if possible
if ${use_bg}  then
  cat << EOF
insmod ${reader}
if background_image ${bg}  then
  set color_normal=white/black
  set color_highlight=cyan/black
else
EOF
fi
...

参考文献