Adding Windows to Grub

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
edes

Adding Windows to Grub

Post by edes »

I think I messed up somewhere in the installation of Linux Mint 10 and didn't choose dual boot. Is there any way I can make the Grub menu appear, and add Windows to it? Windows is still in the drive. I checked.
caf4926
Level 7
Level 7
Posts: 1916
Joined: Mon Mar 22, 2010 3:21 pm
Location: Argyll and Bute

Re: Adding Windows to Grub

Post by caf4926 »

Try this from the Linux terminal

Code: Select all

sudo update-grub
You can see from the output if it picks it up, but if you can't, just reboot and see win is there
Linux Mint 21.1 Cinnamon
edes

Re: Adding Windows to Grub

Post by edes »

Nope. This was the output:

$ sudo update-grub
[sudo] password for [user]:
Generating grub.cfg ...
Found Debian background: linuxmint.png
Found linux image: /boot/vmlinuz-2.6.35-22-generic
Found initrd image: /boot/initrd.img-2.6.35-22-generic
Found memtest86+ image: /boot/memtest86+.bin
done

Do I need to mount the partition before scanning? If so, how?
libssd
Level 4
Level 4
Posts: 288
Joined: Tue Jun 22, 2010 11:26 am

Re: Adding Windows to Grub

Post by libssd »

Check this out: https://help.ubuntu.com/community/Grub2

I'm currently running Linux only, and too lazy to switch drives to see what the menuentry section is on my partitioned drive, but if someone else can provide a copy of the menuentry stanza for Windows, should may be able to add it manually.
dawgdoc

Re: Adding Windows to Grub

Post by dawgdoc »

Here is my menuentry for WinXP on a tri-boot system.

Code: Select all

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows XP Media Center Edition (on /dev/sda1)" {
	insmod ntfs
	set root='(hd0,1)'
	search --no-floppy --fs-uuid --set 6fb6826e16780179
	drivemap -s (hd0) ${root}
	chainloader +1
}
Check the Creating the Custom Menu section of the Grub2 tutorial which libssd posted to see how to use this.
check to see if the following are correct on your system
  • /dev/sda1
    '(hd0,1)'
    6fb6826e16780179
the uuid # is bound to be different, that one is for my WinXP partition, you can check it with this terminal command

Code: Select all

blkid
You should not edit grub.cfg these tutorials tell you which files to edit to change grub.cfg
Also see THIS about the specific file 30_os-prober to accomplish what you want. The instructions are in section 3.
cwsnyder

Re: Adding Windows to Grub

Post by cwsnyder »

Also be aware if your Windows is Vista or 7, they use a Vista loader partition which they expect to find next to the MBR, and that is not compatible with GRUB 1.x or GRUB 2. Windows won't boot without it, and GRUB will be trashed, likely on your first Windows update, if you try to use GRUB to replace it.

Windows XP will work with GRUB, just not later versions. :evil:
User avatar
euthypro
Level 3
Level 3
Posts: 104
Joined: Wed Jan 17, 2007 12:10 pm
Location: Dumaguete, Philippines

Re: Adding Windows to Grub

Post by euthypro »

@cwsnyder,

Can you explain what you mean a little better? I dual-boot Linux and Windows 7 on two laptops, and I have no problems with Grub 2. Grub 2 is installed to the MBR, and no need to touch the small WIndows 7 system partition or replace it with Grub.

Angel
caf4926
Level 7
Level 7
Posts: 1916
Joined: Mon Mar 22, 2010 3:21 pm
Location: Argyll and Bute

Re: Adding Windows to Grub

Post by caf4926 »

edes wrote:I think I messed up somewhere in the installation of Linux Mint 10 and didn't choose dual boot. Is there any way I can make the Grub menu appear, and add Windows to it? Windows is still in the drive. I checked.
Perhaps you should post for us the result of:

Code: Select all

sudo fdisk -l

Just clear things up a little:
Grub 2 and grub-legacy both work with win7/vista
Linux Mint 21.1 Cinnamon
oobetimer

Re: Adding Windows to Grub

Post by oobetimer »

edes wrote:I think I messed up somewhere in the installation of Linux Mint 10 and didn't choose dual boot. Is there any way I can make the Grub menu appear, and add Windows to it? Windows is still in the drive. I checked.
Terminal commands

sudo os-prober

sudo update-grub
cwsnyder

Re: Adding Windows to Grub

Post by cwsnyder »

Maybe they have fixed GRUB since I used it last, but with Windows XP or the Windows Vista boot loader, GRUB normally installs in the MBR and (if installed correctly) points to the Windows installation.

My Windows XP install (not OEM, an eMachines restore disk installation) has failed to boot after a Windows update because it no longer the first partition, and doesn't 'own' the MBR. Any 'fix' required either Windows re-installation, which overwrote GRUB, or Windows fixes which did the same.

I have had the same problems with Windows 7, which uses the Windows Vista boot loader.

I have actually given up on dual-booting on the same drive because of those problems and installed a second drive for my Linux installation, selecting either my Windows HDD or my Linux HDD from BIOS when I change systems. I got tired of fixing GRUB after a Windows re-install or a serious update. It does mean that my Windows drive is sdb when I boot into Linux, but it is the same sdb each time.

When I was actively using Windows in parallel with Linux, re-installing Windows was something I expected to have to do about once a year when something was corrupted to the point it would no longer boot.

The curious thing is that my Linux GRUB discovers and points to the boot partition of Windows 7 and can be selected to go to Windows 7. When I try to boot into Windows XP from Linux, it complains that XP is not the first boot disk and freezes up, requiring a reboot.

