การเปลี่ยนลำดับการบูตของ GRUB2

GRUB2 ไม่มีเมนูให้แก้ไขเหมือนเดิมแล้วครับ การแก้ไขใดๆ ต้องกระทำผ่าน GRUB เท่านั้นครับ

หากลองเปิด /boot/grub/grub.cfg ดู จะพบข้อความประมาณนี้
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from  and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set default=0
set timeout=5
set root=(hd1,8)
search --fs-uuid --set 93d5d78f-42eb-4d8a-8806-adb40171f5fc
if loadfont /usr/share/grub/ascii.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
### END /etc/grub.d/00_header ###

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

### BEGIN /etc/grub.d/10_linux ###
menuentry "Ubuntu, linux 2.6.30-8-generic" {
    set root=(hd1,8)
    search --fs-uuid --set 93d5d78f-42eb-4d8a-8806-adb40171f5fc
    linux    /boot/vmlinuz-2.6.30-8-generic root=UUID=93d5d78f-42eb-4d8a-8806-adb40171f5fc ro  quiet splash
    initrd    /boot/initrd.img-2.6.30-8-generic
}
menuentry "Ubuntu, linux 2.6.30-8-generic (recovery mode)" {
    set root=(hd1,8)
    search --fs-uuid --set 93d5d78f-42eb-4d8a-8806-adb40171f5fc
    linux    /boot/vmlinuz-2.6.30-8-generic root=UUID=93d5d78f-42eb-4d8a-8806-adb40171f5fc ro single
    initrd    /boot/initrd.img-2.6.30-8-generic
}
### END /etc/grub.d/10_linux ###

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

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows NT/2000/XP (loader) (on /dev/sda1)" {
    set root=(hd0,1)
    chainloader +1
}
menuentry "Ubuntu 9.04, kernel 2.6.28-13-generic (on /dev/sda7)" {
    set root=(hd0,7)
    linux /boot/vmlinuz-2.6.28-13-generic root=UUID=f0bc8483-f70d-4689-99bb-93a3e7eeb626 ro quiet splash
    initrd /boot/initrd.img-2.6.28-13-generic
}
menuentry "Ubuntu 9.04, kernel 2.6.28-13-generic (recovery mode) (on /dev/sda7)" {
    set root=(hd0,7)
    linux /boot/vmlinuz-2.6.28-13-generic root=UUID=f0bc8483-f70d-4689-99bb-93a3e7eeb626 ro single
    initrd /boot/initrd.img-2.6.28-13-generic
}
menuentry "Ubuntu 9.04, memtest86+ (on /dev/sda7)" {
    set root=(hd0,7)
    linux /boot/memtest86+.bin
}
menuentry "Ubuntu 9.04, kernel 2.6.28-13-generic (on /dev/sdb5)" {
    set root=(hd1,5)
    linux /boot/vmlinuz-2.6.28-13-generic root=UUID=9470ea92-8b37-4d18-8132-925d8f1aa888 ro quiet splash
    initrd /boot/initrd.img-2.6.28-13-generic
}
menuentry "Ubuntu 9.04, kernel 2.6.28-13-generic (recovery mode) (on /dev/sdb5)" {
    set root=(hd1,5)
    linux /boot/vmlinuz-2.6.28-13-generic root=UUID=9470ea92-8b37-4d18-8132-925d8f1aa888 ro single
    initrd /boot/initrd.img-2.6.28-13-generic
}
menuentry "Ubuntu 9.04, memtest86+ (on /dev/sdb5)" {
    set root=(hd1,5)
    linux /boot/memtest86+.bin
}
menuentry "Ubuntu 9.04 unmodified 2.6.28-13-generic (sda7) (on /dev/sdb5)" {
    set root=(hd1,5)
    linux /boot/vmlinuz-2.6.28-13-generic root=UUID=f0bc8483-f70d-4689-99bb-93a3e7eeb626 ro quiet splash
    initrd /boot/initrd.img-2.6.28-13-generic
}
menuentry "Ubuntu 9.04, unmodified 2.6.28-13-generic (recovery mode) (sda7) (on /dev/sdb5)" {
    set root=(hd1,5)
    linux /boot/vmlinuz-2.6.28-13-generic root=UUID=f0bc8483-f70d-4689-99bb-93a3e7eeb626 ro single
    initrd /boot/initrd.img-2.6.28-13-generic
}
menuentry "Kubuntu 9.04, kernel 2.6.28-13-generic (on /dev/sdb7)" {
    set root=(hd1,7)
    linux /boot/vmlinuz-2.6.28-13-generic root=UUID=90413117-5470-4897-bf4a-2f34e11736b7 ro quiet splash
    initrd /boot/initrd.img-2.6.28-13-generic
}
menuentry "Kubuntu 9.04, kernel 2.6.28-13-generic (recovery mode) (on /dev/sdb7)" {
    set root=(hd1,7)
    linux /boot/vmlinuz-2.6.28-13-generic root=UUID=90413117-5470-4897-bf4a-2f34e11736b7 ro single
    initrd /boot/initrd.img-2.6.28-13-generic
}
menuentry "Kubuntu 9.04, memtest86+ (on /dev/sdb7)" {
    set root=(hd1,7)
    linux /boot/memtest86+.bin
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file is an example on how to add custom entries
### END /etc/grub.d/40_custom ###


set default=0 จะหมายถึงลำดับที่ ของ OS ที่เป็นค่าเริ่มต้น ซึ่งลำดับ 0 หมายถึงรายการแรกของ OS ที่พบ menuentry "Ubuntu, linux 2.6.30-8-generic"

ให้สังเกตุดูที่ลำดับที่ของ OS ที่ต้องการจะให้ Boot นะครับ ในที่นี้คือ menuentry "Windows NT/2000/XP (loader) (on /dev/sda1)" ซึ่งเป็นเมนูลำดับที่ 4 (ลำดับที่ของเมนูจะเริ่มจาก 0)

ขั้นตอนต่อไป เราจะมาทำการแก้ไขเมนูของ GRUB2 กัน

1.เปิดไฟล์
/etc/default/grub

ด้วย gEdit (ต้องเป็น root เท่านั้นนะครับ)

คุณจะพบข้อความประมาณนี้
# 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_DEFAULT="quiet splash"

# 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

กำหนดค่า ตามที่อ่านได้จากตอนแรกเพื่อกำหนดลำดับการ Boot
GRUB_DEFAULT=0

กำหนดช่วงเวลารอคอยของเมนูของ GRUB (ไม่น้อยกว่า 1)
GRUB_TIMEOUT=5

ขนาดหน้าจอของ GRUB
GRUB_GFXMODE=640x480

หลังจากแก้ไขค่าแล้วให้ Save

ขั้นตอนต่อไปจะเป็นการสั่งให้ GRUB2 ทำการแก้ไข

2.เปิด Terminal พิมพ์คำสั่งด้านล่าง แล้วกด Enter
sudo update-grub

จะมีข้อความอัปเดท GRUB แสดงขึ้นมา หลังจากเสร็จเรียบร้อยแล้ว สามารถดูผลงานได้ที่ /boot/grub/grub.cfg ครับ
ผู้เขียน goragod โพสต์เมื่อ 09 เม.ย. 2553 เปิดดู 12,084 ป้ายกำกับ UBUNTU
^