• Fri. Oct 7th, 2022

Default OS to BOOT | How to change default OS to boot in GRUB | QuadBloggers

BySam

Aug 23, 2020 ,
Default OS to Boot

This post explains how to change default OS to boot in GRUB. There are 2 ways to select Default OS to Boot:

  1. Last selected OS
  2. Always boot the same OS

Last Selected OS

To save the last selected OS and boot it next time, follow the below procedure:

  1. In ubuntu, open terminal with Ctrl+Alt+T
  2. Type the below command:
    $ sudo vim /etc/default/grub
  3. Enter password if required. In case vim is not installed you can also use vi.
    $ sudo vi /etc/default/grub
  4. Once you enter the above command you will get the file with default settings:
grub file with default settings
/etc/default/grub with default settings
  1. To learn how to edit the file using vim / vi, refer here. (If you are still finding difficulty to learn vim commands, please leave a comment below. I would be happy to help you out).
  2. From above image you can notice that GRUB_DEFAULT=0. Change that to GRUB_DEFAULT=saved.
  3. Now, add a line below that with this setting: GRUB_SAVEDEFAULT=true.
  4. Your file should look like this:
grub file with custom settings to select default os to boot
/etc/default/grub with custom settings
  1. Once you have finished editing your file in vim, press ESC button to stop editing. Then type :wq to save and quit vim.
  2. Type the below command in terminal to update the grub:
    $ sudo update-grub
sudo update-grub for default os to boot
update-grub
  1. Now restart your system. Ubuntu will be selected now. Change to windows. Once you entered windows, restart your system and you will notice the default OS as Windows.

Always Boot the Same OS

From the above steps you would have learnt to save the last chosen OS and boot it the next time. Now lets consider you want to boot the same OS no matter what the last selected OS was. For example, grub always selects Ubuntu and you want to change it to Windows. Just follow the below procedure:

  1. In ubuntu, open terminal with Ctrl+Alt+T
  2. Type the below command:
    $ grep menuentry /boot/grub/grub.cfg
grub menu entry
grub menu entry
  1. The above screenshot shows the items displayed in the boot menu. From the above image, keep in mind the below values for your OS:
    • 0 = Ubuntu
    • 1 = Advanced options
    • 2 = Windows
  2. Copy the slection you want from the terminal. For example, Windows Boot Manager (on /dev/sda2)
  3. Enter the below command:
    $ sudo vim /etc/default/grub
  4. Now, there are 2 ways you can change the default OS:
    1. Change GRUB_DEFAULT="Windows Boot Manager (on /dev/sda2)"
      OR
    2. Change GRUB_DEFAULT=2 as Windows is 2 (explained in step 3 above).
  5. Once you have finished editing your file in vim, press ESC button to stop editing. Then type :wq to save and quit vim.
  6. Type the below command in terminal to update the grub:
    $ sudo update-grub
  7. Reboot your system and you will find Windows selected.

Comment in case you need any improvements or if you have any doubts.
All comments will be replied asap.

Do checkout our other technology blogs here.

Sam

Leave a Reply

Your email address will not be published.