Mint14 took over the boot process, I cannot get OS12.2 to be master of booting.

Hello!
OpenSUSE 12.2 is my ‘production’ system and I have also partitions with Mint13, openSUSE-12.1 and, since 2 days, Mint14. After installing Mint14 there were (and are) no problems with booting, except that I want the 12.2 system to be the master of the boot process. With Legacy-grub I would have done this using the Grub prompt, but with Grub2 I am not aware of a similar straightforward method. So, I have tried setting up booting in Yast (OS12.2), but without success.
Tried: Boot loader locations: MBR, Root partition, Extended Partition separately and in various combinations. In Bootloader Options ‘Write generic boot code to MBR’ has been set and cleared.

Since OS-12.2 is in sda6, I have set the bootflag for the extended partition sda4 (using pmagic) assuming/hoping that the BIOS-code would jump straight there. (It does not)

I have installed updategrub from P_T_A’s repo and used findgrub as a diagnostic:


oS122:~ # findgrub
Find Grub Version 4.4.1 - Written for openSUSE Forums

 - reading MBR on disk /dev/sda                       ... --> Grub2 (2.00) found in sda MBR     => sda10  0x83 (Ubuntu)
 - reading bootsector  /dev/sda1      (LINUX)         ...
 - skipping partition  /dev/sda2      (swap)         
 - reading bootsector  /dev/sda3      (LINUX)         ...                                   
 - reading bootsector  /dev/sda4   *  (Extended)      ... --> Grub2 (2.00) found in /dev/sda4   => sda6   0x83 (openSUSE)                                                                           
 - reading bootsector  /dev/sda5      (LINUX)         ... --> Legacy GRUB  found in /dev/sda5   => sda5   0x83 (openSUSE)                                                                           
 - reading bootsector  /dev/sda6      (LINUX)         ...                                   
 - reading bootsector  /dev/sda7      (LINUX)         ... --> Grub2 (1.99) found in /dev/sda7   => sda7   0x83 (Ubuntu)                                                                             
 - reading bootsector  /dev/sda8      (LINUX)         ...                                   
 - reading bootsector  /dev/sda9      (LINUX)         ...                                   
 - reading bootsector  /dev/sda10     (LINUX)         ...                                   

 - reading MBR on disk /dev/sdb                       ...

 - reading MBR on disk /dev/sdd                       ...

********************************************************************************
WARNING: /dev/sdb is NOT in /boot/grub/device.map
WARNING: /dev/sdd is NOT in /boot/grub/device.map
         Displayed BIOS device mapping may be incorrect!
********************************************************************************

Press <enter> to Exit findgrub..

Additional partition information:


sda5: openSUSE-12.1
sda6: openSUSE 12.2
sda7: Mint-13
sda10: Mint-14
Last installed: Mint-14.
Other partitions are swap or data.

Q1: How can the MBR point to sda10 when Yast (from sda6) has been told to write to the MBR?
Q2: The Bootflag is shown to be set on sda4 (extended) and there is a Grub2 there correctly pointing to sda6. Yet, it is sda10 that is booted.
Q3: How can I set up Grub to boot first to sda6?
(Of course I can try to change the boot order in sda10’s Grub, but that is not what I would like to learn now.)

Thanks for comments or enlightenment !

So I wonder what would happen if you followed this guide and placed the openSUSE Grub into the MBR (sda)?

https://forums.opensuse.org/content/128-re-install-grub2-dvd-rescue.html

I might also say that the gurb in the MBR is in control and the one placed in sda4 would only work as the master if the MBR had generic boot code. Of course, as long as you can get to everything, does it matter who is in control? I think you are just challenging fate on every new try you make to be able to start completely over again with all distros. Good Luck!

Thank You,

