Grub 2: Fixing the MBR with dual boot linux??

BigAl-sa

Executive Member
Joined
Dec 26, 2006
Messages
6,652
On my system I have a dual boot Ubuntu 10.04 and Debian Wheezy. Ubuntu is on the first partition and Wheezy on the second. The MBR is on the first. I installed Ubuntu first, then Debian, and the MBR went to Debian's /boot (sda2) as I wanted. Ubuntu then asked for a grub upgrade and since then the MBR points to Ubuntu's /boot (sda1).

Everything I've looked at up to now points to getting into a grub shell to fix it, but the grub command no longer exists with grub 2. Anyone have thoughts as to how to get the MBR to point to sda2 with grub 2?
 

Dean

Expert Member
Joined
Aug 19, 2005
Messages
2,709
On my system I have a dual boot Ubuntu 10.04 and Debian Wheezy. Ubuntu is on the first partition and Wheezy on the second. The MBR is on the first. I installed Ubuntu first, then Debian, and the MBR went to Debian's /boot (sda2) as I wanted. Ubuntu then asked for a grub upgrade and since then the MBR points to Ubuntu's /boot (sda1).

Everything I've looked at up to now points to getting into a grub shell to fix it, but the grub command no longer exists with grub 2. Anyone have thoughts as to how to get the MBR to point to sda2 with grub 2?

You could boot with your Ubuntu Disc (as a Live Session ie. "Try Ubuntu without changing my PC") and doing a grub update from within there..
 

milomak

Honorary Master
Joined
May 23, 2007
Messages
12,571
I assume though that while Ubuntu now holds grub, you are still able to boot into Debian. Assuming this is correct, boot into Debian. In a terminal as root run:

grub-install --recheck /dev/sda

if you do not have, a debian entry showing up. In Ubuntu, install os-prober - sudo aptitude install os-prober. I think it will automatically run after install. In case it doesn't, run sudo os-prober

Debian should now show in the Ubuntu grub menu, and you can follow my initial step.

When in Ubuntu, I would be interested in the output of aptitude why grub2. If your Debian grub loads Ubuntu directly without daisy chaining the Ubuntu grub, then there should be no need for grub in your Ubuntu install.

If you are wary of removing grub in Ubuntu, then you can just point it to the partition - grub-install --recheck /dev/sda1

as an aside, can you also post the output of mount. From both would be nice.
 

BigAl-sa

Executive Member
Joined
Dec 26, 2006
Messages
6,652
Thanks guys. Haven't had a chance to try anything yet as I killed the nvidia drivers, so spent most of yesterday pm trying to get the GUI back.


@Mick: On that site is rescatux which maybe the solution.

@Dean: I did try the Ubuntu live CD, but couldn't get it to do what I wanted.

@Milo: os-prober is installed in both. Debian is in the menu, but the grub.cfg being picked up is that from Ubuntu (the menus in the two grub.cfgs are different). Also, the reason for wanting to change it is that I hate the new Debian SpaceFun theme. Going through the Ubuntu grub ignores any changes that I make to the Debian grub. I will do your recheck as soon as I get back to that machine (running on my netbook at the mo). Thanks for your input.
 

BigAl-sa

Executive Member
Joined
Dec 26, 2006
Messages
6,652
If you are wary of removing grub in Ubuntu, then you can just point it to the partition - grub-install --recheck /dev/sda1

Output from this command:

/usr/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea..

:D
 

BigAl-sa

Executive Member
Joined
Dec 26, 2006
Messages
6,652
I assume though that while Ubuntu now holds grub, you are still able to boot into Debian. Assuming this is correct, boot into Debian. In a terminal as root run:

grub-install --recheck /dev/sda

Thanks Milo, this one did the trick running it from Debian.
 
Top