LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   grub and fedora and ubuntu (https://www.linuxquestions.org/questions/linux-software-2/grub-and-fedora-and-ubuntu-4175418379/)

Pedroski 07-24-2012 06:00 AM

grub and fedora and ubuntu
 
I have both Fedora 17 and Ubuntu 12.04 installed. Fedora was installed last. It rewrote the mbr or whatever that is called. It added the necessary lines to boot Windows and Ubuntu, taken from the actual grub.cfg in Ubuntu, I presume.
Problem is when I get a kernel update in Ubuntu. Ubuntu adds its updated configuration to the Ubuntu /boot/grub/grub.cfg which on boot is duly ignored by the grub installed by Fedora.
I can copy the new menuentry { blabla} from the Ubuntu /boot/grub.cfg into the Fedora /boot/grub2/grub.cfg and that is ok.
Can I somehow tell either Ubuntu or Fedora only to write updates to grub.cfg to just one grub.cfg, so that I do not have to copy the details over manually?? And of course tell grub to use only this config!

acid_kewpie 07-24-2012 06:10 AM

well if you just change /etc/fstab to reference the same partition for /boot then yes that would work as far as editing the boot line goes, however I'm not sure if that could cause other issues as well. Tentatively I'd say not, but I wouldn't count on it.

It's (almost) interesting to observe how /boot isn't really part of the operating system as such. there is no need to mount it at all, and outside of the grub phase serves no purpose at all. So it should really been seen to not belong to either OS in the first place really.

yancek 07-24-2012 08:44 AM

Quote:

Problem is when I get a kernel update in Ubuntu. Ubuntu adds its updated configuration to the Ubuntu /boot/grub/grub.cfg which on boot is duly ignored by the grub installed by Fedora.
If you are chainloading Ubuntu from Fedora (which you said is in the mbr) then Fedora hands over booting to Ubuntu and you will then get the Ubuntu grub menu which should have the new entry. If you have a menuentry for Ubuntu in the Fedora grub.cfg which contains the linux and initrd lines, it is pointing to a specific kernel and Fedora would have no way of knowing a change was made. You need to do update-grub or grub-mkconfig from Fedora so it does a search and creates a new grub.cfg. The Fedora Grub would have no way of knowing Ubuntu got an update otherwise.

Below you indicate the new kernel is ignored in Fedora:

Quote:

Problem is when I get a kernel update in Ubuntu. Ubuntu adds its updated configuration to the Ubuntu /boot/grub/grub.cfg which on boot is duly ignored by the grub installed by Fedora.
Here you seem to be saying it write to both??

Quote:

Can I somehow tell either Ubuntu or Fedora only to write updates to grub.cfg to just one grub.cfg, so that I do not have to copy the details over manually??
Manually entering a new menuentry in the grub.cfg file will work until you run update-grub. If you want an entry permanently, you need to put in in /etc/grub.d/40_custom file.

Pedroski 07-24-2012 09:15 AM

To clarify:
I don't know how the computer actually boots. What tells it which grub.cfg to look for?? If I knew that, I would be half way to solving the problem.
I have a grub.cfg in Ubuntu. I have a grub.cfg in Fedora.
If I update Fedora (/dev/sda6), and there is a kernel update, it, quite naturally, changes its grub.cfg
The same goes for Ubuntu (/dev/sda4).

Quote:

Here you seem to be saying it write to both??
NO!


On kernel update, whatever Linux I am using DOES NOT WRITE TO BOTH. That is natural. I wish it would!
Of course, Ubuntu does not change the Fedora grub.cfg, and Fedora does not touch the Ubuntu grub.cfg
I would like to make both Linices change one grub.cfg on kernel update.

In the past I tried putting an entry in /etc/grub.d/40_custom It did not work, for whatever reason, probably me. I did mess up grub completely once, and had to reinstall, so I tend to leave that alone.
I found, if I directly insert an entry in grub.cfg, it works, even though at the start of grub.cfg it says 'DO NOT EDIT THIS FILE', so I always do it this way.

yancek 07-24-2012 01:59 PM

Quote:

I don't know how the computer actually boots.
According to your initial post, you installed Fedora last and installed the Fedora Grub2 to the master boot record. That means the BIOS goes to the mbr and then to the Fedora grub.cfg and boots whatever the default is. You should have had an entry for Ubuntu in your Fedora grub.cfg.

I don't use Fedora but, with Ubuntu you could update its grub.cfg file to include a new kernel for Fedora on the machine with: sudo update-grub. I would expect you would be able to use "update-grub" with Fedora, if not try the grub mkconfig command or google updating Grub2 in Fedora. Since you are using the Fedora Grub2 to boot, that would be the best option.

My experience with editing the grub.cfg file manually is that when update-grub is run on that OS, the entry disappears if it was not also in the 40_custom file.

Pedroski 07-24-2012 06:17 PM

Thanks for that. Do you mean: if I run 'sudo update-grub' in Fedora, or Ubuntu, it will find the new kernels and put them in grub.cfg?

Assume, I am using Ubuntu (/dev/sda4) and /devsda6 is not mounted by default. I open a terminal and run 'sudo update-grub' Will it look in /dev/sda6 (Fedora) for /etc/boot and add things from there??

Quote:

You should have had an entry for Ubuntu in your Fedora grub.cfg.
Yes, after installing Fedora, it looks for other OSs and puts and entry in its own grub.cfg But it only does this on install. If Ubuntu updates the kernel, Fedora does not see that. So I have to do that manually.

If I am running Fedora, will 'sudo update-grub' find the new Ubuntu kernel and add it to (Fedora)grub.cfg??

syg00 07-24-2012 09:34 PM

No.
No.
No and no.

Sorry, I lost track of which question I was answering there ...

Quote:

I would like to make both Linices change one grub.cfg on kernel update.
You definitely do not want this to happen. Else you tribulations will be longer and stronger.
*ONE* system must own the MBR - that system is the one for which you will see the boot menu. All other systems should install their bootloader to the partition boot record rather than over-write the MBR. They can then be chainloaded if desired - this saves having to continually rebuild the grub.cfg for the "MBR-owning" system for any other (kernel) upgrades. Not such a burden on a 2-system dual boot, but try 5 or 8.
Else simply update the "MBR-owning" systems grub.cfg - for F16 that is grub2-mkconfig (note that this is "non-standard"). It will go find the other updates. See the Fedora wiki for syntax.
"update-grub" will not work on Fedora - it is a Debianism. So whilst being even more "non-standard", is probably easier to work with. You might want to consider Ubuntu as the "MBR-owning" system. But Fedora will have to be re-configured else it will continue to (seemingly randomly) update the MBR. Depends a lot on which system you use more and want as the default boot.

Pedroski 07-24-2012 10:10 PM

Ok, thanks. At the mo, I use Ubuntu more. But Fedora 'owns' the mbr. How do I reverse that? Make Ubuntu the owner again? Short of reinstalling?

The reason I have two flavours of Linux is: this computer, Toshiba laptop C600D has a major, unresolved Linux problem: it crashes any and every time the dsl cable is unplugged. I have reported this to the bugzillas, and any and all forums I could reach. No one has an answer or solution, except 'update'. So I will continue to update, and hope and pray that some sunny day, this problem will vanish into /dev/none!

syg00 07-24-2012 11:23 PM

There are two separate functions required - on both systems.
You'll need to do Ubuntu first - issue "grub-install" to the device node (/dev/sda say). That will over-write the MBR. Then run update-grub - that should populate grub.cfg and still allow you to select Fedora. Good Ubuntu article here.
Seems Ubuntu are pushing people to use "boot repair" - see mention here.
On reboot select Fedora and you need to issue "grub-install" on Fedora pointing to it's partition (/dev/sda2 or whatever), then do the grub2-mkconfig. Both commands are mentioned in the wiki article here.

Make sure you run the Ubuntu update-grub if new kernel get picked up by Fedora.

Pedroski 07-25-2012 07:40 PM

Thanks! That did the trick!
I started Ubuntu, ran grub-install, so now I have Ubuntu in charge of the mbr.

To pick up any Fedora installation, the partition must be mounted. Otherwise grub does not see it. Mounting the Fedora partition in Ubuntu is just a click. Then run grub-update. Funnily enough, I did not have to mount the windows partition for it to be found! I wonder why?

So in future, if Fedora updates the kernel (they always seem to be a step ahead of Ubuntu) I just:
1) Start Ubuntu
2) Mount Fedora partition
3) Run grub-update, and problem solved, the new kernel is in grub.cfg

I see no reason why, if you had more systems, distros, that this should not work. So if you had 5 or 8 distros (why would you do that??), it should pick them up and put them all in one grub.cfg

So thanks again, great tip!

Thanks for the links!

How come I don't see the mbr in say gparted or disk utility?? Where is it??

syg00 07-25-2012 08:24 PM

Quote:

Originally Posted by Pedroski (Post 4738048)
So if you had 5 or 8 distros (why would you do that??),

Partly so I can answer questions like this thread .... :p

I am interested in the technology, not the eye-candy.
The MBR is at the start of the disk - outside of any partition. Likewise the partition table. Wikipedia used to have a quite good explanation.


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