3

I am desperate to add Windows 7 to grub. I have tried sudo update-grub, I have run sudo os-prober, but I can't seem to get windows to be added to grub.

Can someone please explain how to manually add windows 7 to my grub?

  • Please stop starting new questions for the same Problem. Please provide the requested information in your other question. – Pabi May 4 '15 at 21:10
  • I did, but no one answered the other questions, so I am asking a specific question: how do I manually add windows 7 to grub. – Darby Gallagher May 4 '15 at 21:18
  • I did answer suggesting boot-repair and posting its resultst. Editing grub files is not recommended, it can break your system. – Pabi May 4 '15 at 21:22
  • No worries. I have had no system for my kids for days now so Linux has to go as they need a working computer. Thanks for your help – Darby Gallagher May 4 '15 at 21:29
5
  1. Open a terminal and type:

sudo nano /etc/grub.d/40_custom

  1. Add the following line:
menuentry "Windows 7 (loader) (on /dev/sda1)" {
insmod part_msdos
insmod ntfs
set root='(hd0,msdos1)'
chainloader +1
}

by appropriately modifying the location of windows 7 in your computer.

  1. Run sudo update-grub

Note If you are not careful these operations can mess up your computer.

  • I think this is the only answer at this moment that really addresses the question of adding the Windows boot entry manually. But just adding a Windows entry to the grub list will not fix problems with the Windows MBR file that may be present in the first place that may stop Windows from booting. - To fix those, run boot-repair from a live session and chose restore MBR . If that leads to directly booting to Windows, run boot-repair in a live session again and chose 'Automatic repair'. Then, in Ubuntu sudo update-grub. – user47206 Jun 28 '17 at 10:10
3

grub-customizer helped me. It auto-detected Windows 7 for me and I was able to add it and change position and title in the menu.

sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update 
sudo apt-get install grub-customizer
2

Before you attempt anything further, I suggest you go to a terminal by pressing Ctrl+Alt+T and enter the following:

sudo update-grub2

This should scan your system for all existing OS's and add them to the Grub menu (See Note¹)

Next download and run boot-repair

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install -y boot-repair && boot-repair

The program should launch automatically or you can open it from the Apps list.

If none of the above works, see Note² to manually add a Windows entry to the GRUB menu.

Source


Note¹:

If you have multiple Windows systems installed on the same hard drive, you will likely only see one Windows system in the resulting GRUB menu when it boots up. This is because that option is referring to the Windows boot loader which resides on the boot sector of the hard drive and/or at the beginning of each Windows partition. When that option is invoked it will run the Windows boot manager which will allow you to select your other Windows environments.

You should understand there's a difference between a boot manager and a boot loader. For the most part both GRUB and the Windows Boot Manager (BOOTMGR) perform both duties. However Windows Boot Manager cannot load a Linux environment and vice versa, GRUB can't actually load a Windows environment.

Hence if you're using GRUB as your primary boot manager and you select a Windows environment at boot-up, it will load BOOTMGR as the boot loader for any Windows system you have installed and will be taken to a BOOTMGR screen which allows you to select either Windows 10 or Windows 7 from the list.

Similarly if you instead are using BOOTMGR as the primary (using bcdedit), when you select the Linux distribution from the menu it will not boot directly into the system: it will just run GRUB (which should then reside at the beginning of the root partition instead of the boot sector of the HD) and allow you to select the desired system from there.

Note²:

If none of the above works you can manually add windows entry. This solution provides a proper entry in the grub2 menu to boot into Windows 10.
A requisite word of caution, editing the GRUB menu is not recommended because it can break your system. But if you need to do it, here's how.

First check on which disk and partition is the Windows EFI boot:

parted --list

Now find the UUID of the partition. E.g:

blkid /dev/sda2

returns:

/dev/sda2: UUID="1AC3-9984" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="dda518e7-aa6d-4944-9a59-e459f0f7944e"

Then you can edit the /etc/grub.d/40_customgrub file to add the lines which will help you to boot into your Windows system

sudo gedit /etc/grub.d/40_custom

Add the following modified according to your configuration:

menuentry 'Windows 10 (on /dev/sda2)' --class windows --class os $menuentry_id_option 'osprober-efi-1AC$
        insmod part_gpt
        insmod ntfs
        insmod search_fs_uuid
        insmod chain

        set root='hd0,gpt2'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-barem$
        else
          search --no-floppy --fs-uuid --set=root 1AC3-9984
        fi
        chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}

note that entry is configured to boot from the 2nd partition gpt2 of the 1st hard drive hd0 or ahci0. If you are working on legacy, then replace all gpt with msdos

Now you can update the grub file

upgrade-grub

Restart you system to see the GRUB menu

Source

1

Better use Boot Repair

  • either from an Ubuntu live-session (boot your computer on a Ubuntu live-CD or live-USB then choose "Try Ubuntu") or from your installed Ubuntu session (if you can access it)

  • connect to the Internet

  • open a new Terminal, then type the following commands (press Enter after each line):

    sudo add-apt-repository ppa:yannubuntu/boot-repair
    sudo apt-get update
    sudo apt-get install -y boot-repair && boot-repair

Recommended repair
1. launch Boot-Repair from either :

  • the Dash (the Ubuntu logo at the top-left of the screen)
  • or by typing 'boot-repair' in a terminal

    1. Then click the "Recommended repair" button. When repair is finished, note the URL (paste.ubuntu.com/XXXXX) that appeared on a paper, then reboot and check if you recovered access to your OSs.
    2. If the repair did not succeed, indicate the URL to people who help you by email or forum.

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.