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?
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?
sudo nano /etc/grub.d/40_custom
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.
sudo update-grub
Note If you are not careful these operations can mess up your computer.
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
.
–
Jun 28 '17 at 10:10
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
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.
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.
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_custom
grub 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
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 :
or by typing 'boot-repair' in a terminal