"zypper up" overwrote my MBR

Hi all,
i have a dual boot machine with this configuration:

  • Fedora 13 installation on the first 4 disks, booted with grub legacy installed on the MBR of /dev/sda
  • OpenSuse 12.3 64bit installed on the 5th disk, with GRUB2 installed on /dev/SDE and chainloaded from grub legacy (the fedora bootloader).

With this configuration every OS manage its own bootloader without any interference.

A couple of days ago i issued a “zypper up” and something went horribly wrong. At the next boot I saw that grub2 was installed on the MBR of the first disk, and grub legacy was overwritten. Luckly grub2 autoamagically detects the presence of Fedora 13 and allows me to correctly boot it (I can’t honestly understand where it has found the right parameters, it seems like it has read and copied the grub legacy configuration file) and i was still able to boot both the OSs.

My first question is why this happend ? And, secondly, how can I avoid a disaster like that to happen again ?
I had a look to zypper log and i didn’t find any update to the grub package. I saw instead that the kernel was updated and i suppose this could be the problem. After the kernel update the grub configuration file has to be modified, but why it issued a complete grub-install overwriting the (wrong) MBR ???

Any ideas ?

P.S. In the meantime I recovered the situation reinstalling grublegacy on sda (from fedora13)and grub2 on sde (from opensuse12.3).

The problem would be if Grub got updated I would imagine and I can say that in the past and on dual or triple boot setups, such a thing has happened to me. To see what was installed last, you can use the following command:

rpm -q --all --last 

If you are a big zypper user and fan, you must check out my bash script Zypper Command you can find here:

Zypper Command - Zypper Package Management Menu System - Version 2.00 - Blogs - openSUSE Forums

Thank You,

I think some have reported this behaviour as a bug.
That openSUSE writes the new bootloader info to the MBR…!

It doesn’t bother me. Though most distros don’t behave this way.
I’m unsure of any methods to prevent this.

Could be the initial config for openSUSE was to write the code to MBR. If Fedora was installed afterwards, and now openSUSE updates the kernel (hence reconfiguration of GRUB2), wouldn’t that explain it?

Please, confirm that your openSUSE is configured to use grub2 as bootloader:

bor@opensuse:~/build/grub> grep LOADER_TYPE /etc/sysconfig/bootloader
LOADER_TYPE="grub2"
bor@opensuse:~/build/grub> 

and if yes, please paste content of /etc/default/grub_installdevice and possibly /boot/grub2/device.map if exists.

Hi,
grub was not updated in the last “zypper up” session, but the kernel instead was in.


rpm -q --all --last | grep grub
grub2-branding-openSUSE-12.2-11.12.1          Tue May 28 00:30:19 2013
grub2-2.00-1.23.1                             Tue May 28 00:29:32 2013
grub-0.97-185.1.2                             Mon May 27 23:29:20 2013
rpm -q --all --last | grep kernel
kernel-desktop-3.4.47-2.38.1                  Sat Sep 21 20:40:29 2013
kernel-desktop-3.4.42-2.28.1                  Mon May 27 23:56:20 2013
kernel-desktop-3.4.6-2.10.1                   Mon May 27 23:32:42 2013

So my suspect is that the kernel update process was involved in the problem

Fedora was installed before (several years before) of OpenSuse. After the installation there were at least an update package for grub2 and one for the kernel (as you can see from my previous post), without any adverse effect on Fedora Grub1.

Hi,
I confirm the bootloader is grub2 since the installation


# grep LOADER_TYPE /etc/sysconfig/bootloader
LOADER_TYPE="grub2"

So I have had a look into the file you suggested and I was really surprised to see this:


#cat /etc/default/grub_installdevice
/dev/sda
activate
generic_mbr

# cat /boot/grub2/device.map
(hd0)   /dev/sda

I’m absolutely sure the first grub installation was on /dev/sde and i’m absolutely sure that, until 3 days ago, /dev/sda has contained a grub-legacy MBR from which i have always booted fedora13 and, via chainload, Opensuse!

I’m sorry, in my first post i did a mistake, I’m talking about OpenSuSE 12.2 64 bit and NOT 12.3

Sorry again.


cat /etc/SuSE-release
openSUSE 12.2 (x86_64)
VERSION = 12.2
CODENAME = Mantis

On 2013-09-23 20:56, jjletho wrote:

> So my suspect is that the kernel update process was involved in the
> problem

The kernel update triggers some sort of grub reinstall. At least it has
to add/remove entries in the menu. I heard that openSUSE 12.3 does
somewhat more than needed with grub2.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

Yes
openSUSE writes not just the menu but also re-writes the MBR

Well, this explains why your MBR now contains grub2 from openSUSE.

Perhaps, prior to install OpenSuSE, i disconnected the disks on which Fedora is installed to be sure they weren’t modified. This could explain why grub_installdevice contains a reference to /dev/sda instead of /dev/sde
So the installation of grub2 over sda it’s not an unexpected behavior.

I still can’t explain why it’s necessary to rewrite the mbr after a kernel update. Isn’t the modification of grub.cfg enough ?

On 2013-09-24 05:26, caf4926 wrote:
>
> robin_listas;2587160 Wrote:
>> On 2013-09-23 20:56, jjletho wrote:
>>
>>> So my suspect is that the kernel update process was involved in the
>>> problem
>>
>> The kernel update triggers some sort of grub reinstall. At least it has
>> to add/remove entries in the menu. I heard that openSUSE 12.3 does
>> somewhat more than needed with grub2.

> Yes
> openSUSE writes not just the menu but also re-writes the MBR

I wonder why. Mistake, or intentional?
Some unknown advantage, perhaps? :-?


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

This should be fixed in factory, although I cannot find bug number right now and it is not mentioned in commit.

I have just had a look to bugzilla, but i didn’t find anything related to useless writing into MBR or while it is unnecessary. could you please give us a reference ?
Thank you very much!

I wonder if your YaST Boot Loader settings might some effect when the right update is set in motion? Here is the default on my setup.

http://paste.opensuse.org/view/download/56792309

Notice how the Set the active partition and write generic boot code are checked here.

Thank You,

I’m not sure if there is any bugzilla for that; here is commit: https://github.com/openSUSE/perl-bootloader/commit/cca07fe1bb30d58e797e2db41f7e3f82da991e00 and update-bootloader in 13.1:

linux-9o75:~ # update-bootloader --help
Usage:
    update-bootloader [operation] [options]

    operation is one of --add, --remove, --refresh or --reinit.

    valid options are --help, --man, --image <file>, --initrd <file>,
    --xen-kernel <file>, --xen, --default, --previous, --name <string>,
    --force, --force-default.

linux-9o75:~ # exit

–refresh is used by mkinitrd and only updates configuration, --reinit reinstalls grub2 and is used by RPM scripts.