My system has been working this way since late 2008 with few problems, so I am unlikely to change the setup, having gone from Ubuntu 8.10, 9.04, 9.10, #! 9.04 (interim when I found out neither Ubuntu 10.04 nor 10.10 live disks would work on my system without rework which I don't have the time or resources to fix), to Linux Mint Debian now. I actually quad-boot with Windows XP/7 on a 200G PATA and a 500G SATA with my primary Linux partitions (for daily use and experimentation) and Debian Lenny as my secondary (stable and recovery install). All on one eMachines T5212 Intel Pentium D805 processor, 2G RAM. nVidia 6200 video, system.
User avatar
euthypro
Level 3
Level 3
Posts: 104
Joined: Wed Jan 17, 2007 12:10 pm
Location: Dumaguete, Philippines

Re: Adding Windows to Grub

Post by euthypro »

I've read about certain WIndows 7 apps, especially recovery tools by the PC makers, (like Dell DataSafe) either trying to restore the MBR or writing to a section which will trash Grub. Some info here:

http://www.pctechs.org/?p=34264

With XP, I've had no problems. I still have the original OEM install of XP running on this laptop after 4 years. I have gone from Mint 2 to Mint 9, resized partitions a couple of times, and XP keeps soldiering on, running like new. (Here's where I knock on wood. :D ) I even have a free Vista upgrade, which I never installed. Didn't want to screw up a good thing. XP doesn't get much use anymore, but it's still there.

My experience with Windows 7 is much shorter, only about 3 months on my wife's laptops, so time will have to tell. So far dual-booting works flawlessly, letting Grub do the work. Since they are laptops, I can't do multiple hard drives, but I have taken note of alternatives, just in case.

Angel
caf4926
Level 7
Level 7
Posts: 1916
Joined: Mon Mar 22, 2010 3:21 pm
Location: Argyll and Bute

Re: Adding Windows to Grub

Post by caf4926 »

Only issues I have ever come across
1. as mentioned by @euthypro
2. Vista service pack updates couldn't install where grub exists (work around: restore mbr, install service pack, re-install grub)
Linux Mint 21.1 Cinnamon
breaker

Re: Adding Windows to Grub

Post by breaker »

@edes If

Code: Select all

sudo fdisk -l
doesn't reveal anything, please download and run the Boot Info Script and post the body of the generated RESULTS.TXT into the body of a forum post (perhaps in code tags), which will provide us with detailed boot information.

How to use it: http://ubuntuforums.org/showthread.php?t=1291280 http://bootinfoscript.sourceforge.net/
Where to get it: http://sourceforge.net/projects/bootinfoscript/

Thanks
cwsnyder

Re: Adding Windows to Grub

Post by cwsnyder »

@euthypro
The comments to the article you linked to finally explained why I have been having problems from the beginning with my Windows XP install:
the manufacturer's (eMachines) restore disks use PC Angel software which writes to the same area GRUB uses. That is probably also why I couldn't use VMware's utility to convert my XP install to a virtual machine, which is why I still have an XP partition after using Linux for almost 3 years (I still have a Visioneer USB flatbed scanner which only works under XP).
nmumbach

Re: Adding Windows to Grub

Post by nmumbach »

Long Story ... maybe it will help someone else in similar situation. :)
-started with Win7pro, added WinXP, added LMDE about a year ago
-had problems with sluggish performance, even after a fresh wipe and re-load; MB diags passed, Memtest86 passed, WD Disk Diagnostics passed, EVENTUALLY. Slower than predicted.
-reformatted, tried installing Mint xfce rather than LMDE Cinnamon, for perhaps better VirtualBox and/or VmWare success or even WINE, which has never provided me with any Windows apps (I'm running mostly boring old DOS/Windows games, rather than modern RPGs that PlayOnLinux offers).
-install failed, disk problems. Replaced WD hard drive with new Hitachi, hopefully better reliability.
-installed Mint 17.1 with xfce, manual partitioning, intentionally over-sized.
/boot - 512MB ext2
/swap - 16GB swap
/root - 40GB ext4
/tmp - 20GB ext4
/var - 20GB ext4
/home - huge ext4
/winXP - 20GB ntfs
/win7 - 20GB ntfs
-Mint install succeeds and boots
-try to install WinXp and/or Win7, which fail despite the NTFS partitions... I apparently left no recognizable boot space for them.
-use gparted live to re-size and move /boot to the right, with 100MB empty space preceding, then format the 100MB space to FAT32
-try to load Win7, fails; try to load WinXP, succeeds; try Win7 again, succeeds. Do Win7 updates, mostly succeeds. Reboot.
-No Linux, No WinXP, auto boot into Win7. Run BootRepair acquired from SourceForge, reboot, find Linux Mint, no Windows.
-run BootRepair trying different options, no joy. Still only Linux Mint.
-Search for help on adding windows to grub on linux mint, found this thread.
-saw the suggestion to "sudo os-prober" and "sudo update-grub" posted by oobetimer, and tried it.
-BANG! success! :D Thank you oobetimer.
User avatar
karlchen
Level 23
Level 23
Posts: 18228
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: Adding Windows to Grub

Post by karlchen »

<Moderator on>
Hello, nmumbach,
thank you very much for saying thank you to oobetimer. Yet, this thread had been resting in peace for more than 4 years. So in order to prevent its rest being disturbed once more, it will be locked now.
Cheers,
Karl
<Moderator /off>
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 792 days now.
Lifeline
Locked

Return to “Installation & Boot”