Friday, November 27, 2009

Grub Setting on Ubuntu 9.10 Karmic Koala

GRand Unified Bootloader it is the software responsible for loading and transferring control to the operating system kernel during the initial boot. On the Koala Karmic is using GRUB version 2. On this version there is a bit different on file configuration. On last version, all of the GRUB configuration can we see on file '/boot/grub/menu.list'. On this version, the configuration file is on this path :
sonic2epix@matrix:~$ sudo gedit /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=10
#GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT="10"
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entrys
#GRUB_DISABLE_LINUX_RECOVERY="true"
This file contain GRUB setting variable. You can make any change setting of this variable to make the GRUB running as you want. Beware that after you editing this file, you must running the update-grub syntax on console to update the GRUB setting.

If you want to change the list of the Boot Menu, you can edit on this path :
sonic2epix@matrix:~$ sudo gedit /boot/grub/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 [ -s /boot/grub/grubenv ]; then
  have_grubenv=true
  load_env
fi
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,1)
search --no-floppy --fs-uuid --set 15ed4e71-1d78-4ed8-9855-3b3771861ce9
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
if [ ${recordfail} = 1 ]; then
  set timeout=-1
else
  set timeout=3
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/white
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry "Ubuntu, Linux 2.6.31-14-generic" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
 set quiet=1
 insmod ext2
 set root=(hd0,1)
 search --no-floppy --fs-uuid --set 15ed4e71-1d78-4ed8-9855-3b3771861ce9
 linux /boot/vmlinuz-2.6.31-14-generic root=UUID=15ed4e71-1d78-4ed8-9855-3b3771861ce9 ro   quiet splash
 initrd /boot/initrd.img-2.6.31-14-generic
}
menuentry "Ubuntu, Linux 2.6.31-14-generic (recovery mode)" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
 insmod ext2
 set root=(hd0,1)
 search --no-floppy --fs-uuid --set 15ed4e71-1d78-4ed8-9855-3b3771861ce9
 linux /boot/vmlinuz-2.6.31-14-generic root=UUID=15ed4e71-1d78-4ed8-9855-3b3771861ce9 ro single 
 initrd /boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
 linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
 linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows Vista (loader) (on /dev/sda2)" {
 insmod ntfs
 set root=(hd0,2)
 search --no-floppy --fs-uuid --set 5220fd0220fcedbb
 chainloader +1
}
if [ ${timeout} != -1 ]; then
  if sleep --interruptible 3 ; then
    set timeout=0
  fi
fi
### 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 ###

If you want to hide the boot menu on GRUB 2, you must do little more things like this one.
sonic2epix@matrix:~$ sudo gedit /etc/grub.d/30_os-prober
adjust_timeout () {
  if [ "x${found_other_os}" = "x" ] ; then
    if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then
      if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
 verbose=
      else
 verbose=" --verbose"
      fi

      if [ "x${GRUB_HIDDEN_TIMEOUT}" = "x0" ] ; then
 cat <<EOF
if [ \${timeout} != -1 ]; then
  if keystatus; then
    if keystatus --shift; then
      set timeout=-1
    else
      set timeout=0
    fi
  else
    if sleep$verbose --interruptible 3 ; then
      set timeout=0
    
    fi
  fi
fi
EOF
      else
 cat << EOF
if [ \${timeout} != -1 ]; then
  if sleep$verbose --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then
    set timeout=0
  fi
fi
EOF
      fi
    fi
  fi
}
Replace the script on the line 28-29 become this one :
if [ "x${found_other_os}" = "x" ] || [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then
Delete the script 'fi' on the line 61. Make sure you uncomment the variable 'GRUB_HIDDEN_TIMEOUT' on the '/etc/default/grub' to enable the Hidden Boot Menu and then restart your computer to see the different.

2 comments:

jarwadi said...

thanks for this article, thinks this is useful for me as newbie who want to extend skills about linux especially ubuntu

Dwi M. Wibowo said...

you're welcome ..