Wednesday, 25 April 2012

Setting default boot kernel in grub 2

Setting default boot kernel in grub 2

Each time kernal is updated  boot order is changed automatically so it is necessary many times for me atleast to set it back to the old boot order.

See already running grub entries

cat /boot/grub2/grub.cfg | grep Fedora

menuentry 'Fedora (3.3.2-1.fc16.x86_64)' --class fedora --class gnu-linux --class gnu --class os {
    echo 'Loading Fedora (3.3.2-1.fc16.x86_64)'
menuentry 'Fedora Linux, with Linux 3.3.1-3.fc16.x86_64' --class fedora --class gnu-linux --class gnu --class os {
menuentry 'Fedora Linux, with Linux 3.3.1-3.fc16.x86_64 (recovery mode)' --class fedora --class gnu-linux --class gnu --class os {
menuentry 'Fedora Linux, with Linux 3.1.0-7.fc16.x86_64' --class fedora --class gnu-linux --class gnu --class os {
menuentry 'Fedora Linux, with Linux 3.1.0-7.fc16.x86_64 (recovery mode)' --class fedora --class gnu-linux --class gnu --class os {


get the menu entry from the result which you want to make as default (copy the portion in single inverted coma)

ex : Fedora Linux, with Linux 3.1.0-7.fc16.x86_64

now issue this command to set this as default

grub2-set-default "Fedora Linux, with Linux 3.1.0-7.fc16.x86_64"
see which is default boot entry buy issuing

grub2-editenv list - you should see something similar to below one based on your menu entry

ex: saved_entry=Fedora Linux, with Linux 3.1.0-7.fc16.x86_64

generate a grub config file

grub2-mkconfig -o /boot/grub2/grub.cfg