How to restore the MBR after do-release-upgrade?

Ralf Mardorf silver.bullet at zoho.com
Thu Jul 7 14:36:55 UTC 2016


On Thu, 07 Jul 2016 15:11:36 +0200, Nils Kassube wrote:
>Ralf Mardorf wrote:
>> the    # do-release-upgrade    from Wily 15.10 to Xenial 16.04
>> installed the GRUB packages. There was no way to deny the
>> installation. I now try to get rid of GRUB, allegedly written to
>> /dev/sda, by restoring the MBR of all connected drives.
>> 
>> The dd command claims to be ok, but after running
>> 
>>   [root at moonstudio 2016-May]# dd
>> if=MBR_SDA-20160506_155555.may_2_0_1_6 of=/dev/sda bs=512 count=1  
>[...]
>> still the new Ubuntu GRUB menu appears. I tried several times, also  
>[...]
>> but I never get back the setup I used before GRUB was installed by
>> do-release-upgrade.  
>
>What boot loader did you have installed before the release upgrade?
>The dd command would only fail if there is a read or write error. But
>I suppose the data you want to write are incomplete, i.e. the MBR part
>is only a tiny bit of the data GRUB uses to boot. If you had an
>earlier version of GRUB before, you only overwrite the very first part
>which may be identical to the new version. GRUB uses a huge chunk of
>the space between the MBR and the first partition.

Hi,

before the release upgrade GRUB2 was used, too, but from a former
Debian install. IIRC in the past restoring the MBR always worked.
However, if it should be impossible to restore the old setup, I
temporarily could use the new Ubuntu GRUB. Unfortunately the
automatically generated grub.cfg doesn't automatically include FreeBSD,
so I added the chainloder, that worked before the release upgrade.

[weremouse at moonstudio ~]$ sudo fdisk -l | grep -i freebsd
/dev/sda1  *           63 121274495 121274433  57.8G a5 FreeBSD
[weremouse at moonstudio ~]$ sudo parted -l | grep freebsd
 1      32.3kB  62.1GB  62.1GB  primary   freebsd-ufs     boot
[weremouse at moonstudio ~]$ grep -i freebsd -A3 /boot/grub/grub.cfg 
menuentry "FreeBSD"{
    set root=(hd0,msdos1)
    chainloader +1
}

I also edited grub.cfg to boot my Arch Linux kernels with special
parameters, such as "threadirqs". While booting Arch Linux doesn't
fail, booting FreeBSD is broken now.

The chainloader works, but the FreeBSD loader now fails with "R/W mount
of ada0s9 denied due to unsupported optional features", even after
running fsck. The only plausible explanation seems to be, that the
enforced written GRUB to /dev/sda damaged something, that even can't be
fixed by restoring the MBR and that wasn't damaged by the GRUB2 used
before.

[weremouse at moonstudio ~]$ sudo update-grub -o /tmp/grub.txt
Doesn't notice that there is a FreeBSD install. There even isn't a
warning or error, it doesn't notice FreeBSD at all.

During the upgrade there was a mount error or warning regarding a bad
magic number of the FreeBSD's ufs. I neither know what tried to mount
ufs, nor what options were used, it happened to fast.

Mounting it now doesn't cause a warning or error.

[root at moonstudio weremouse]# mkdir /mnt/freebsd
[root at moonstudio weremouse]# mount -r -t ufs -o ufstype=ufs2 /dev/sda1 /mnt/freebsd/ 
[root at moonstudio weremouse]# ls -hAl /mnt/freebsd/
total 31M
drwxr-xr-x  2 root      root 1.0K Dec 23  2012 bin
drwxr-xr-x  8 root      root 1.0K Dec 23  2012 boot
[snip]

Excepted of confusing FreeBSD with an unknown Linux distro, I can't
find anything related in the log files.

[root at moonstudio weremouse]# strings /var/log/dist-upgrade/* | grep -B1 -A1 sda1 | grep -v 15
Found memtest86+ image: /boot/memtest86+.bin
Found unknown Linux distribution on /dev/sda1
Found openSUSE 11.2 RC 1 (x86_64) on /dev/sda7
--
Found memtest86+ image: /boot/memtest86+.bin
Found unknown Linux distribution on /dev/sda1
Found openSUSE 11.2 RC 1 (x86_64) on /dev/sda7

Regards,
Ralf





More information about the ubuntu-users mailing list