Does GRUB upgrade store a copy of the old MBR

Asked by Ronan Mooney

During an upgrade yesterday, it seems that Grub overwrote my MBR without confirmation (Grub was actually installed on /dev/sda1 not /dev/sda)

What WAS on the MBR was a Trucrypt boot loader, which was set up to allow dual booting. Unfortunately, when I restored the boot loader using a rescue disk, the dual boot functionality did not work as expected. Did the Grub upgrade take a copy of the MBR before it was overwritten?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu grub2 Edit question
Assignee:
No assignee Edit question
Solved by:
Ronan Mooney
Solved:
Last query:
Last reply:
Revision history for this message
Ronan Mooney (roomey) said :
#1

I have created a bug report also, there is a bit more info there about the background of what happened.

Revision history for this message
Eliah Kagan (degeneracypressure) said :
#2

GRUB does not make a backup of the MBR before overwriting it. This behavior is normal, and is not considered to be a bug, though as Colin Watson says, GRUB might back up the MBR in the future. If you want a different bootloader than GRUB installed in the MBR, then GRUB should not be configured to use the MBR at all; instead, you can install it at the beginning of your Ubuntu partition and chain-load into it using your other boot loader.

Bug 495423 *is* a bug, because in that case, GRUB installed itself to the MBR of the wrong hard disk. That does *not* seem to be the same as your situation.

Revision history for this message
delance (olivier-delance) said :
#3

Usually, we only needs to solve issue to reinstall MBR of Windows XP or which one of Vista/Seven (which don't save either previous MBR). So few people need to save MBR, and it's not a priority. Currently, it's to you to save MBR, which is not only first sector of disk, but 64 first sectors of disk.

Revision history for this message
Eliah Kagan (degeneracypressure) said :
#4

Hiren's BootCD contains some tools that will back up MBR's:
http://www.hiren.info/pages/bootcd

Revision history for this message
Ronan Mooney (roomey) said :
#5

Hi,
Thanks for the information. I think my issue here is with the terminology. I do agree the following:#

Grub SHOULD have been reconfigured after I ran grub install to move the boot information from /dev/sda to /dev /sda1.

The forums did not mention this of course. So right here there could have been a message saying I should reconfigure grub. I was under the impression that running grub-install would install it and upadate the configuration

Yes I should have backed up the MBR, in fact I had, on a truecrypt boot disk. The problem was it did not restore correctly (it was not an exact copy), on another PC it did- this problem hit two PCs. I think before you use it to restore you must set the windows encrypted partition as the boot partition (or set the boot label on it).

Anyway, I would still say this is a bug. When you run upgrade, it should not break a system. I did not mean to reinstall Grub, so was not expecting the MBR to be touched.

The MBR itself is very small, so I think creating a copy of it in the boot folder would not be difficult and wasteful. I am sure in other situations a grub update has left people with a broken system.

@Eliah- I think you will find Bug 495423 is actually the same problem, although they do reference a different bug (the one where the RAID was broken.

I think this could be a simple fix that could help people revert to a working system quickly, if there is a botched install of Grub.

Revision history for this message
Ronan Mooney (roomey) said :
#6

dd if=/dev/sda of=/boot/mbrsda.bak bs=512 count=1

Is a good way to backup an MBR.
(NB: Be careful with this command, it it is mistyped it could damage your filesystem)