[Top][All Lists]

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

please add support for os-prober to detect other OSes in update-grub

From: Fabian Greffrath
Subject: please add support for os-prober to detect other OSes in update-grub
Date: Thu, 24 Jan 2008 13:25:17 +0100
User-agent: Thunderbird (Windows/20071031)

Dear GRUB-developers,

I recently had a discussion with the GRUB-maintainers in Debian if it will be possible to add other (maybe proprietary, preinstalled) OSes to the GRUB boot menu when update-grub is run [1]. This happens automatically when Debian is installed (via the Debian-Installer) using a tool called 'os-prober'. This tool mounts all possible partitions and reports if it finds an OS on these partitions. This means it should be possible to run 'os-prober' and interpret it's output to generate further GRUB menu entries every time update-grub is started. For this purpose, please find my approach for an /etc/grub.d/30_os-prober script attached. It is only 1.5 kB, tab-indented and full of comments and paranoid tests. If it is considered usefull, though, I'd like to hand it over (including copyright!) to the GRUB-developers.

At the moment there is still one problem left: os-prober returns the partition on which it finds the OS as a system device name, e.g. /dev/hda2. At the moment, GRUB does not provide an (easy) way to translate these into GRUB drives, e.g. (hd0,1). This is why I allready requested such a feature on this list [2]. Another problem (or: missing feature) is, that at the moment my script can only add chainloaded OSes to grub.cfg. To add kernels like Linux or HURD it is necessary to mount these partitions again to find out exactly where the kernel and initrd images reside. This is something I want to avoid, because the partitions have allready been mounted by os-prober and I don't want to duplicate it's code for this purpose. Maybe os-prober could be modified to be more verbose in such cases and report the entire path to the images.

You may consider this a very Debian specific problem/feature, but I believe once os-prober finds more attention by other Linux distributions it will provide a very valuable means to automatically detect other OSes and add them to the boot menu.



Dipl.-Phys. Fabian Greffrath

Ruhr-Universität Bochum
Lehrstuhl für Energieanlagen und Energieprozesstechnik (LEAT)
Universitätsstr. 150, IB 3/134
D-44780 Bochum

Telefon: +49 (0)234 / 32-26334
Fax:     +49 (0)234 / 32-14227
E-Mail:  address@hidden

#! /bin/sh -e

# update-grub helper script.
# <insert copyright and license blurb here>

if [ -x "`which os-prober 2>/dev/null`" ] ; then
        # os-prober output contains the partition and the name, a label and
        # a boot keyword, separated by colons (:) for each detected OS.
        # It may contain space characters and linebreaks,
        # e.g. "/dev/hda2:Windows XP Professional:Windows:chain".
        # Convert space characters to underscores and linebreaks to spaces.
        RESULT="`os-prober | tr ' ' '_' | tr '\n' ' '`"

if [ "x${RESULT}" != "x" ] ; then
        for OS in "${RESULT}" ; do
                # e.g. "/dev/hda2:Windows_XP_Professional:Windows:chain"
                PARTITION="`echo ${OS} | cut -d ':' -f 1`"
                LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '_' ' '`"
                LABEL="`echo ${OS} | cut -d ':' -f 3`"
                BOOT="`echo ${OS} | cut -d ':' -f 4`"

                if [ "x${LONGNAME}" = "x" ] ; then
                        # is this likely to happen?

                case "${BOOT}" in
                                echo "Found ${LONGNAME} on ${PARTITION}" >&2
                                if [ -x "`which grub-probe 2>/dev/null`" ] ; 
                                        # need to convert partition device to 
GRUB drive here!
                                        GRUB_DEVICE="`grub-probe --something 
                                        cat << EOF
menuentry "${LONGNAME} (on ${PARTITION})" {
        set root=${GRUB_DEVICE}
        chainloader +1
                                else # wtf?!
                                        echo "  Error: Missing grub-probe!" >&2
                                # can't macos* also be chainloaded?
                                # other Linux/HURD-Systems are not (yet) 
                                # with the given output of os-prober
                                # is it possible to reach here?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]