LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Any way to repair grub in partition other than MBR. (https://www.linuxquestions.org/questions/linux-newbie-8/any-way-to-repair-grub-in-partition-other-than-mbr-705347/)

michalng 02-17-2009 08:17 AM

Any way to repair grub in partition other than MBR.
 
I have ubuntu installed in sda1 and ubuntu's grub is in mbr.
Ubuntu's grub will chainload any other distro's grub installed in their respective partition.

Just install Debian in sda2 and somehow Debian's grub is not installed.

Is there any way that I can install/repair Debian's grub into sda2 partition without affecting
- Ubuntu's grub (in mbr).
- Debian's installation (ie. without reinstalling Debian)

Thanks in advance for help.

CJS 02-17-2009 08:41 AM

Sure, you can install Grub to the boot sector of the Debian partition while you are in Ubuntu:
Code:

sudo grub
grub> root (hd0,1)
grub> setup (hd0,1)
grub> quit

Then you should be able to chain load Debian's Grub from your Ubuntu menu.lst. Let me know how that goes or if you run into problems.

alan_ri 02-17-2009 11:40 AM

Quote:

Originally Posted by CJS (Post 3446925)
Code:

sudo grub
grub> root (hd0,1)
grub> setup (hd0,1)
grub> quit


This would be wrong because there should be letter "s" instead of the letter "h",but anyway,I think that Debian's GRUB is already installed on the Debian's root partition,so all there has to be done is to open /boot/grub/menu.lst in Ubuntu and add an entry for Debian since the Debian was installed after Ubuntu and that's way Ubuntu didn't recognized Debian automagically.

CJS 02-17-2009 11:54 AM

Quote:

Originally Posted by alan_ri (Post 3447151)
This would be wrong because there should be letter "s" instead of the letter "h",but anyway,I think that Debian's GRUB is already installed on the Debian's root partition,so all there has to be done is to open /boot/grub/menu.lst in Ubuntu and add an entry for Debian since the Debian was installed after Ubuntu and that's way Ubuntu didn't recognized Debian automagically.

I would suggest that you check out the official Grub manual, because you will see that Grub never uses (sdX,Y) notation; all drives, whether IDE or SATA, are (hdX,Y) to Grub. Also, the disadvantage of adding Debian's boot stanzas to Ubuntu's menu.lst is that you would have to do that manually every time Debian gets a kernel upgrade. That's the advantage of "chain loading" Debian's menu.lst from Ubuntu: you never have to worry about updating Ubuntu's menu.lst when Debian gets new kernels. Another method that can work is to link to Debian's menu.lst via the "configfile" notation:
Code:

title Debian Grub Menu
configfile (hd0,1)/boot/grub/menu.lst

The advantage of that is you don't have to first install Grub to the boot sector of the Debian partition as you do when you chain load; but the disadvantage is that some distros like OpenSUSE use gfxboot for eye candy, so linking to its menu.lst via "configfile" doesn't work well. But in the case of Debian, it would probably work fine. Always the safest approach is chain loading, because then the distro you want to add to the Grub menu uses its own version Grub to load its own menu.lst.

alan_ri 02-17-2009 12:47 PM

What about command;
Code:

grub-install /dev/sda
Will that work?

What about when you want to install GRUB on the floppy disk?Would you then use "s" or "h"?

CJS 02-17-2009 01:08 PM

Quote:

Originally Posted by alan_ri (Post 3447225)
What about command;
Code:

grub-install /dev/sda
Will that work?

That command will install Grub to the MBR and point Grub to the partition that you run the command from for its boot files. If you want to use the grub-install command to install Grub using the boot files from another partition, and also install Grub to the boot sector of that partition (michalng's case), you have to mount that partition and do:
Code:

grub-install --root-directory=/mounted_sda2_partition /dev/sda2
But the only time you need the grub-install command is if Grub's boot files don't all ready exist in /boot/grub. If the partition all ready has the boot files installed (which would be michalng's case), then it is generally better to use the Grub CLI to install Grub to the boot sector of the partition and use the all ready existing Grub boot files.
Quote:

Originally Posted by alan_ri (Post 3447225)
What about when you want to install GRUB on the floppy disk?Would you then use "s" or "h"?

Actually neither, you would use (fd0) in the Grub CLI. :)

alan_ri 02-17-2009 01:29 PM

So,I've made my point.The thing is,I know that I made Lapsus Memoriae and I was wrong and you were right about "h" but also I was right about "s" for what I had in mind,also,as I've said within the question,GRUB can use "f" and now that you've confirmed that GRUB can use "s" and "f" I believe that we understand each other.That said,just to clarify,I didn't need your explanation for "How GRUB works" I just wanted you to say that GRUB can use "s" and "f".
Hope that this little discussion of ours will make some things clearer for someone. ;)

H_TeXMeX_H 02-17-2009 02:12 PM

Do you have any particular reason for chainloading grub to grub ? I mean, in most cases you don't have to, in fact it's senseless. Just tell it where the kernels are and it'll boot them, no need for chainloading.

syg00 02-17-2009 04:14 PM

Quote:

Originally Posted by H_TeXMeX_H (Post 3447342)
Do you have any particular reason for chainloading grub to grub ? I mean, in most cases you don't have to, in fact it's senseless.

Quite the contrary.
When the second (or fifth, ...) distro ships a new kernel they will update their config file. You will see it automatically.
Stops people wondering why they aren't seeing that upate when they neglected to continually update their manual config.

michalng 02-17-2009 04:48 PM

Quote:

Originally Posted by CJS (Post 3446925)
Sure, you can install Grub to the boot sector of the Debian partition while you are in Ubuntu:
Code:

sudo grub
grub> root (hd0,1)
grub> setup (hd0,1)
grub> quit

Then you should be able to chain load Debian's Grub from your Ubuntu menu.lst. Let me know how that goes or if you run into problems.

Got it working , thanks for the help ! :)

