Donate to Remove ads

Got a credit card? use our Credit Card & Finance Calculators

Thanks to Wasron,jfgw,Rhyd6,eyeball08,Wondergirly, for Donating to support the site

GRUB question

Seek assistance with all types of tech. - computer, phone, TV, heating controls etc.
cinelli
Lemon Slice
Posts: 553
Joined: November 9th, 2016, 11:33 am
Has thanked: 234 times
Been thanked: 161 times

GRUB question

#121600

Postby cinelli » March 2nd, 2018, 11:57 am

I have installed various flavours of linux over the years, usually dual (or more) boot. GRUB is the mechanism which controls which OS you want to use and always the most recently installed system is the version of GRUB which is in control. My question is, how does the computer “know” which disk partition to go to for the relevant GRUB? Thanks.

Cinelli

UncleEbenezer
The full Lemon
Posts: 10813
Joined: November 4th, 2016, 8:17 pm
Has thanked: 1471 times
Been thanked: 3005 times

Re: GRUB question

#121657

Postby UncleEbenezer » March 2nd, 2018, 2:27 pm

Isn't it a BIOS setting to boot from MBR?

With LILO, you get control of it transparently as you install. I like that: I find systems that take control "under the hood" scary, as some - ranging from Windows to OpenSolaris versions - have silently killed other cohabiting OSs.

Breelander
Lemon Quarter
Posts: 4179
Joined: November 4th, 2016, 9:42 pm
Has thanked: 1002 times
Been thanked: 1855 times

Re: GRUB question

#121668

Postby Breelander » March 2nd, 2018, 2:59 pm

cinelli wrote: My question is, how does the computer “know” which disk partition to go to for the relevant GRUB?


I don't dual boot, but can tell you the short answer: BCDEDIT

For longer answers, see...

https://askubuntu.com/questions/744697/ ... and-by-sep

https://www.sevenforums.com/tutorials/2 ... linux.html

pochisoldi
Lemon Slice
Posts: 943
Joined: November 4th, 2016, 11:33 am
Has thanked: 32 times
Been thanked: 462 times

Re: GRUB question

#121674

Postby pochisoldi » March 2nd, 2018, 3:44 pm

cinelli wrote:I have installed various flavours of linux over the years, usually dual (or more) boot. GRUB is the mechanism which controls which OS you want to use and always the most recently installed system is the version of GRUB which is in control. My question is, how does the computer “know” which disk partition to go to for the relevant GRUB? Thanks.

Cinelli


If you've installed GRUB in the MBR, then the code isn't held in a partition, it will be held on the first cylinder. The GRUB configuration will then specify where the target operating systems are located.

A google for "GRUB boot process" (with out the quotes), yielded https://www.thegeekstuff.com/2011/02/linux-boot-process which looks like a good first overview of how things work.

If you haven't installed GRUB in the MBR, but have installed it on a partition, then you need to mark that partition as active, and the MBR code will then load the boot code for that partition (containing GRUB) and then the process continues (this is how a MS-DOS computer booted back in the day).

PochiSoldi

cinelli
Lemon Slice
Posts: 553
Joined: November 9th, 2016, 11:33 am
Has thanked: 234 times
Been thanked: 161 times

Re: GRUB question

#122584

Postby cinelli » March 6th, 2018, 12:51 pm

Thank you for the replies. I think this is probably more complicated than I thought. I want to explain the reason for the question and what I have experienced.

If this is relevant I am using an old IBM Thinkpad laptop for experiments like this. If anyone else is thinking of testing linux, this is a good idea – if anything goes wrong, you have not lost anything. I split the hard disk into five partitions. 1, 2 and 3 will hold different linuxes and 5 and 6 will hold common /home and swap. First I installed arch in partition 3. On reboot I was presented with the GRUB menu. Even though there is only one OS at this stage, you still have an option to boot arch or arch with advanced options. Where is this menu stored? The answer is in partition 3 in file /boot/grub/grub.cfg. So far so good.

I then installed crunchbang linux in partition 2. On reboot the GRUB menu now has more options: crunchbang, memory test, arch, arch with advanced options. And this enhanced menu is stored in the just created partition 2 in file /boot/grub/grub.cfg.

And so on to partition 1 in which I successfully installed peppermint linux. After reboot the menu has grown further and is stored in partition 1, file /boot/grub/grub.cfg. The question is how does the computer “know” to look at partition 1 for its menu? I am aware that there is a flag stored in the master boot record but in my experience, this is irrelevant for linux. In fact you can check its position by the command “sudo fdisk –l” and for my system, it points to partition 3 whereas I know the relevant file is in partition 1.

Why does this matter? Well, I just like to know how things work. But for a practical reason, suppose my third installation had failed. I would have been left with a computer attempting to boot with its critical data inaccessible in partition 1. Or perhaps I want to use partition 1 for data. In these circumstances, I would like to know how to go back a step or to force the computer to look in partition 2 for its menu.

Cinelli


Return to “Technology - Computers, TV, Phones etc.”

Who is online

Users browsing this forum: No registered users and 34 guests