How do I add Windows 7 to GRUB 2?
The problem is that Windows 7 uses a 100MB system partition which holds the boot files. So you need to boot from it, not your Windows drive(which is called the boot partition).
menuentry 'Windows 7' {
set root='(hd0,0)'
chainloader +1
}
Note GRUB counts partitions from 0, so /dev/sda1 is (hd0,0), /dev/sda2 is (hd0,1).
Although, there seems to be a problem with boot info script
saying it can't mount the filesystem, this will most likely work.
Related videos on Youtube
user829876
Updated on September 18, 2022Comments
-
user829876 over 1 year
I am having trouble adding Windows 7 to my GRUB 2 boot menu. I know similar questions have been asked and answered on this site and others, but none of the answers seem to work for me.
My setup: Two hard drives, sda with a Win 7 installation and sdb with a Debian installation and GRUB2.
In my BIOS, I can choose which hard drive to boot from, and if I boot from the first hard drive Windows starts so I know that it is working. Now I want to add a menu item to GRUB to boot Windows.
I downloaded bootinfoscript and ran it, here is the
RESULTS.txt
:Boot Info Script 0.61 [1 April 2012] ============================= Boot Info Summary: =============================== => Windows is installed in the MBR of /dev/sda. => Grub2 (v1.99) is installed in the MBR of /dev/sdb and looks at sector 2048 of the same hard drive for core.img. core.img is at this location and looks for (,gpt2)/boot/grub on this drive. sda1: __________________________________________________________________________ File system: Boot sector type: Windows Vista/7: NTFS Boot sector info: Mounting failed: mount: unknown filesystem type '' sda2: __________________________________________________________________________ File system: ntfs Boot sector type: Windows Vista/7: NTFS Boot sector info: No errors found in the Boot Parameter Block. Operating System: Windows 7 Boot files: /Windows/System32/winload.exe sdb1: __________________________________________________________________________ File system: BIOS Boot partition Boot sector type: Grub2's core.img Boot sector info: sdb2: __________________________________________________________________________ File system: ext4 Boot sector type: - Boot sector info: Mounting failed: mount: unknown filesystem type '' mount: /dev/sdb2 already mounted or sdb2 busy sdb3: __________________________________________________________________________ File system: swap Boot sector type: - Boot sector info: ============================ Drive/Partition Info: ============================= Drive: sda _____________________________________________________________________ Disk /dev/sda: 256.1 GB, 256060514304 bytes 255 heads, 63 sectors/track, 31130 cylinders, total 500118192 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes Partition Boot Start Sector End Sector # of Sectors Id System /dev/sda1 * 2,048 206,847 204,800 7 NTFS / exFAT / HPFS /dev/sda2 206,848 500,115,455 499,908,608 7 NTFS / exFAT / HPFS Drive: sdb _____________________________________________________________________ Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes 255 heads, 63 sectors/track, 364801 cylinders, total 5860533168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes Partition Boot Start Sector End Sector # of Sectors Id System /dev/sdb1 1 4,294,967,295 4,294,967,295 ee GPT GUID Partition Table detected. Partition Start Sector End Sector # of Sectors System /dev/sdb1 2,048 4,095 2,048 BIOS Boot partition /dev/sdb2 4,096 2,605,768,703 2,605,764,608 Data partition (Windows/Linux) /dev/sdb3 2,605,768,704 2,639,306,751 33,538,048 Swap partition (Linux) "blkid" output: ________________________________________________________________ Device UUID TYPE LABEL /dev/sda2 DCA04533A0451584 ntfs /dev/sdb2 ea61c63c-0a93-44fb-894c-f652c28b67d0 ext4 /dev/sdb3 ca9c61ec-f99e-428c-bdf3-65fbbfc4b43b swap ================================ Mount points: ================================= Device Mount_Point Type Options /dev/disk/by-uuid/ea61c63c-0a93-44fb-894c-f652c28b67d0 / ext4 (rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered) /dev/sda2 /mnt/win fuseblk (ro,nosuid,nodev,noexec,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096) =============================== StdErr Messages: =============================== xz: (stdin): Compressed data is corrupt
OS-prober does not seem to be able to detect my Win7 installation. If I run
update-grub2
(which I believe in turn runs OS-prober) it will output:Generating grub.cfg ... Found background image: /usr/share/images/desktop-base/desktop-grub.png Found linux image: /boot/vmlinuz-3.2.0-4-amd64 Found initrd image: /boot/initrd.img-3.2.0-4-amd64 done
I have tried some variations on GRUB menu entries (by modifying
/etc/grub.d/40_custom
and then runningupdate-grub2
). Here are some of them:The first one is simple, inspired by (for instance) this link: http://technologytales.com/2010/11/21/manually-adding-an-entry-for-windows-7-to-an-ubuntu-grub2-menu/
menuentry 'Windows 7' { set root='(hd0,2)' chainloader +1 }
This will not boot, and results in the following output from GRUB:
Booting a command list error: invalid signature. Press any key to continue...
Then I tried this:
menuentry 'Windows 7' --class windows --class os { insmod part_msdos insmod ntfs set root='(hd0,2)' search --no-floppy --fs-uuid --set=root DCA04533A0451584 chainloader +1 }
which results in:
BOOTMGR is missing Press Ctrl+Alt+Del to restart
and then I tried:
menuentry 'Windows 7' --class windows --class os { insmod part_msdos insmod ntfs insmod ntldr set root='(hd0,2)' search --no-floppy --fs-uuid --set=root DCA04533A0451584 ntldr ($root)/Windows/System32/winload.exe }
which does not work either (goes to an empty screen with a blinking cursor).
I am really at a loss here. Any help would be greatly appreciated!
Update: I ran boot-repair-disk (as suggested by moses in comments) with default settings. It did not add a Win7 entry to the boot menu. Maybe it failed to detect the Win7 installation since it overwrote its MBR with GRUB. Here is a link to the boot-repair-disk log.
-
Admin over 10 yearsHave you tried simply running the automatic Boot-repair-disk? It scans all operating systems and rebuilds grub without the need to manually do it.
-
user829876 over 10 yearsThanks for the tip! I didn't know boot-repair-disk existed. I ran it with default settings but did not add any entry to GRUB's menu. Updating the question above with boot-repair log.
-