H_TeXMeX_H 02-18-2009 03:13 AM

Quote:

Originally Posted by syg00 (Post 3447476)
Quite the contrary.
When the second (or fifth, ...) distro ships a new kernel they will update their config file. You will see it automatically.
Stops people wondering why they aren't seeing that upate when they neglected to continually update their manual config.

Sorry, but I don't get it, try again.

Grub will boot just a kernel, it doesn't really need anything else, just the HDD and partition and the path to the kernel. So, I don't get what you're saying.

alan_ri 02-18-2009 04:17 AM

...and what if we have a line in /boot/grub/menu.lst for OS that we want to add to GRUB that looks like this;
Code:

kernel /boot/vmlinuz root=/dev/hda1
Would you say that there is a need for chainloading then?

michalng 02-18-2009 04:22 AM

Quote:

Originally Posted by H_TeXMeX_H (Post 3447989)
Sorry, but I don't get it, try again.

Grub will boot just a kernel, it doesn't really need anything else, just the HDD and partition and the path to the kernel. So, I don't get what you're saying.

Believe what syg00 means is,

if today debian's kernel is 2.6.26-1-686, the manually updated (not-debian) grub will be pointing to it.

However, if tomorrow there's a new kernel 2.6.28.1-686, an update will only cause an update to debian's own grub menu, in my case hidden in debian's own boot partition (not inside mbr). The original (not debian's) grub at mbr will not be updated automatically.

Chainloading will thus solve this "problem" of "not seeing that update".

Hope I get this right :)

jschiwal 02-18-2009 04:45 AM

You could update the second Linux's grub in it's own MBR, and then copy it's stanza from the second menu.lst to the main MBR's menu.lst file. You could keep the chainloading stanza for insurance. Hopefully you will be able to boot directly instead of chainloading.

syg00 02-18-2009 05:21 AM

Way too hard @jschiwal - I have dozens of systems, and I also build my own kernels.
@alan_ri has the right idea - except that as I said, I have so many kernels, that little kludge ain't gunna fly.

But this is Linux - enough choices to satisfy everyone.


All times are GMT -5. The time now is 05:36 PM.