Fedora – How to change boot sequence -Grub2



Update
Works with Fedora 20
Works with Fedora 17

This is for dual boot os users, there are many who prefers dual boot to keep another OS optional. For any reason if you wish to change boot sequence unlike grub, grub2 requires couple of commands to run.

Here will take example to keep Windows as default boot.
First of all find menuentry for Windows

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

result:-

menuentry "Windows 7 (loader) (on /dev/sda1)" --class windows --class os {

Set Windows menuentry as default (only entry mentioned in either " or ' from above command)

grub2-set-default "Windows 7 (loader) (on /dev/sda1)"

Verify default entry

grub2-editenv list

Generate updated grub.cfg

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

Below is to set Fedora as default boot

cat /boot/grub2/grub.cfg |grep Fedora
grub2-set-default "Fedora Linux, with Linux 3.1.0-5.fc16.i686"
grub2-editenv list
grub2-mkconfig -o /boot/grub2/grub.cfg

————————————————————————————————————————————————
Update 2011-12-29
This one is dirty way to achieve purpose. Especially if above does not works.
e.g following err faced by one of commenter.


grub2-mkconfig -o /boot/grub2/grub.cfg
/sbin/grub2-probe: error: cannot stat `/dev/root’.

You need to do this after every new kernel installation, as it may change default entry.

vim /boot/grub2/grub.cfg
#replace
set default="${saved_entry}"
#with
set default="2"

Now check on reboot, third boot entry should be default for booting.
for grub first entry is 0, second is 1, third is 2 & so on.

To keep default=2 permanent even after new kernel installation
vim /etc/default/grub
#replace
GRUB_DEFAULT=saved
#with
GRUB_DEFAULT=2


if you find any missing point in here, please let us know in comment section or tweet us at @linuxreaders. To get more articles like this, subscribe to our RSS feeds / Mails.
Read 248 articles by
  • Sarthak Sharma

    It’s not working for me. (the 1st method) I’m using fedora 20. No errors are reported however, the default choice is still ‘Fedora’.

    • dpthakar

      It works for me on F20, probably you have made some err with grub2-set-default

  • Pingback: How to change boot sequence -Grub2 | Virtualize the World

  • Pingback: /dev/blog » Change GRUB2 default boot target

  • Pingback: Compiler Kernel 3.4.2 Stable on Fedora Core 17 | IT水電工-哆啦胖虎

  • dagurasu dagurasu

    I believe the last step is wrong (but will usually work by accident). The default entry is set in the file /boot/grub2/grubenv which is changed with the grub2-set-default command and is available at bootup when processing grub.cfg . There is no need to rebuild grub.cfg in order to set this.  In fact when I followed these instructions grub.cfg ended up rebuilt with slightly different menuentry names and it broke the default.. resorting to the default default of 0. So skip the last grub2-mkconfig

    • dpthakar

       hi, I am not sure how it works for you, for me this boot sequence does not change unless grub.cfg is rebuild. Can someone pl confirm this?

  • Pingback: grub2 change default boot partition | wsinw.com

  • Pingback: grub2 change default boot partition | wsinw.com

  • shanid ahammed

    its working… smooth..thanx..but get fedora as default if we forget to exit terminal..

  • newgoldenmountain

    You explanation is very helpful and it helped me to set default kernel version on my Fedora 16 laptop. Thank you!!!

  • Bashir

    I got this error,what to do? i begins to discover fedora just days ago and i dont know what it means. can u introduce some pdf-book for learning linux fundamental and fedora specially? THX ——My Error—————–:-(————————- [root@localhost /]# grub2-mkconfig -o /boot/grub2/grub.cfg /sbin/grub2-probe: error: cannot stat `/dev/root’.

    • http://www.linuxreaders.com/ Dhaval Thakar

      they is bug filed for exact err. https://bugzilla.redhat.com/show_bug.cgi?id=737370 for now, try running yum update also check updates on bottom of the post

      • Bashir

        Dear Dhaval Thakar Two days after i reported my problem to you, i turned on my laptop for doing some work. when the GRUB2 loaded i saw that Win7 has highlighted in boot menu and after that my Acer AS 4741G booted from win7. So the first solution worked for me, however there was some error with generating updated grub.cfg. XOXO

  • James

    Great! Thanks.

  • Pingback: Fedora- How to change the boot order in Grub2 to Windows 7 « flyingpengwin

  • cj

    Thanks a lot!

  • Daniel S.

    Thanks a lot! You saved me!!

  • aelgali

    Nice! Worked great, Thanks

  • Stefan

    It does not work for me, although grub2-editenv list states the Windows entry correctly, grub selects the Fedora recovery mode kernel as default on my computer which is the last before the windows menu entry. I suspected that behind “Windows 7 (loader) (on /dev/sda1)” a wrong number but even giving the number 4 or 5 did result in grub2 only selecting the last entry before windows… Did it work for you?

    • http://www.linuxreaders.com/ Dhaval Thakar

      what is your output for following command? cat /boot/grub2/grub.cfg |grep Windows

      • Stefan

        I figured out that I forgot that I played with /etc/default/grub before I found your solution. I left the number 3 there instead of ‘saved’. Your solution works perfectly well now, thanks a lot! Stefan

  • AsVHEn

    TY

  • http://www.techienote.com Vidyadhar

    Nice tutorial. Done the same thing in ubuntu via changing order in /etc/grub.d/. See this for more info http://www.techienote.com/2011/08/changing-default-boot-os-in-ubuntu-11-04.html

Trending Posts