Because you installed Mint last (referred as 'Ubuntu" by findgrub, since its Grub must have the same signature) and Mint puts its own Grub in MBR.

Because the bootflag is irrelevant when a boot manager is installed in MBR, as in your case.

Not sure what you mean. You can have any Grub booting any system “first” by changing the default system. If you want to see openSUSE’s Grub at start, just boot it normaly (by selecting it from your current Grub menu) and install its Grub to MBR:


$ su -l
# grub2-install /dev/sda

You certainly don’t need to do that from DVD rescue!

Then you can use updategrub (actually a symlink to updateGrub2) to refresh the menu. If you’re unsure, you can try the option -d first, which just prints the menu to standard output without actually writing it.

Further, I would reinstall Mint’s Grub in its own partition. It surely won’t hurt.

Under Mint14:

$ sudo /usr/sbin/grub-install **--force** /dev/sda10
  • I don’t have Mint14, but I assume it has “grub-install” in /usr/sbin - just like Ubuntu.
    ** Notice that when you install Grub2 boot loader anywhere else besides in MBR, you need to use the option “–force” .

Once you have done this, you can run updategrub again under openSUSE to permanently add a chainloader entry for this Grub if you like.

@hws38

You can swap between which grub takes control easily:

If Mint is in control and you want SUSE, boot to SUSE, open a terminal and the following:

su -
grub2-mkconfig -o /boot/grub2/grub.cfg

followed by

grub2-install /dev/sda

If SUSE is in control and you want Mint, boot to Mint and do:

sudo update-grub
sudo grub-install /dev/sda

Simple as that

which is what updateGrub2 does at the very end, except that it can do more, i.e:

  • finds out and adds chainloader entries if they don’t already exist
  • uses an alternate (better) os-prober script (updategrub -a)
  • allows you to sort an skip user defined boot entries (by reading the variables GRUB_OS_PROBER_SORT and GRUB_OS_PROBER_SKIP in /etc/default/grub
  • supports all BSD boot entries (requires os-prober 1.56 from my repo).

*It used to fix the unreadable (light grey on light green) menu color - and still does - although it’s not necessary anymore, since that bug has been fixed, AFAIK.
** It might issue a non fatal error message the first time because of a library which has been moved … but I’m not sure. I guess I fixed it, but I’m too busy at the moment.

I would do it the other way around (first install the boot loader, then refresh the menu) , but I don’t see why the order would actually matter.

@hws38

If you install Grub2 in MBR under openSUSE, could you please run and post the output of ** findgrub -c*** before and after *(this command takes a little bit longer). It will show if non embedded boot loaders still point to a valid core (I’m afraid the one you have in sda4 will get broken, but findgrub -c will tell us for sure.)

First of all: Thank you jmcdaniel3, please_try_again and caf4926 for your advice!

@jdmcdaniel:

  • Apparently, Yast did not write a generic booloader into the MBR, even though I had enabled this option in the Bootloader options of Yast. Confusing!
  • Quote: * I think you are just challenging fate on every new try you make to be able to start completely over again with all distros.* Well, I installed Mint-14 on the request of a house-guest, assuming the 12.2 system would not be in danger.

@please_try_again:
Your suggestion “grub2install /dev/sda” was exactly what I had been looking for and it worked, of course. Thanks!
Here is the output you asked of “findgrub -c” before and after the grubinstall:


28dec12 09:53 -10:04

oS122:~ # findgrub -c
Find Grub Version 4.4.1 - Written for openSUSE Forums

 - reading MBR on disk /dev/sda                       ... --> Grub2 (2.00) found in sda MBR     => sda10  0x83 using core (Ubuntu)
 - reading bootsector  /dev/sda1      (LINUX)         ...
 - skipping partition  /dev/sda2      (swap)         
 - reading bootsector  /dev/sda3      (LINUX)         ...
 - reading bootsector  /dev/sda4   *  (Extended)      ... --> Grub2 (2.00) found in /dev/sda4   => sda6   0x83 at offset 206939346 (openSUSE)
                                                                                                => inode: 783833   Path: (hd0)/boot/grub2/i386-pc/core.img
 - reading bootsector  /dev/sda5      (LINUX)         ... --> Legacy GRUB  found in /dev/sda5   => sda5   0x83 at offset 156980926 (openSUSE)
                                                                                                => inode: 789664   Path: (hd0)/boot/grub/stage2
 - reading bootsector  /dev/sda6      (LINUX)         ...
 - reading bootsector  /dev/sda7      (LINUX)         ... --> Grub2 (1.99) found in /dev/sda7   => sda7   0x83 at offset 253264352 (Ubuntu)
                                                                                                => inode: 281950   Path: (hd0)/boot/grub/core.img
 - reading bootsector  /dev/sda8      (LINUX)         ...                                                                                
 - reading bootsector  /dev/sda9      (LINUX)         ...                                                                                
 - reading bootsector  /dev/sda10     (LINUX)         ...                                                                                
                                                                                                                                         
                                                                                                                                         
Press <enter> to Exit findgrub...                                                                                                        
oS122:~ # grub2-install /dev/sda                                                                                                       
Installation finished. No error reported.                                                                                                
oS122:~ # findgrub -c                                                                                                                    
Find Grub Version 4.4.1 - Written for openSUSE Forums

 - reading MBR on disk /dev/sda                       ... --> Grub2 (2.00) found in sda MBR     => sda6   0x83 using core (openSUSE)
 - reading bootsector  /dev/sda1      (LINUX)         ...
 - skipping partition  /dev/sda2      (swap)         
 - reading bootsector  /dev/sda3      (LINUX)         ...
 - reading bootsector  /dev/sda4   *  (Extended)      ... --> Grub2 (2.00) found in /dev/sda4   => sda6   0x83 at offset 206939346 (openSUSE)
                                                                                                => inode: <block not found> Path: invalid
 - reading bootsector  /dev/sda5      (LINUX)         ... --> Legacy GRUB  found in /dev/sda5   => sda5   0x83 at offset 156980926 (openSUSE)
                                                                                                => inode: 789664   Path: (hd0)/boot/grub/stage2
 - reading bootsector  /dev/sda6      (LINUX)         ...
 - reading bootsector  /dev/sda7      (LINUX)         ... --> Grub2 (1.99) found in /dev/sda7   => sda7   0x83 at offset 253264352 (Ubuntu)
                                                                                                => inode: 281950   Path: (hd0)/boot/grub/core.img
 - reading bootsector  /dev/sda8      (LINUX)         ...
 - reading bootsector  /dev/sda9      (LINUX)         ...
 - reading bootsector  /dev/sda10     (LINUX)         ...


Press <enter> to Exit findgrub...
oS122:~ # updategrub
Scanning...
oS122:~ # 

Your suggestion for Mint:

$ sudo /usr/sbin/grub-install **--force** /dev/sda10

Gave an error message which I unfortunately have not saved. If you are interested I will “try again”.

@caf4926:
Receiving the same suggestion from two experts was most reassuring!

@caf4926:
Receiving the same suggestion from two experts was most reassuring!

Your words not mine.

Just trying to simplify things for you.

@hws38,
Thank you for your feedback. What a lovely findgrub oputput you have here! Let us - all together - take a closer look. We’re interested in your previous openSUSE Grub boot loader, the one which was installed in the extended partition. The others belong to other systems and were of course not affected.

Before, you had that:

openSUSE Grub in sda4 (probably installed during setup) was perfectly valid and I can assure that it would have booted if you had chainloaded it from the other Grub (Mint) installed in MBR

Then you installed openSUSE’s grub in MBR and it worked (we had no doubt it would).

Now you have this:

openSUSE Grub is in MBR, which is what you wanted. But look at the other one (sda4). It’s dead!

What does it mean? Simply that - unlike Legacy Grub and Grub2 v 1.98 (not sure about Grub2 v 1.99) you can not have Grub2 v 2.00 installed in 2 different boot sectors. Well, you can … but only the latest you install will be valid, at least the one installed in a partition boot sector and using blocklist to find the core can not work anymore, because the core has been rewritten and so the offset on disk has changed. :wink:

My apologies to all three respondents for my typo/mistake. I most certainly consider everyone who replied to my post to be an expert.
Redfacedly,
hws38

Yes, your predictions were confirmed :slight_smile: And thank you for elaborating the workings of Grub2.
I do not understand the “rewritten core”. Is this just a result of the update from v 1.99 or v 1.99 to v 2.00? Or is the core being rewritten after installation in a partition boot sector?

It’s a little bit more complicated than that. To make it simple, the core directory is rewritten on disk when you install or reinstall the boot loader.
I’ll give you an example:

# findgrub -c
Find Grub Version 4.4.1 - Written for openSUSE Forums

 - reading MBR on disk /dev/sda                       ... --> Grub2 (1.99) found in sda MBR     => sda6   0x83 using core (Ubuntu)
 - searching partition /dev/sda1      (FAT16)         ... --> Windows NT/2K/XP Loader found in /dev/sda1

 - skipping partition  /dev/sda2      (FreeBSD)      
 - skipping partition  /dev/sda3      (FreeBSD)      
 - reading bootsector  /dev/sda4   *  (Extended)      ... --> Legacy GRUB  found in /dev/sda4   => sda9   0x83 at offset 615705944 (openSUSE)
                                                                                                => inode: 1441815  Path: (hd0)/boot/grub/stage2
 - skipping partition  /dev/sda5      (swap)         
 - reading bootsector  /dev/sda6      (LINUX)         ...
 - reading bootsector  /dev/sda7      (LINUX)         ...
 - reading bootsector  /dev/sda8      (LINUX)         ...
 - reading bootsector  /dev/sda9      (LINUX)         ... --> Grub2 (2.00) found in /dev/sda9   => sda9   0x83 at offset **579110312** (openSUSE)
                                                                                                => inode: 1442245  Path: (hd0)/boot/grub2/i386-pc/core.img
 - reading bootsector  /dev/sda10     (LINUX)         ...

Now if I reinstall the boot loader in sda9 (there is a warning about blocklists - because it is discouraged - but it succeeds with the --force option).

#  grub2-install --force /dev/sda9
/usr/sbin/grub2-bios-setup: warning: File system `ext2' doesn't support embedding.
/usr/sbin/grub2-bios-setup: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
Installation finished.** No error reported.**

the entire core directory (/boot/grub2/i386-pc) will be recreated. Look at the date:


# stat /boot/grub2/i386-pc 
  File: '/boot/grub2/i386-pc'
  Size: 12288           Blocks: 24         IO Block: 4096   directory
Device: 809h/2057d      Inode: 1441816     Links: 2
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2012-12-28 05:38:31.771721827 -0800
Modify: 2012-12-28 05:36:11.780797423 -0800
Change:** 2012-12-28 05:36:11**.780797423 -0800
 Birth: -

and the offset (absolute position on disk) of core.img has changed:


 # findgrub -c
Find Grub Version 4.4.1 - Written for openSUSE Forums

 - reading MBR on disk /dev/sda                       ... --> Grub2 (1.99) found in sda MBR     => sda6   0x83 using core (Ubuntu)
 - searching partition /dev/sda1      (FAT16)         ... --> Windows NT/2K/XP Loader found in /dev/sda1

 - skipping partition  /dev/sda2      (FreeBSD)      
 - skipping partition  /dev/sda3      (FreeBSD)      
 - reading bootsector  /dev/sda4   *  (Extended)      ... --> Legacy GRUB  found in /dev/sda4   => sda9   0x83 at offset 615705944 (openSUSE)
                                                                                                => inode: 1441815  Path: (hd0)/boot/grub/stage2
 - skipping partition  /dev/sda5      (swap)         
 - reading bootsector  /dev/sda6      (LINUX)         ...
 - reading bootsector  /dev/sda7      (LINUX)         ...
 - reading bootsector  /dev/sda8      (LINUX)         ...
 - reading bootsector  /dev/sda9      (LINUX)         ... --> Grub2 (2.00) found in /dev/sda9   => sda9   0x83 at offset** 583107624** (openSUSE)
                                                                                                => inode: 1442245  Path: (hd0)/boot/grub2/i386-pc/core.img


Thus, it wouldn’t work if you install the boot loader in 2 different boot sectors (because this offset is saved in the boot loader - or the way to access it, to make it simple).

As complicated as it might sound, it means that people should avoid blindly reinstalling Grub2. It wasn’t a problem at all with Legacy Grub. You could have had the boot loader (stage1) installed everywhere.

Grub2 v 1.98, 1.99 and 2.00 all have different ways to store the core offset. Hope you don’t want me to explain the differences here. :slight_smile:

@please_try_again

Thus, it wouldn’t work if you install the boot loader in 2 different boot sectors (because this offset is saved in the boot loader - or the way to access it, to make it simple).

Thanks for your explanation. The example is very informative. (Even so, I tend to think that simplicity is in the eye of the beholder.)

As complicated as it might sound, it means that people should avoid blindly reinstalling Grub2. It wasn’t a problem at all with Legacy Grub. You could have had the boot loader (stage1) installed everywhere.

Yes, Legacy Grub seems much simpler to me. But this may change as my understanding of Grub2 improves.

Grub2 v 1.98, 1.99 and 2.00 all have different ways to store the core offset. Hope you don’t want me to explain the differences here.

Thank you very much indeed for your help. You have spent a lot of time on my problem. No more questions until I have done some serious thinking on Grub2.