Introduction to Linux - A Hands on Guide | Linux Bible | Linux From Scratch | A Newbie's Getting Started Guide to Linux | Linux Command Line Cheat Sheet | More Linux eBooks



Thursday, 30 January 2014

How To : Change the Default GRUB Boot Entry Using Command Line in Ubuntu/Linux Mint

how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry, how-to-change-default-grub-boot-entry,

What is GRUB?

    GRUB  is an acronym of GRand Unified Bootloader and it is a Multi-boot loader package developed by GNU to support multiple operating systems. Whenever there are more than one operating systems installed on a system, GRUB would ask the user to select any one among them during boot-up process. One can delete or modify the boot entries, change the boot times and configure GRUB dynamically.

    In this article, we would see how to change the default GRUB boot entry using CLI.

    So, the scenario is, I'm having two operating systems Ubuntu and Windows 7, installed on my computer. The default boot entry is Ubuntu, i.e., Ubuntu would be booted if I don't select any of the operating systems at boot-up. Being a die hard gamer, I would want Windows 7 to be booted automatically. Presently, the GRUB boot order for me is something like this:

  • Ubuntu, with Linux 3.8.0-3-generic
  • Ubuntu, with Linux 3.8.0-3-generic (recovery mode)
  • Memory test (memtest86+)
  • Memory test (memtest86+, serial console 115200)
  • Windows 7 (loader) (on /dev/sda1)
Step 1: In order to change default boot entry, we need to edit /etc/default/grub file. Before that, lets take a back up for the said file so that if anything goes wrong, we can easily revert back to the previous state.

sudo cp /etc/default/grub /etc/default/grub.bak
Step 2: Edit the file /etc/default/grub using your favorite text editor.

sudo gedit /etc/default/grub
Step 3: Find a line which says GRUB_DEFAULT=0.

All the entries in the GRUB menu are zero-indexed. This means, if there are 'N' entries in the GRUB menu, the very first entry is indexed as 0 (Zero) and the last one is indexed as 'N-1'.

Step 4: Now, our aim is to make 'Windows 7', which is listed at 5th position and hence having index 4, as the default boot entry. So, edit the same line to that it reads as GRUB_DEFAULT=4.

Step 5: For the changes made above to be implemented, run the following command:

sudo update-grub
And you're done !!

Note: This method will not change the order of the entries in the GRUB menu, but it would certainly boot the selected operating system.

Credits: Santosh Patil, IIT Bombay.


3 comments:

  1. Spot on tutorial for a quick modification. You could also use a little gui tool to manage grub: http://youtu.be/_gaImxC-grU

    ReplyDelete
  2. Thank you, was easy to follow and complete...

    ReplyDelete