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.

24 Comments

  1. Sarthak Sharma says:

    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’.

  2. dagurasu dagurasu says:

    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 says:

       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?

  3. shanid ahammed says:

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

  4. newgoldenmountain says:

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

  5. Bashir says:

    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’.

    • Dhaval Thakar says:

      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 says:

        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

  6. James says:

    Great! Thanks.

  7. cj says:

    Thanks a lot!

  8. Daniel S. says:

    Thanks a lot! You saved me!!

  9. aelgali says:

    Nice! Worked great, Thanks

  10. Stefan says:

    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?

    • Dhaval Thakar says:

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

      • Stefan says:

        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

  11. Vidyadhar says:

    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

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

    [...] Fedora – How to change boot sequence -Grub2 [...]

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

    [...] http://fedoraproject.org/wiki/GRUB_2 http://www.linuxreaders.com/2011/11/fedora-16-how-to-change-boot-sequence-grub2.html (No Ratings Yet) Categories: Uncategorized Tags: Fedora, GRUB2 Comments (0) Trackbacks [...]

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

    [...] ◎以上就大功告成了,若想要知道詳細的Grub2的用法,可參考Fedora的官方網站、LinuxReader或人家的部落格,收工! Compile Kernel ← 在CentOS 5.6上簡易實作Quota磁碟配額的限制 Leave a comment ?0 Comments. /* */ [...]

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

    [...] - http://www.linuxreaders.com/2011/11/01/fedora-16-how-to-change-boot-sequence-grub2/ Tags: Fedora, [...]

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

    [...] - http://www.linuxreaders.com/2011/11/01/fedora-16-how-to-change-boot-sequence-grub2/ Tags: Fedora, [...]

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

    [...] Dhaval Thakar for this tip. Link Share this:TwitterFacebookLike this:LikeBe the first to like this [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trending Posts