LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 07-25-2017, 02:40 PM   #1
tb75252
Member
 
Registered: Oct 2010
Posts: 167

Rep: Reputation: Disabled
GRUB Bootloader


I'm relatively inexperienced with Linux and I have nagging doubts on how things with the GRUB bootloader work.

I have Ubuntu installed in /dev/sda1 and its GRUB bootloader is installed in /dev/sda.

Now I want to install Debian in /dev/sda2 (keeping Ubuntu in /dev/sda1) and the installer is asking me where I want to install its GRUB bootloader.

I figure that since I have already Ubuntu's bootloader installed in /dev/sda I should not even have to install a second bootloader. Am I right? All I would need to do, after installing Debian, is to bring Ubuntu's command line up and launch
Quote:
update-grub
Right?

And yet Debian wants to know if I want its bootloader in /dev/sda or /dev/sda2.

I did some research online about all this but I've gotten even more confused. Can somebody help?

PS: These are standard OS installations on a BIOS (not UEFI) PC with EXT4 partitions, if that helps.
 
Old 07-25-2017, 03:02 PM   #2
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec and Dartmouth, Nova Scotia CANADA
Distribution: Arch, AntiX, ArtiX
Posts: 1,364

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
Hi tb75252 ... You are correct - you do not need to install a second instance of Grub after installing another OS (Debian or otherwise). Updating Grub in the Ubuntu session should detect Debian and add it to the boot menu.

Cheers,
 
Old 07-25-2017, 03:07 PM   #3
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
Quote:
I figure that since I have already Ubuntu's bootloader installed in /dev/sda I should not even have to install a second bootloader. Am I right? All I would need to do, after installing Debian, is to bring Ubuntu's command line up and launch
Quote:
update-grub
Right?
Yes that will work.
If you install Debian boot loader to sda2, you could create an entry in /etc/grub.d/40_custom to chainload the debian bootloader. By doing so would eliminate the task of going back to Ubuntu to update grub every time there is a kernel update in debian.
 
Old 07-25-2017, 03:40 PM   #4
tb75252
Member
 
Registered: Oct 2010
Posts: 167

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by colorpurple21859 View Post
Yes that will work.
If you install Debian boot loader to sda2, you could create an entry in /etc/grub.d/40_custom to chainload the debian bootloader. By doing so would eliminate the task of going back to Ubuntu to update grub every time there is a kernel update in debian.
Interesting suggestion! And I suppose that if it were Ubuntu to have a kernel update, the chainloading for Debian in /etc/grub.d/40_custom would not be affected, right? In other words, when Ubuntu "rebuilds" GRUB due to a kernel update it would not get rid of the chainloading. Am I correct?

I can't seem to be able to find a good example of chainloading two Linux distros. All I find is chainloading examples with Microsoft Windows. Does anyone know of a chainloading tutorial with only Linux OSs?
 
Old 07-25-2017, 04:13 PM   #5
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec and Dartmouth, Nova Scotia CANADA
Distribution: Arch, AntiX, ArtiX
Posts: 1,364

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
I realize that you're going to be using Ubuntu and Debian, but the ArchLinux Wiki is an excellent resource and its entry on Grub is quite extensive, including sections on chainloading. It wouldn't be a waste of time, in my opinion, were you to consult it.

Cheers.
 
2 members found this post helpful.
Old 07-25-2017, 06:49 PM   #6
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 actually see an option in the Debian installer to not install Grub then that should work and reboot to Ubuntu and sudo update-grub.
If you want to chainload you need Grub.

Sample chainload I use on a flash drive to boot a second partition which is what you want below;

Quote:
menuentry 'Debian' {
insmod ext2
set root=(hd0,2)
chainloader +1
}
 
Old 07-25-2017, 07:37 PM   #7
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
you will have to run update-grub after editing /etc/grub.d/40_custom for the chainloader entry to show on your grub menu
 
Old 07-25-2017, 07:54 PM   #8
TheEzekielProject
Member
 
Registered: Dec 2016
Distribution: arch
Posts: 668

Rep: Reputation: 190Reputation: 190
I second Rickkkk's suggestion of checking out the Arch linux wiki. While there are some things that will be more distribution specific, I would say most things are fairly universal among the linux distros. Especially relating to grub, being that grub boots before linux, it is really platform independent
 
Old 07-25-2017, 08:34 PM   #9
tofino_surfer
Member
 
Registered: Aug 2007
Posts: 483

Rep: Reputation: 153Reputation: 153
Quote:
If you install Debian boot loader to sda2, you could create an entry in /etc/grub.d/40_custom to chainload the debian bootloader. By doing so would eliminate the task of going back to Ubuntu to update grub every time there is a kernel update in debian.
You may run into problems by trying to install to a partition as it may complain about using blocklists. An ext4 file system has only 1024 bytes free at the start of the partition. This is far too small for the core.img (32K) second stage so a list of sectors is sometimes put in this 1K of space to point to the core.img in the file system. Recent versions of grub don't like to do this easily with MBR partitioning. With BIOS/GPT booting you have a separate 1 MiB BIOS Boot partition in which to place the core.img.

There is another easier way to get a similar effect to chainloading and that is connfig file loading. In this approach the grub of Ubuntu will load the config file of Debian in its /boot directory. You will need to have the grub system files in your /boot directory but don't have to install boot code to the 1K PBR.

In my case I load the config file of Fedora 24 from the grub controlled by Centos 7 with the following entry in my /etc/grub.d/40_custom. This approach will boot faster as there is only one grub executable and is simpler as there is no need to install boot code to the 1K PBR. I have a separate /boot partition so the uuid is of the /boot filesystem and the config file path is shorter. If you don't have a separate /boot partition the uuid will be of the / file system and you will have configfile /boot/grub2/grub.cfg.

