SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2010-08-03 03:44:22

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,462
Website

If ubuntu overwrites your mbr (Grub 2)

A minor annoyance with a simple fix - I'm posting it in case it saves someone from having to use something more powerful and dangerous like a live disk.

I've got Ubuntu on a different partition from Statler, and an update the other day from Karmic to Lucid ended with the Ubuntu version of the Grub2 menu written onto my Master Boot Record. It's no big deal - the Crunchbang entry is still there, but it's no longer the default choice and the Statler "powered by Debian" splash image is missing. Googling around brought up lots of solutions involving booting from a live disk and reinstalling Grub, but Ubuntu had rewritten the mbr from a normal session and Statler's Grub was in perfect working order so I figured Crunchbang ought to be able to reclaim the mbr in the same way. Finally found it.

First run

sudo fdisk -l

to make sure of the name of the drive the mbr should be on. For a lot of people it will be /dev/sda but check anyway.

Now do this:

sudo grub-setup /dev/xxx

where xxx is replaced with your drive. That will rewrite your mbr. Don't add a partition number like /dev/sda1, you want the whole drive.

That's it. It ought to work if you've had your mbr overwritten by some other distro while hopping, as long as you can still boot into Crunchbang and as long as there's nothing wrong with your Crunchbang Grub setup. Don't try to fix a broken Grub this way!


John
--------------------
( a boring Japan blog , and idle twitterings )

Offline

Be excellent to each other!

#2 2010-09-02 23:30:12

Matt3223
Member
Registered: 2010-01-22
Posts: 29

Re: If ubuntu overwrites your mbr (Grub 2)

so would this work in reverse? I've got a Teo netbook with ubuntu lucid installed on it. The family has finally gotten used to using ubuntu full time. So of course I decide it's time to give Statler a try! smile But, due to an excess amount of ignorance, I let the Statler install put grub to the mbr.

I'd like ubuntu to have primary control so as not to confuse the family.

Would running the following while booted into ubuntu put things back into ubuntu's hands you think?

sudo grub-setup /dev/xxx

Offline

#3 2010-09-03 05:41:32

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,462
Website

Re: If ubuntu overwrites your mbr (Grub 2)

It ought to work under any OS that's using grub 2 (which Lucid is). I have no idea if 'grub-setup' exists with grub 1, or if its behaviour is the same.


John
--------------------
( a boring Japan blog , and idle twitterings )

Offline

#4 2010-09-03 13:46:17

hhh
Caught in the Vortex
From: Port Salerno
Registered: 2010-08-04
Posts: 1,479

Re: If ubuntu overwrites your mbr (Grub 2)

I have three Linux partitions and XP all on one drive. The last partition is a "testing" one. When I install a new OS, I rarely want the testing partition to control Grub. I haven't used the grub-setup command, I use grub-install. So for me, update-grub and then

grub-install /dev/sda

Offline

#5 2010-09-03 16:32:56

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,462
Website

Re: If ubuntu overwrites your mbr (Grub 2)

grub-install is a more sophisticated command, which does some testing and checking and redoes a lot of the grub installation.
grub-setup is a simple process of writing onto the disk. The end result may well be the same in most cases, but on the principle of "if it ain't broke, don't fix it" I'd prefer grub-setup if the grub installation is basically OK.

http://members.iinet.net/~herman546/p20 … mands.html
http://grub.enbug.org/Manual#head-4bf1d … 3310ca8ceb


John
--------------------
( a boring Japan blog , and idle twitterings )

Offline

#6 2010-09-03 18:38:03

hhh
Caught in the Vortex
From: Port Salerno
Registered: 2010-08-04
Posts: 1,479

Re: If ubuntu overwrites your mbr (Grub 2)

Thanks for the info, John!

Offline

#7 2010-09-04 10:26:24

Matt3223
Member
Registered: 2010-01-22
Posts: 29

Re: If ubuntu overwrites your mbr (Grub 2)

Things worked like a champ for me.

I did sudo update-grub and then grub-setup /dev/sda in my case.

Things are all lined up with ubuntu as primary once again. Now when grub pops up I can just tell the family to close there eyes, don't be scared, and wait about ten seconds.

Thanks all. \o

Offline

#8 2010-09-14 15:32:32

Iskander
#! Member
From: Srbija
Registered: 2010-04-06
Posts: 58

Re: If ubuntu overwrites your mbr (Grub 2)

Very useful tip, thanks. I had Mint on a partition rearrange things, this fixes it.

Offline

#9 2010-09-14 15:43:53

boromeus
#! Junkie
Registered: 2010-09-12
Posts: 254

Re: If ubuntu overwrites your mbr (Grub 2)

Matt3223 wrote:

Things worked like a champ for me.

I did sudo update-grub and then grub-setup /dev/sda in my case.

Things are all lined up with ubuntu as primary once again. Now when grub pops up I can just tell the family to close there eyes, don't be scared, and wait about ten seconds.

Thanks all. \o

You could maybe edit that config file a bit so that they woudln't have to wait ten seconds but five or three. (Whenever you want to boot #!, you can easily hit the down key in 5 sec.)

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo