20

I've been reading a lot about dual-booting, and it seems as easy as loading Windows and then loading Linux with GRUB, but everybody says that Windows loves to trash GRUB when it gets the opportunity. What are some steps I can take to prevent this from happening (other than using Windows' bootloader, I want to keep this as simple as possible)?

19

Windows will overwrite the boot sector whenever you install it, upgrade it to a new version, or use tools like bootrec /fixmbr, bootrec /fixboot, or the older fdisk /mbr. In general, install Windows first, then Linux. The boot sector will stay put until you do one of the things above. (And perhaps there are also other ways to write onto the MBR.) But, if you lose GRUB, it is easily restored:

  • Boot from a live CD (CD/DVD or flash drive).
  • Become root or use sudo with commands below.
  • List the available partitions if needed: fdisk -l
  • Windows will almost certainly exist on /dev/sda1: mount /dev/sda1 /mnt
  • Reinstall GRUB in the MBR: grub-install --root-directory=/mnt/ /dev/sda
  • Reboot: shutdown -r now
  • Restore the GRUB menu: update-grub

You could also install 100% Unix, Linux, or BSD and simply run Windows in a virtual machine if the computer is strong enough for that.

Also: your computer's BIOS may have an option to protect the boot sector.

| improve this answer | |
  • By upgrading, do you mean Windows 7 to Windows 8 or just running Windows Update? – Nathan2055 Mar 20 '13 at 18:07
  • 1
    @Nathan2055 Yes, like 7 to 8... new, higher versions of Windows. Windows Update will not affect the MBR. – Christopher Mar 20 '13 at 18:08
  • I thought so. The good thing is I doubt I will be messing with the MBR under Windows, and there is no way I am going to Windows 8 after reading this. – Nathan2055 Mar 20 '13 at 18:13
  • 1
    As an alternative, you can try to configure the windows bootloader to chainload to grub: oreillynet.com/pub/h/2337 A little more involved and may be too much work for too little effect, but doing it that way makes it so if Windows does overwrite the bootloader, you'll still be able to boot into Linux. – Bratchley Mar 21 '13 at 12:46
  • @JoelDavis: Yeah, I've read several tutorials on doing that, but for someone who has absolutely no experience even loading GRUB and the fact that I don't think Windows will give me trouble, considering I don't want to upgrade, I think I will go with a vanilla GRUB setup and not mess with the bootloader. – Nathan2055 Mar 21 '13 at 14:51
4

I think I will go with a vanilla GRUB setup and not mess with the bootloader.

If you use any form of grub, you are messing with the boot loader. GRUB stands for "grand unified bootloader". And there are two versions -- grub v1 adn grub v2. All modern linux systems use grub2 automatically. If you install any linux system, grub is the default bootloader unless you specifically go with LILO, which I would not suggest.

I personally have a dual boot system with xp and Wheezy. I keep xp from over writing grub by disabling "windows restore" option.

Before I disabled the restore option, I would have to fix grub at least once a week as windows bootloader kept overwriting grub.

I am fixing to install windows 8 on an external hard drive through a usb port. I am hoping this goes without a hitch and doesn't mess with my mbr.

| improve this answer | |
  • 1
    disabling the windows restore option seems to have fixed this issue for me. – DrCord Sep 7 '16 at 1:42
3

A solution I found somewhere online (unix.stackexchange.com) involves deactivating windows boot manager. Get into Linux (either the original install, if you can or live CD/DVD) and run this command:

efibootmgr

Note that this method will only work if Linux has been installed in UEFI mode, so you'll get an error if Linux has been installed in Legacy mode. If you installed it in UEFI mode, you'll get some info and a list. You'll notice Windows boot loader/manager and Linux somewhere in the list. It's likely that Windows will have higher priority (boot order is above the list).

There are also stars* beside some, if not all, of the entries, marking them active.

Look at the 4 digit boot number next to Windows entry and run

sudo efibootmgr --bootnum #### --inactive

This will deactivate Windows entry. Also, make sure that now deactivated Windows has higher priority if it doesn't already:

sudo efibootmgr --bootorder ####,$$$$,&&&&,%%%%

where #### is Windows boot number.

If you reboot now, you'll boot to grub, if the Linux option is enabled with the highest priority.

Note that Windows doesn't seem to recognize that it's been deactivated, so this will not get reverted by booting into Windows or updating it.

I participated in a local Linux installfest where we install Linux for interested people, most often as a secondary OS next to Windows. I've yet to see this method fail, and I've tried it on several distros (mostly Ubuntu and Mint) and several vendors (Asus, Acer, HP, Lenovo).

| improve this answer | |
2

This is a workaround I use, it works with Windows updates with no intervention required: Rename your EFI/Microsoft in EFI/Microsomething Replace Windows Boot Path in grub.cfg to EFI/Microsomething/bootmfgw.efi Like this:

menuentry "Microsoft Windows UEFI-GPT" {
    insmod part_gpt
    insmod fat
    insmod search_fs_uuid
    insmod chain
    search --fs-uuid --set=root <PROVIDE YOUR EFI DRIVE UUID>
    chainloader /EFI/Microsomething/Boot/bootmgfw.efi
}
| improve this answer | |
1

Just open gparted , right click the partition that has Grub in it, go to manage flags and mark boot.

| improve this answer | |
  • 2
    This may work if the Windows install merely changed the boot partition. In my case The Windows 8.1 install overwrote the MBR, requiring Christopher's grub-install solution. – Nathan Kidd Nov 1 '16 at 13:49
0

Windows 10 overwrites GRUB 2 when you change the text color, size, font, or menu entry titles.

There are two ways to solve this.

  1. You could install Linux in Legacy Mode (BIOS Settings > Boot > Legacy Support + Legacy First).

  2. You could turn OFF Windows restore (a.k.a. System Protection) (Control Panel > System & Security > System > System Protection > Configure > Disable).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.