From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JI18p-0003dt-AT for mharc-grub-devel@gnu.org; Thu, 24 Jan 2008 07:25:11 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JI18n-0003ac-As for grub-devel@gnu.org; Thu, 24 Jan 2008 07:25:09 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JI18l-0003YI-CW for grub-devel@gnu.org; Thu, 24 Jan 2008 07:25:08 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JI18l-0003Y5-8e for grub-devel@gnu.org; Thu, 24 Jan 2008 07:25:07 -0500 Received: from mx1.rz.ruhr-uni-bochum.de ([134.147.32.86]) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1JI18k-0007Fc-Fa for grub-devel@gnu.org; Thu, 24 Jan 2008 07:25:07 -0500 X-Queued: (qmail 25192 invoked by uid 281); 24 Jan 2008 12:25:04 -0000 X-Qmailscanner: from 134.147.252.214 by mx1.rz.ruhr-uni-bochum.de (envelope-from , uid 80) with qmail-scanner-2.01 (sophie: 3.05/2.52/4.24. Clear:RC:1(134.147.252.214):. Processed in 0.657184 secs); 24 Jan 2008 12:25:04 -0000 Received: from router.leat.ruhr-uni-bochum.de (134.147.252.214) by mx1.rz.ruhr-uni-bochum.de with SMTP; 24 Jan 2008 12:25:03 -0000 Received: from [134.147.55.45] (frodo.leat.ruhr-uni-bochum.de [134.147.55.45]) by router.leat.ruhr-uni-bochum.de (8.12.2/8.12.2/SuSE Linux 0.6) with ESMTP id m0OCTD1l018466; Thu, 24 Jan 2008 13:29:13 +0100 Message-ID: <479883AD.6060005@leat.rub.de> Date: Thu, 24 Jan 2008 13:25:17 +0100 From: Fabian Greffrath User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: grub-devel@gnu.org Content-Type: multipart/mixed; boundary="------------000804070605070903080609" X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 Cc: 461442@bugs.debian.org Subject: please add support for os-prober to detect other OSes in update-grub X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2008 12:25:09 -0000 This is a multi-part message in MIME format. --------------000804070605070903080609 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit 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. Cheers, Fabian [1] http://bugs.debian.org/461442 [2] http://lists.gnu.org/archive/html/grub-devel/2008-01/msg00446.html http://bugs.debian.org/462218 -- 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: greffrath@leat.ruhr-uni-bochum.de --------------000804070605070903080609 Content-Type: text/plain; name="30_os-prober" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="30_os-prober" #! /bin/sh -e # update-grub helper script. # 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' ' '`" fi 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? LONGNAME="${LABEL}" fi case "${BOOT}" in chain) echo "Found ${LONGNAME} on ${PARTITION}" >&2 if [ -x "`which grub-probe 2>/dev/null`" ] ; then # need to convert partition device to GRUB drive here! GRUB_DEVICE="`grub-probe --something ${PARTITION}`" cat << EOF menuentry "${LONGNAME} (on ${PARTITION})" { set root=${GRUB_DEVICE} chainloader +1 } EOF else # wtf?! echo " Error: Missing grub-probe!" >&2 fi ;; macos|macosx) # can't macos* also be chainloaded? ;; hurd|linux) # other Linux/HURD-Systems are not (yet) supported # with the given output of os-prober ;; *) # is it possible to reach here? ;; esac done fi --------------000804070605070903080609--