Code:
menuentry "Fedora 24 using grub2 configfile" {
   insmod ext2
   insmod part_gpt
   search --no-floppy --fs-uuid --set=root e52b5567-e0eb-4ac6-93d3-6fd86d8043b1
   configfile /grub2/grub.cfg
}
 
Old 07-26-2017, 01:42 AM   #10
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,806
Blog Entries: 1

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066
As a multibooter for more than 2 decades, I like tofino_surfer's suggestion a bit more than colorpurple21859's. That said, if your Ubuntu Grub ever fails, then Debian boot will be unavailable too until Ubuntu's Grub is repaired.

What I do is install Grub only on primary partition(s) never to be mounted to /boot or root, and use standard MBR code pointing to the Grub primary partition. IOW, I never put any Grub on any MBR. I maintain the bootloader on the primary partition(s), and make all root partitions logicals. Consequently if one distro's bootloader fails for any reason, one or more others will always remain available, both for normal use, and for facilitated repair of any broken one. This equally applies when Windows is also installed, whether before or after installing Linux(es).
 
Old 07-26-2017, 09:20 AM   #11
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
mrmazda
Quote:
IOW, I never put any Grub on any MBR
Quote:
use standard MBR code pointing to the Grub primary partition
What bootloader do you use in the MBR or it is just nulled out and let bios handle it?


tofino_surfer
Quote:
There is another easier way to get a similar effect to chainloading and that is connfig file loading
I have seen a few ops mentioning chainloading with config files. I have considered doing it on my efi system versus using the efind bootloader I use now. I've never really thought about it on a bios system, mostly because I'm using lilo with some of the distros I multiboot. May swap everything over to grub, and give configfile chainloading a whirl.

Last edited by colorpurple21859; 07-26-2017 at 09:23 AM.
 
Old 07-26-2017, 12:36 PM   #12
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,806
Blog Entries: 1

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066
Quote:
Originally Posted by colorpurple21859 View Post
What bootloader do you use in the MBR or it is just nulled out and let bios handle it?
Neither. All a BIOS does is load and start execution of the MBR sector's code block. If it were null, you'd get nothing post-POST completion. "Standard MBR code" is DOS/OS2/Windows/Lilo/Grub/etc.-compatible code, which does no more than locate the primary partition with the boot flag set, loads its PBR, and starts its execution. If the flag is set to a Windows partition, Windows' bootloader starts. If the flag is set on a partition with some other bootloader on it, that bootloader is started. If Windows' bootloader starts, such as immediately after Windows installation, but you want Grub to start, it's a very simple matter to boot into Windows and use one of its MBR sector tools to move the boot flag to a primary partition containing Grub. If Windows refuses to perform updates because it has not boot control, it's again a simple matter to move the flag to the Windows primary, let Windows update, then move the flag back to the primary with Grub. Thus Windows can be installed or reinstalled at any time without (more than nominally) disrupting any installed FOSS OS. Meanwhile, no installed distro's bootloader will wrest control from any other, due to each having been installed to its own root (or /boot). And, by (optionally) disabling os-prober, each distro's boot menu can be kept simple, providing only stanzas applicable to that one distro, which can be very welcome on machines with more installed OS than can fit in a single screen boot menu.
 
Old 07-26-2017, 03:37 PM   #13
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
I didn't think it would work with a nulled MBR, but wasn't sure. On My bios system I also have the os-prober disabled to keep things simpler.

Last edited by colorpurple21859; 07-26-2017 at 03:39 PM.
 
Old 07-26-2017, 04:14 PM   #14
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
It can be handy to have an alternate boot-device, which you can quickly flip-to on a BIOS or system-firmware screen, which is also capable of correctly booting the computer.
 
Old 07-26-2017, 04:31 PM   #15
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
I don't care for the additional complexity and complications of chain loading or even a second boot setup.

My preference would be:

1) Do NOT install grub at all in the second OS (Debian).

2) Boot into Ubuntu as necessary to run "update-grub" - it will autodetect the Debian install and set up appropriate boot option in Grub for it.

3) Create a minimal Debian (or Ubuntu) install on a usb drive.

If for some reason the Ubuntu grub is borked, do the following steps:
Code:
1) boot into the USB drive
2) run "update-grub" - it will autodetect both the Ubuntu and Debian installs and create new grub entries for it
3) optionally do other rescue work
4) reboot and choose one of the new grub entries to boot into Ubuntu or Debian
Fundamentally, this strategy minimizes the maintenance effort involved. There's just one "mastermind" OS controlling a simple centralized grub setup. If for some reason that setup gets borked, then I go through the small extra effort of updating grub on a minimal USB install. This utility USB thumbdrive is a useful rescue OS for all of my computers, not specific to just one. As such, its grub setup will be specifically set up for whatever the heck was the last computer setup I ran "update-grub" on. Too much effort and too silly to try and "maintain" that grub setup. I just run "update-grub" when necessary to help rescue a system.
 
  


Reply



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
[SOLVED] GRUB bootloader questions.(Can I restore the windows bootloader & windows 10 upgrade) anon261 Linux - General 3 07-19-2015 05:01 PM
GRUB security. -How do I properly set, and double check the grub bootloader password? bwilky11 Debian 3 11-02-2012 08:22 PM
Grub bootloader overwritten by WinXP bootloader, all other os' gone! craigforsure Linux - Newbie 5 03-29-2010 02:49 AM
Replace GRUB Bootloader with WIN NT Bootloader wombat53 Linux - Software 1 09-04-2009 08:56 AM
How can I disable the grub bootloader and enable the lilo bootloader? abefroman Linux - General 1 08-06-2005 08:53 AM

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

All times are GMT -5. The time now is 07:15 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