LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to repair grub2 in MBR? win7/10.10 dual boot. (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-repair-grub2-in-mbr-win7-10-10-dual-boot-852236/)

Nizzok 12-24-2010 01:13 PM

How to repair grub2 in MBR? win7/10.10 dual boot.
 
Hi everyone, I apologize for re-posting what seems to be a common problem. I have a win7/10.10 dual-boot set up, more or less following the lifehacker.com tutorial (I know, I know). I had to reinstall windows, and its taken over the MBR so that only win7 boots now. My shared drive and the ubuntu filesystem are still there, I just can't get to them without a boot cd. So, I tried to follow the tutorials, which all basically say to reinstall grub or grub2. I tried one method, but ubuntu told me that installing grub2 anywhere but the MBR was a bad idea. Ok...so how do I do this so that ubuntu and win7 stay happy, but I get my grub menu back? Thanks in advance.

EDDY1 12-24-2010 01:24 PM

Have you tried
"sudo os-prober"
and
"sudo update-grub"
?

Is your ubuntu desktop or server edition?

ronlau9 12-24-2010 02:01 PM

You have reinstalled Win 7 , so Grub is gone I assume .
So you do not have a other option than reinstalling GRUB .
After that if windows does not appear run the command susdo update-grub
If windows 7 is capable of booting UBUNTU than you can install GRUB on the root partition UBUNTU and let WIndows do the booting .
But do not ask me how , I do not use windows,.

imagine_me2 12-25-2010 07:09 AM

boot ur ubuntu cd/dvd then select the rescue mode (there should be something like that)..

if the disk image is mounted under some other path then

#chroot "path" eg. #chroot /mnt/sysimage

#grub

grub> root (hdX,Y).... this is where ur linux is (hd0,0) for 1st part. (hd0,1) for 2nd part and so on

grub> setup (hdX) ..... usually (hd0)

exit and reboot

Snark1994 12-25-2010 08:47 AM

Quote:

Originally Posted by Nizzok (Post 4202259)
I tried one method, but ubuntu told me that installing grub2 anywhere but the MBR was a bad idea. Ok...so how do I do this so that ubuntu and win7 stay happy, but I get my grub menu back? Thanks in advance.

You probably tried
Code:

grub-install /dev/sda3
rather than
Code:

grub-install /dev/sda
Obviously, I've missed out the rest of the commands and the partition may be wrong, but basically you want to be installing onto the drive, "/dev/sda" not a partition, "/dev/sdaX"

Nizzok 12-25-2010 05:12 PM

Hi all,

Thanks for your responses. I've tried a lot different tutorials, and I'm not sure what I'm doing wrong.

Here are the results of os-prober, and just trying to update grub.
Code:

ubuntu@ubuntu:~$ sudo os-prober
/dev/sda1:Windows 7 (loader):Windows:chain
/dev/sda3:Ubuntu 10.10 (10.10):Ubuntu:linux
ubuntu@ubuntu:~$ sudo update-grub
/usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?).

and for reference here's the results of fdisk -l
Code:

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d7d9e

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          13      102400    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2              13        4279    34267136    7  HPFS/NTFS
/dev/sda3            4280        7834    28555537+  83  Linux
/dev/sda4            7836      19457    93353715    7  HPFS/NTFS

So, I thought it was because I hadn't mounted the drive, but even after having mounted the drive, it still doesn't work

Code:

sudo mount /dev/sda
mount: can't find /dev/sda in /etc/fstab or /etc/mtab
ubuntu@ubuntu:~$ sudo mount /dev/sda /mnt
mount: /dev/sda already mounted or /mnt busy
ubuntu@ubuntu:~$ sudo grub-install /dev/sda
/usr/sbin/grub-probe: error: cannot find a device for /boot/grub (is /dev mounted?).
No path or device is specified.
Try `/usr/sbin/grub-probe --help' for more information.
Auto-detection of a filesystem module failed.
Please specify the module with the option `--modules' explicitly.

Anyway, I'm not sure what to try to do next. Most of the tutorials on line don't apply to this system, or repeat some of the steps suggested above.

thanks again from the n00b

PS...only win7 loads...

Nizzok 12-25-2010 06:17 PM

Ok...
so...I ran this code successfully

sudo grub-install --root-directory=/mnt /dev/sda

this now borked the system completely as win7 now does not load either and I just get a black screen where the boot menu would have been

Nizzok 12-25-2010 08:30 PM

forget it, went nuclear and just re-did the linux install, all seems to be well. I really wanted to fix it though...

syg00 12-25-2010 09:05 PM

Have a read of this.
For future reference take particular note of section 12 - of the options presented, I prefer method 3, the chroot. Note that you mount partitions (or directories), not device(s).

smartgilli 01-11-2013 09:56 AM

Solution for newbie's
 
This might help someone who come across this thread ,,
ssatish.wordpress.com/2013/01/11/how-to-re-install-grub-2-in-mbr-from-ubuntu-live-disk/


All times are GMT -5. The time now is 10:41 AM.