LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-04-2016, 03:53 AM   #1
henrig
Member
 
Registered: Jan 2016
Location: UK
Distribution: Linux Mint
Posts: 50

Rep: Reputation: Disabled
Can someone explain GRUB to me?


If I install Windows then Linux Mint in dual partitions, the bootloader in Mint will detect both OS and I can dual boot.

If I install another Linux distro alongside these 2 but do not install/update GRUB at that time, will GRUB detect the 3rd OS?
Is it a case of re-installing GRUB or updating it?
I suppose it sits independently in a partition or sector of its own on the HDD?

I had Windows and Mint on my PC, then installed GhostBSD alongside both OS. There was aan option to install GRUB during the installation and I went for it. However, when I restarted, BSD was the only OS available at boot, although the other 2 OSes were still there.

So I ran Boot-Repair but that left me only with Mint although Windows XP is still lurking there. BSD doesn't come up anymore.

Then I reinstalled BSD without re-installing GRUB this time and although it's installed, my bootloader screen is just the same as before - only Mint comes up. I assume that's simply because I have made no changes to GRUB.

So GRUB doesn't "detect" a new OS, it needs to be re-installed every time?

Windows had also previously disappeared from the boot options before and it magically came back after I installed another linux distro. I might try that to get Windows back but it doesn't help my understanding of GRUB that OSes can come and go unpredictably when you install it.

So if anyone could explain in simple terms how GRUB works when messing about with dual or triple boots and adding OSes alongside existing ones, that would be very helpful to me.
 
Old 05-04-2016, 04:57 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
this is a two-step process:
first you need to create a config file for grub (which is made by executing update-grub2). That will look for bootable OSs and will construct a menu system.
next you need to boot and choose something from that menu.

In your case BSD created no menu entries for other OSs, so you need to update-grub again.
 
Old 05-04-2016, 05:01 AM   #3
henrig
Member
 
Registered: Jan 2016
Location: UK
Distribution: Linux Mint
Posts: 50

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
this is a two-step process:
first you need to create a config file for grub (which is made by executing update-grub2). That will look for bootable OSs and will construct a menu system.
next you need to boot and choose something from that menu.
Is this approximately what Boot-Repair does?
 
Old 05-04-2016, 05:06 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
not really, it can do much more. I do not know if it can generate grub menus properly.
 
Old 05-04-2016, 07:41 AM   #5
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,502

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
The problem would appear to be the version of Grub2 used by 'GhostBSD' as generally when installing systems such as Mint will probe for other systems and create a grub.cfg boot menu with the grub-mkconfig command run at the end of the install. One simple solution to your situation would have been to install Grub2 on the partition to which you installed it rather than the MBR. You would have then been able to boot Mint and run the grub-mkconfig command. In Mint, this command is: sudo update-grub.

Take a look at the site below which explains re-installing Grub2 which you could do for Mint. Have you tried running grub-mkconfig from GhostBSD? I've never ued it so don't know what's available.

https://help.ubuntu.com/community/Gr..._Broken_System

Last edited by yancek; 05-04-2016 at 11:13 AM.
 
Old 05-04-2016, 08:14 AM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Strictly speaking grub doesn't probe for other OS - that is performed by os-prober, an external program which grub will use if present.
os-prober has specific matching rules - if the "other" OS doesn't match, it isn't included in the boot menu.
 
Old 05-04-2016, 09:40 AM   #7
henrig
Member
 
Registered: Jan 2016
Location: UK
Distribution: Linux Mint
Posts: 50

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by yancek View Post
The problem would appear to be the version of Grub2 used by 'GhostBSD' as generally when installing systems such as Mint will probe for other systems and create a grub.cfg boot menu with the grub-mkconfig command run at the end of the install. One simple solution to your situation would have been to install Grub2 on the partition to which you installed it rather than the MBR. You would have then been able to boot Mint and run the grub-mkconfig command. In Mint, this command is: sudo update-grub.

Take a look at the site below which explains re-installing Grub2 which you could do for Mint. Have you tried running grub-mkconfig from GhostBSD? I've never ued it so don't know what's available.
I sort of fixed it by running Boot-Repair on a live CD but I'm now only left with Mint. The bootloader doesn't detect either BSD or Windows on my machine.
So I only get to boot into BSD only or Mint only. Can't have both or even all three.
 
Old 05-04-2016, 11:20 AM   #8
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,502

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
If you are able to boot Mint, open a terminal and run: sudo update-grub and watch the output to see if the other OS's are detected and added to the boot menu. If that doesn't do it, try sudo os-prober

Since you have and are using the boot repair software, is there any particular reason you are not posting a link to the output by selecting the Create BootInfo Summary option which would give a lot more detail on your system and it's problems?
 
Old 05-04-2016, 11:36 AM   #9
henrig
Member
 
Registered: Jan 2016
Location: UK
Distribution: Linux Mint
Posts: 50

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by yancek View Post
Since you have and are using the boot repair software, is there any particular reason you are not posting a link to the output by selecting the Create BootInfo Summary option which would give a lot more detail on your system and it's problems?
I ditched the output!
This thread is not really about troubleshooting. Mint is my main installation and it works fine. If GRUB doesn't work, I know how to fix it via Boot-Repair.

