[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#409820: initramfs-tools: mbr_check() does not work reliable with lilo and grub around



Package: initramfs-tools
Severity: important


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.

My proposed fix is to use:

   dd if="${boot}" bs=512 skip=0 count=1 2> /dev/null | hexdump | \
      grep -q '0000000 ebfa .... .... 494c 4f4c' \
      && run_lilo && return 0

This will check for lilo's clear interrupt instruction (fa), the
jump instruction (eb) and the string LILO itself (494c 4f4c).
(hexdump is part of bsdmainutils, if you have another variant you
prefer feel free to adjust above code, I can test it for you of
course.)

JFTR the header looks like the following on a x86 32 bit system
(notice the use of hexdump's -C option in the second command):

# dd if=/dev/hda bs=512 skip=0 count=1 2> /dev/null | hexdump | head -1
0000000 ebfa 0121 01b5 494c 4f4c 0616 b884 4575
# dd if=/dev/hda bs=512 skip=0 count=1 2> /dev/null | hexdump -C | head -1
00000000  fa eb 21 01 b5 01 4c 49  4c 4f 16 06 84 b8 75 45  |úë!.µ.LILO...žuE|

On another x86 32 bit system where initramfs-tools' current check
fails:

# dd if=/dev/sda bs=512 skip=0 count=1 2> /dev/null | hexdump | head -1
0000000 48eb 0190 01b4 494c 4f4c 0716 0783 45c7
# dd if=/dev/sda bs=512 skip=0 count=1 2> /dev/null | hexdump -C | head -1
00000000  eb 48 90 01 b4 01 4c 49  4c 4f 16 07 83 07 c7 45  |.H....LILO.....E|

I'v tested my proposed fix on several boxes with lilo 22.6.1 and
22.7.3 and on one system where lilo was around and grub is present
now. The tested lilo versions are the ones used in current stable,
testing and unstable so we should have an appropriate fix which
should enter Etch. If you have any package(s) for testing please let
me know...

regards,
-mika-



Reply to: