How to Set Up Grub in a Dual Boot System
Guide Overview
The purpose of this guide is to teach you how to set up Grub in a dual boot system.
When running Windows Updates in a dual system, sometimes you need to have an unattended restart of Windows.
If Linux is the default system in Grub, then you have to wait, and select Windows manually.
This modification will instruct Grub to always boot to the last OS used, thereby allowing unattended updates of Windows.
Tools Needed
- A working Grub Boot Loader
- A Dual Boot System
- A Terminal Text Editor
Instructions
Step 1 - Modify the /etc/default/grub file
Open a terminal, by either selecting one from your menu, or pressing the ctl+alt+t at the same time.
The default terminal text editor in Unbuntu is Nano.
Type the following command and press enter:
sudo cp /etc/default/grub /etc/default/grub.bak
Enter your password. No characters will appear on the screen as you type your password.
You have just made a backup copy of your grub file.
Now enter the following command:
sudo nano /etc/default/grub
Your grub file will be opened in the Nano text editor.
We are interested in this section of the file:
GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
We are going to change on line, and add one line.
Change the line "GRUB_DEFAULT=0" to "GRUB_DEFAULT=saved".
Press enter to place a carriage return and start a new line.
Add the following line:
GRUB_SAVEDEFAULT=true
Your grub file should now look like this:
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
Press ctl+x to exit Nano and save the changes by entering Y. (Either upper or lower case will work.)
Now enter this command:
sudo update-grub
Now, grub will automatically select the last OS boot you used.
If you select Windows from the menu, then Windows becomes default.
The next time you select Linux, it will be set back to default.
You can test by rebooting you computer, and selecting a different OS.
Step 2 - There is no Step 2.
Cheers!
Naught