I'd rather understand what's going on, why GRUB behaves as it does, how it's supposed to behave, etc...

So next time I attempt to install another OS and GRUB, I will know what I'm doing.
 
Old 05-04-2016, 12:46 PM   #10
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
I may be wrong but my understanding is that BIOS points to a bootloader on the HDD, that invokes GRUB, which (from version 2 onwards) has pointers to the installed OSs the prober found and there's a boot menu.
The initial bootloader has to be installed on the first place your BIOS looks (unless the previous ones are missing but ignore this for now) for a boot partition.
Edit: UEFI can boot from suitable partitions and doesn't care about the MBR.
 
Old 05-04-2016, 05:01 PM   #11
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,502

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
Quote:
I'd rather understand what's going on, why GRUB behaves as it does, how it's supposed to behave, etc...
With "some" distributions of Linux such as Mint, the installer will probe for other operating systems and create a menuentry for each. All Linux distributions don't do this or don't do it as well as some others and you then end up with the result you got with Ghost BSD. It's the installer as pointed out above which does this.

Your options with almost all Linux distributions are too either install to the MBR of a specific drive or to select to install to the partition on which you have the Linux system installed. If you select to install Grub to the system partition, you need a separate bootloader with code in the MBR. You then would boot that system and run grub-mkconfig or update-grub and the new install should be detected.

Your specific problem isn't with Grub, it is GhostBSD. If you want to understand Grub2, the best source of information is their online manual.

http://www.gnu.org/software/grub/manual/grub.html
 
Old 05-04-2016, 09:53 PM   #12
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,346

Rep: Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589
As far as your problem as has already been mentioned the problem is in the probing of other distros.
This http://www.ramkitech.com/2012/01/gru...omization.html explains how grub2 works with out getting too technical. What it doesn't mention is in the distro that has grub connected to the MBR, you can add entries to the /etc/grub.d/4o_custom file that aren't picked up by the osprober so that when update-grub/grub-mkconfig is run these entries will be added to the /boot/grub/grub.cfg file. The downside is that every time there is a kernel update in the other distro you will have to re-edit the 40_custom file and rerun update-grub/grub-mkconfig to reflect the change in the distro that has grub connected to the MBR. A work around is to install grub from the distro that you keep all the time to the MBR, and the other distros grubs to their respective partitions and add chainloading entries to the /etc/grub.d/40_custom for the other distros. This is on systems that uses MBR, EFI systems work a little differently.

Last edited by colorpurple21859; 05-05-2016 at 09:17 AM.
 
Old 05-05-2016, 03:28 AM   #13
henrig
Member
 
Registered: Jan 2016
Location: UK
Distribution: Linux Mint
Posts: 50

Original Poster
Rep: Reputation: Disabled
So my understanding is that GRUB2 is GRUB2 whether installed from Mint, other linux distros or BSD. It's the os-prober from the install that may or may not pick up all the other OSes already there?
 
Old 05-05-2016, 07:58 AM   #14
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,502

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
The Grub2 Manual below indicates that running 'grub-mkconfig (update-grub in Ubuntu) will search for kernels and create the grub.cfg menu. When this doesn't work, running 'os-prober' is recommended. The page referred to is at the link below. More info on Grub2 on the Ubuntus at the second link.

https://www.gnu.org/software/grub/ma...-configuration

https://help.ubuntu.com/community/Grub2/Setup

Info on os-prober.

https://joeyh.name/code/os-prober/

I expect developers of different distros make some modifications as from my experience, some are much better than others at detecting other operating systems even if all are Linux.
 
Old 05-07-2016, 03:12 PM   #15
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
GRUB is a little bit of code that loads up the rest of it from whatever thing installed it last. And loads a configuration file from that thing. Or goes into command mode if that configuration file is missing. When grub is installed it creates a configuration file (update-grub in debian). The main issue with BSD is that it tends to use ZFS and encryption which doesn't exist in linux or at least bsd's version of it in linux.

There's various ways to cope though. I tend to set my computer to boot from USB first. And I tend to install my distros to usb storage and put grub on that storage. So whatever stick is in the port is the OS that boots. No fuss, no mess, it just works. Until you have more than one OS stick connected, then you get to play OS roulette. Although my tendency towards this is that the only ports on the laptop are USB and the storage that came with the device is soldered to the motherboard and will someday fail.
 
  


Reply

Tags
bootloader, grub



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Infinite Grub Loop: GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB... beeblequix MEPIS 2 11-02-2013 10:56 PM
Changing GRUB-GRUB, GRUB-LILO and vice versa andreas_skw Linux - Newbie 1 06-05-2008 06:40 AM
explain GRUB loader hck_sec Linux - Newbie 3 02-07-2007 04:10 AM
Booting my new ubuntu install = "GRUB GRUB GRUB GRUB GRUB" etc. dissolved soul Ubuntu 2 01-13-2007 12:55 PM
grub option pls explain ravi.ravix Linux - Newbie 2 07-14-2006 02:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration