Skip to content

Setting up GRUB2 for dual-booting with Windows

June 21, 2011

There are a lot of guides and posts about doing this and in general this should be pretty automated. Here are just a couple of tweaks that I like to add to the default GRUB2 setup. These tweaks will persist through GRUB updates.

Note that after changing any of these options, you will need to run
sudo update-grub
for changes to take effect.

  1. I don’t like that Windows by default appears at the bottom of the list in Grub. The best way to alter positioning of Windows menu entry in Grub is by editing the files in the /etc/grub.d/ directory. During grub initial setup and update, grub will execute the update-grub script. This script, in turn, will go through the /etc/grub.d/ directory and execute each script in the alphabetical order. So the numerical prefix of each script tells the order in which they are executed.By default windows partitions are detected by the 30_os-prober script. So the easiest solution is to give this script a lower number prefix, by renaming it to, for instance, 08_os-prober (if you want it to appear before the linux entries, which are 10_linux) or 15_os-prober (if you want them to appear after linux entries).

    Personally, I want the Windows entry to simply state “Windows 7”. For this, you will have to create a new custom script that will generate a windows menu entry. The best way to do this is by copying the 40_custom script to a new file, for instance 08_windows. Now, you will have to copy the automatically generated windows menu entry from /boot/grub/grub.cfg and place it in the 08_windows script file, right under the comments. You can now rename the label on the first line to anything you want. It should look like this:

    menuentry "Windows 7 Professional" --class windows --class os {
    	insmod part_msdos
    	insmod ntfs
    	set root='(/dev/sda,msdos2)'
    	search --no-floppy --fs-uuid --set=root 6AB615090161313C
    	chainloader +1

    Finally, you will have to disable the os-prober script from generating duplicate windows entries. This is done in the /etc/default/grub file. You will need to add the following line (or edit the option if it is already present):

    The down side to disabling os-prober and having a custom entry is that the menu entry will not be updated if you remove windows or change the partition that it resides on; however, you can always re-enable os-prober and update your windows menu entry manually through the same process.

  2. It is annoying to always have to remember to select the correct OS to boot to when all you want to do is restart the computer. Fortunately, GRUB2 can remember the last menu entry that you selected and chose it for you automatically the next time you reboot (it will only do this for OS entries and will not remember Memtest entries). This is enabled in /etc/default/grub file by setting the following options (these options should already be present, but perhaps not set to the right values):

    Don’t put quotes around the values.

    Note that savedefault option must be present in each of the menu entries for the selection to be remembered (see the menu entry code above). This is why memtest menu entries are not remembered upon reboot.

  3. I like to see all the steps that happen while Ubuntu is booting up or shutting down. To enable this verbose mode and disable the “fancy” Ubuntu loading screen, you simply need to omit the “quiet splash” flags from the grub menu entry. You can remove them persistently in /etc/default/grub file. The entries of interest are GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX. When update-grub script is run, it, by default, generates two entries for each kernel: default and recovery. The *_DEFAULT option applies only to the default entry and GRUB_CMDLINE_LINUX entry applies to all linux kernels. GRUB_CMDLINE_LINUX should have an empty string as its value. GRUB_CMDLINE_LINUX_DEFAULT should have “quiet splash” options, which is what you want to remove (leave the empty string).

Many more options to configure GRUB2 behavior can be found in the GRUB2 manual.

Remember to run sudo update-grub after changing the settings.


From → Linux

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: