Restoring dual boot

enemje

Distinguished
Sep 13, 2011
4
0
18,510
I have a dual boot on my Asus netbook -Win 7 and Ubuntu 11.04. But then I went and fiddled with the partitions to free up some space. The system failed to boot up. I restored Grub with Rescatux but Win 7 is missing from the list. Using the repair function of the Win 7 DVD I could restore Win 7 but Grub disappeared. (On booting up the screen shows MBR at the top left corner and then goes to Win 7). Is there anyway to restore Grub with Ubuntu and Win 7, other than a reinstall?
 

bmouring

Distinguished
May 6, 2006
1,215
0
19,360
[strike]Or, you could try to manually fix the issue.

Steps:
1) Take note of the partition# of the Windows install. For this example, I'll use /dev/sda2
2) Add a file to /etc/grub.d/, call it something like 39_WindowsVista (these files are examined in order of ascending prefixes)
3) File contents should be
#!/bin/sh
exec tail -n +3 $0
menuentry 'Windows 7' {
set root='(hd0,2)'
chainloader +1
}
hd0 == the first disk brought up, i.e. /dev/sda, (hd0,2) means first disk, second partition (yes, they mix 0-based and 1-based counting, gotta love it)
4) Run update-grub
5) Double-check that the entry shows up in /boot/grub/grub.cfg

Any of these steps that complain about permissions, run them as root (add sudo to the front)

Edit: I really kinda miss the old way of grub, this new stuff seems overly complicated[/strike]

I'd forgotten about /etc/grub.d/30_os-prober, thanks skittle
 

enemje

Distinguished
Sep 13, 2011
4
0
18,510
I've already tried 'sudo update-grub' but that didn't solve the problem.

BTW, after restoring Win 7 I ran Rescatux and tried to reinstall grub. Restarting lead to a screen with the grub> .

Went back to Rescatux and tried to use the file checking option. Only the Linux partition is detected. Re-running file check after mounting all the Windows partitions (I can do that and access files from Rescatux or an Ubuntu live CD) gave the same result. Restoring Windows through Rescatux and restarting leads to a windows message asking repair using the install CD, which I did.

So back to square one!
 

enemje

Distinguished
Sep 13, 2011
4
0
18,510


Okay, will try that out. Should I add the last line in that post
I'd forgotten about /etc/grub.d/30_os-prober
If so, where?
 

raz1313

Honorable
Jul 18, 2013
1
0
10,510
Hi All,

Just a newbie here, but I had the following:
single boot Win XP. Then, blue-screen of death no boot up.
I installed Opensuse Linux to see if I could rescue the system.
Figured it was a master boot record problem. Tried everything but did not have a Win XP resuce CD.
I got an XP install CD from a friend, brought up the rescue screen, did the "fixmbr" command that's supposed to work, It did not.
Then, trid a bunch of grub solutions. No joy.
Finally, with Gparted (free/ semi free) boot CD, I did a disk analysis and my disk was definitely bad.
So, rescued files using Gparted by copying to other drives.
Then, since I was buy a new RAM drive, I also got Windows 7 Home.
Installed Windows 7, but lost my Linux install.
Rebooted with Opensuse install CD, then lost the WIndows boot.
Look here (Tom's) for a solution. Unfurtunately, Opensuse does not use "update-grub" (at least not with the new grub2 loader).
Found this command elsewhere: (must be super user)
grub2-mkconfig -o /boot/grub2/grub.cfg

then rebooted.
My dboot is now back!!

cheers.

rebooted