Wednesday, September 14, 2011

How to change boot order for Ubuntu (>9.10)

1. cat /boot/grub/grub.cfg
see the order of the wanted kernel. Starts from 0.

Example:
...
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Ubuntu, with Linux 2.6.35-30-server' --class ubuntu --class gnu-linux
# this is 0
--class gnu --class os {
recordfail
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set 71119ab7-e93f-49a9-80f1-efc11398c954
linux /boot/vmlinuz-2.6.35-30-server root=UUID=71119ab7-e93f-49a9-80f1
-efc11398c954 ro quiet
initrd /boot/initrd.img-2.6.35-30-server
}

# this is 1
menuentry 'Ubuntu, with Linux 2.6.35-30-server (recovery mode)' --class ubuntu -
-class gnu-linux --class gnu --class os {
recordfail
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set 71119ab7-e93f-49a9-80f1-efc11398c954
echo 'Loading Linux 2.6.35-30-server ...'
linux /boot/vmlinuz-2.6.35-30-server root=UUID=71119ab7-e93f-49a9-80f1
-efc11398c954 ro single
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-2.6.35-30-server
}

# this is 2
menuentry 'Ubuntu, with Linux 2.6.32-28-server' --class ubuntu --class gnu-linux
--class gnu --class os {
recordfail
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set 71119ab7-e93f-49a9-80f1-efc11398c954
linux /boot/vmlinuz-2.6.32-28-server root=UUID=71119ab7-e93f-49a9-80f1
-efc11398c954 ro quiet
initrd /boot/initrd.img-2.6.32-28-server
}

# this is 3
menuentry 'Ubuntu, with Linux 2.6.32-28-server (recovery mode)' --class ubuntu -
-class gnu-linux --class gnu --class os {
recordfail
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set 71119ab7-e93f-49a9-80f1-efc11398c954
echo 'Loading Linux 2.6.32-28-server ...'
linux /boot/vmlinuz-2.6.32-28-server root=UUID=71119ab7-e93f-49a9-80f1
-efc11398c954 ro single
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-2.6.32-28-server
}
### END /etc/grub.d/10_linux ###
...

2. vi /etc/default/grub
change GRUB_DEFAULT=0 value to wanted kernel

Example:

If we want to boot to 'Ubuntu, with Linux 2.6.32-28-server' we should set 2

3. run update-grub to update

4. reboot and check with uname -r to see if correct kernel selected.

No comments: