Changing the Default OS in GRUB—the Easy Way!

A grub larva

Like many folks, I have my laptop set to dual boot Windows and Linux. This isn’t the sort of thing that’s too terribly difficult to set up, but GRUB always boots up Linux by default, and sometimes that’s not ideal, such when I’m trying to install Windows updates that require a restart or two. I’m a distractible beast, and I always seem to look away from my computer at just the wrong time.

When I searched for an easy way to switch which OS was set to boot by default, I found a lot of dead ends, either outdated information or complicated methods that just seemed like a lot more trouble than they were worth for what is, at the end of the day, a minor annoyance. Well I took another crack at it the other day and I finally found an easy solution! Better yet, I found out that it’s also easy to set GRUB to save whichever OS was booted last as use that as the default! That’s not even what I was initially trying to figure out how to do, but that’s exactly the behavior I wanted, I realized.

Now, this should work for any version of GRUB2, though I can’t personally vouch for other setups; I have GRUB version 2.02 from Linux Mint. But the solution is to simply edit the /etc/default/grub file, which is used to generate the actual grub.conf file (which should not be edited by hand).

There is a line which reads:


The value is an index number for the menu items displayed by the GRUB menu at boot, starting at zero for the first item. You can switch this number to set any other item on the list as the default, so 1 for the 2nd menu item, 2 for the 3rd menu item, etc.

OR! You can change this value to saved and add one more option as follows:


As you might suppose, this tells GRUB to start saving a reference to whichever OS was last booted and sets that reference as the new default. After saving these changes, the GRUB boot menu will still display as before, so you are free to manually select whichever OS you need, but left unattended, whichever menu option was chosen last will be booted automatically when the countdown timer runs out.

For good measure, now that I was more confident about my default boot selection, I went ahead and shortened that boot countdown to 30 seconds:


As the file reminds you in the comments, once you are done saving your changes, be sure to run sudo update-grub to put them into effect.

For more details and to learn about some of the other GRUB options, check out this post from How To Geek.