Bug#409820: initramfs-tools: mbr_check() does not work reliable with lilo and grub around
hello mika,
thanks a lot for your report.
On Mon, 05 Feb 2007, Michael Prokop wrote:
>
> Inside the mbr_check function in /usr/sbin/update-initramfs we have:
>
> dd if="${boot}" bs=512 skip=0 count=1 2> /dev/null | grep -q LILO \
> && run_lilo && return 0
>
> This does not work reliable in the following scenario:
>
> * lilo is installed first
> * grub is installed afterwards
>
> It does not work in that case because grub does *not* clear lilo's
> signature. So the string LILO might be found even though grub is the
> used and present bootmanager. With the above code we install lilo
> in the MBR wheras we want to use grub. => The system might not even
> boot anymore after upgrading and executing update-initramfs.
i would prefer another solution:
what about if we check _before_ for GRUB, does lilo overwrite that
string?
that would mean to put the grub section of mbr_check in front.
could you please test the following patch, i'm currently away
and not very keen on testing bootloader stuff on my laptop..
thanks
=== modified file 'update-initramfs'
--- update-initramfs 2006-12-14 22:16:15 +0000
+++ update-initramfs 2007-02-14 09:41:16 +0000
@@ -146,6 +148,16 @@
# check if lilo is on mbr
mbr_check()
{
+ # try to discover grub and be happy
+ [ -r /boot/grub/menu.lst ] \
+ && groot=$(awk '/^root/{print substr($2, 2, 3); exit}' \
+ /boot/grub/menu.lst)
+ [ -e /boot/grub/device.map ] && [ -n "${groot}" ] \
+ && dev=$(awk "/${groot}/{ print \$NF}" /boot/grub/device.map)
+ [ -n "${dev}" ] && [ -r ${dev} ] \
+ && dd if="${dev}" bs=512 skip=0 count=1 2> /dev/null \
+ | grep -q GRUB && return 0
+
# check out lilo.conf for validity
boot=$(awk -F = '/^boot=/{ print $2}' /etc/lilo.conf)
[ -z "${boot}" ] && return 0
@@ -162,16 +174,6 @@
dd if="${boot}" bs=512 skip=0 count=1 2> /dev/null | grep -q LILO \
&& run_lilo && return 0
- # try to discover grub and be happy
- [ -r /boot/grub/menu.lst ] \
- && groot=$(awk '/^root/{print substr($2, 2, 3); exit}' \
- /boot/grub/menu.lst)
- [ -e /boot/grub/device.map ] && [ -n "${groot}" ] \
- && dev=$(awk "/${groot}/{ print \$NF}" /boot/grub/device.map)
- [ -n "${dev}" ] && [ -r ${dev} ] \
- && dd if="${dev}" bs=512 skip=0 count=1 2> /dev/null \
- | grep -q GRUB && return 0
-
# no idea which bootloader is used
echo
echo "WARNING: grub and lilo installed."
--
maks
Reply to: