How do I set the bootloader so that in my dualboot with Windows 7/Ubuntu 11.04, Windows start up as standard instead of Ubuntu?
How do I set the bootloader so that in my dualboot with Windows 7/Ubuntu 11.04, Windows start up as standard instead of Ubuntu?
Customizing the
/etc/default/grub
fileThere are two ways of doing this using editing a grub file. These are described in the Ubuntu Community Documentation Grub2 page
The two ways are:
Finding the menuentry to set as the new default
To start we need to find out what we are booting or want to boot. Open a terminal with Ctrl+Alt+t and type in
You can see that the "saved" method can come in handy when booting multiple operating systems. Save the name of the entry you want e.g.
Windows NT/2000/XP (loader) (on /dev/sda1)
, we need it later.Editing the
/etc/default/grub
fileType in the terminal
and your password if asked. The nano editor will open.
A. Saved method - In my preferred way, I made the following changes from the standard grub file.
I changed the value of
GRUB_DEFAULT
tosaved
:I enabled the SAVEDEFAULT functionality by adding the following line:
B. Specific menuentry - In the way you are asking for
GRUB_DEFAULT
to the name of the Windows system you want to always boot. The name of the corresponding Grub menuentry can be found as described in the previous section.I wanted to have Window XP always set as default at boot, I would set
GRUB_DEFAULT
to"Windows NT/2000/XP (loader) (on /dev/sda1)"
:Note: Some versions of Ubuntu require single quote (') vice double quote (").
You could also set
GRUB_DEFAULT
to the line number in the menu entry list (with 0 being the first), but when the kernel in Ubuntu is updated grub adds the new kernel to the top of the list, you would have to change the number, since Windows is the last one in the menu entry list. You can see this in my menu entry list.Update the boot configuration
Now you have to run
to update the system generated
grub.cfg
file in the/boot/grub/
directory.Addendum
Notes on nano
nano
is especally easy to use in the terminal. Move around with the arrow keys. Type in you addtions, delete the unwanted.The
-B
or--backup
option backs up the previous version of it to the current filename suffixed with a~
. Very handy in case of the dreaded Fat pfinger effect.When you are through, Ctrl+o will allow you to save your edits by hitting Enter and Ctrl+x will close. These and other options are shown at the bottom of the terminal screen with the
^
indicating Ctrl.Notes about nano, sudoeditor and other editors
Some in the Ubuntu community suggest
sudoedit
instead ofnano
. I recommendnano
— which is the default sudoedit editor in later distributions of Ubuntu — instead ofsudoedit
, because the default can be overridden in non-obvious ways, unless you are an administrator.sudoedit
is safer in that it automatically saves a backup copy of the edited file, but the-B
command line option innano
does the same thing.nano
is more intuitive than editors likevi
oremacs
, which are very flexible but require learning a lot of commands, shortcuts or different modes.If you prefer not to use the
nano
editor and prefer the Gnome Text Editor, instead ofsudo nano -B
usegksu gedit
. I generally do this for large files, and/etc/default/grub
could easily be considered a large file. Thus type ingksu gedit /etc/default/grub
instead ofsudo nano -B /etc/default/grub
. Note that the Gnome text editor does not automatically make a backup!Notes on my grub file
I made some changes to grub for my personal needs. Such as the background picture of the moon launch. How to do these are discussed at the Ubuntu Community Documentation page on Grub2, recommended.
Good luck!
With a bit of command line trickery, you can get the default of grub to always be a particular grub entry - for example Windows - no matter when a new kernel is installed.
In a terminal type:
This will display all your grub entries - for example
Highlight the entry you want to default to - for example Windows 7 in the screen-shot. Right click and choose
copy
Type
Change the entry
to
i.e. paste the entry you want (including the quotes)
Save, then type
source
You need to edit the
/etc/default/grub
file to set Windows as your default OS.First Step. Determine the Windows OS' position in the grub menu. To do this, open a terminal by pressing
Ctrl+Alt+T
and type the following:This will list the grub menu entries. I'll use my grub menu as an example:
You will then select the Windows partition, in my case "Windows 7 (loader) (on /dev/sda1)" including the double quotes and copy it.
Second Step. Open the
/etc/default/grub
file. To do this, type the following on the terminal:It will open the /etc/default/grub file with gedit. Look for the
GRUB_DEFAULT=0
line and change it's value from 0 to the selected Windows menu entry by pasting it. .Alternatively, you can use an integer value specifying the index position of the Windows OS, take note that index starts counting at 0, so in my example, the Windows OS value would be 4, therefore you can also set
After which, you need to update grub by typing
You can follow this nitstorm answer here ,
You will have to add Grub-customizer through
Then launch it from dash , application lens.
the above menu will be different to yours, so choose wisely and select the Windows 7 entry and from the top Menu bar , select the ^ arrow to move it upward to have the top position , while booting.
For booting into Windows directly select the
preference
and reduce the boot-time to load windows.It can be done easily with a GUI tool called "Grub Customizer".
What is Grub Customizer?
Grub Customizer is a graphical interface to configure the grub2. The application allows the user to add, remove, freeze, rename and reorder boot menu items
How to install?
Hit Alt+Ctrl+T to open terminal and run following commands one by one:
How to use?
Remember that you can't move single entries out of their respective group like Ubuntu can't be moved out of Linux group.
Use startup manager, which you can start from the dash. There you can use the OS to start with in the dropdown menu.
Change the value of
GRUB_DEFAULT
in/etc/default/grub
to whatever windows is on grubs list of available operating systems when you boot. For example in my case I would have to change that line fromto
After that, run
sudo update-grub
.Identify the name of the Windows entry
On the GRUB, there should be an entry like
Windows 7 (loader) (/dev/sda1)
. We need to know what's that name on your machine, so open a Terminal and run the following command:The output should be something like this:
Look at the line we were talking about! In my machine, it is
Windows 8 (loader) (en /dev/sda1)
. Write the name of your entry somewhere, and now let's set is as the default.Setting the Windows entry as the default
That's easy!
First, open our configuration file with gedit (a text editor) as root, running this command:
Search for this line:
And modify the
0
with the name of your Windows entry. In my computer:Now just save the file, close gedit, and update grub.
Updating GRUB
Just run this command:
Now just restart, and the Windows entry should be highlighted as the default!
Grub-Customizer:
Is a very easy to use graphical GRUB2 settings manager. For now, it only allows you to edit the GRUB2 menu entries: reorder, rename or add/remove entries. It will also allow changes to background image and menu timeout. Since these are actually scripts which generate the boot.cfg file, Grub Customizer changes the actual script order and then generates a new boot.cfg so if you then run "sudo update-grub", your customization won't be overwritten.
From my experience, I noticed that it's not so easy to change boot priority for Win7/Ubuntu 11.04. Utility, like Startup Manager seems like isctrying to change the default boot system, yet nothing happens after restart (11.04 continue to boot by default). I such case I suggest Grub Customiser Grub Customised on WebUpd8, which works well with Grub2. I just removed all absolete boot options (there are many), leaving only 11.04 and Win7. And then changed a boot priority. Now, everything works well :)
Good luck.