From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1K4eW2-0006sP-Qb for mharc-grub-devel@gnu.org; Fri, 06 Jun 2008 12:10:10 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K4eVz-0006rj-NN for grub-devel@gnu.org; Fri, 06 Jun 2008 12:10:07 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K4eVy-0006qh-0p for grub-devel@gnu.org; Fri, 06 Jun 2008 12:10:07 -0400 Received: from [199.232.76.173] (port=44622 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K4eVx-0006qF-SK for grub-devel@gnu.org; Fri, 06 Jun 2008 12:10:05 -0400 Received: from aybabtu.com ([69.60.117.155]:43203) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1K4eVv-0001qz-VJ for grub-devel@gnu.org; Fri, 06 Jun 2008 12:10:04 -0400 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1K4eUj-0005mv-Oc for grub-devel@gnu.org; Fri, 06 Jun 2008 18:08:50 +0200 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1K4eVe-0003aC-Cq for grub-devel@gnu.org; Fri, 06 Jun 2008 18:09:46 +0200 Date: Fri, 6 Jun 2008 18:09:46 +0200 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20080606160946.GA13716@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="xHFwDpU9dbj6ez1V" Content-Disposition: inline Content-Transfer-Encoding: 8bit Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [PATCH] boot from LVM / RAID 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: Fri, 06 Jun 2008 16:10:08 -0000 --xHFwDpU9dbj6ez1V Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit This patch makes it possible to boot directly from LVM or RAID. It is archieved by permitting that grub_prefix include a drive component as part of its path. The kernel already knows how to extract root from there, as long as `grub_install_dos_part == -2'. -- Robert Millan I know my rights; I want my phone call! What good is a phone call… if you are unable to speak? (as seen on /.) --xHFwDpU9dbj6ez1V Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="root_on_lvm.diff" 2008-06-06 Robert Millan Make boot directly from LVM or RAID possible. * kern/i386/pc/init.c (make_install_device): Remove memdisk check. It is assumed that if we have a memdisk, grub-mkimage has set grub_prefix to include the "(memdisk)" drive in it. * util/i386/pc/grub-install.in (prefix_drive): New variable. If we need to include a drive in the prefix (because we're installing on LVM or RAID), it is set in this variable. Include ${grub_prefix} in `--prefix' parameter of ${grub_mkimage} invokation. * util/i386/pc/grub-mkimage.c (main): If a memdisk was requested, add "(memdisk)" drive explicitly to the beginning of the prefix. * util/i386/pc/grub-setup.c (setup): Don't write to `install_prefix', since it has been set by grub-mkimage based on request from grub-install, which knows better than anyone else which prefix we need. diff -x ChangeLog -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/kern/i386/pc/init.c ./kern/i386/pc/init.c --- ../grub2/kern/i386/pc/init.c 2008-04-07 16:34:46.000000000 +0200 +++ ./kern/i386/pc/init.c 2008-06-06 16:14:37.000000000 +0200 @@ -64,12 +64,7 @@ make_install_device (void) /* XXX: This should be enough. */ char dev[100]; - if (grub_memdisk_image_size) - { - grub_sprintf (dev, "(memdisk)%s", grub_prefix); - grub_strcpy (grub_prefix, dev); - } - else if (grub_install_dos_part != -2) + if (grub_install_dos_part != -2) { /* If the root drive is not set explicitly, assume that it is identical to the boot drive. */ diff -x ChangeLog -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/util/i386/pc/grub-install.in ./util/i386/pc/grub-install.in --- ../grub2/util/i386/pc/grub-install.in 2008-06-06 17:49:43.000000000 +0200 +++ ./util/i386/pc/grub-install.in 2008-06-06 17:50:39.000000000 +0200 @@ -231,10 +231,18 @@ partmap_module=`$grub_probe --target=par # Device abstraction module, if any (lvm, raid). devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}` +if [ "x${devabstraction_module}" = "x" ] ; then + prefix_drive= +else + prefix_drive=`$grub_probe --target=drive --device ${grub_device}` +fi + # _chain is often useful modules="$modules $fs_module $partmap_module biosdisk $devabstraction_module _chain" -$grub_mkimage --output=${grubdir}/core.img --prefix=`make_system_path_relative_to_its_root ${grubdir}`/ $modules || exit 1 +$grub_mkimage --output=${grubdir}/core.img \ + --prefix=${prefix_drive}`make_system_path_relative_to_its_root ${grubdir}`/ \ + $modules || exit 1 # Now perform the installation. $grub_setup --directory=${grubdir} --device-map=${device_map} \ diff -x ChangeLog -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/util/i386/pc/grub-mkimage.c ./util/i386/pc/grub-mkimage.c --- ../grub2/util/i386/pc/grub-mkimage.c 2008-01-21 16:48:27.000000000 +0100 +++ ./util/i386/pc/grub-mkimage.c 2008-06-06 12:36:57.000000000 +0200 @@ -278,6 +278,11 @@ main (int argc, char *argv[]) free (memdisk); memdisk = xstrdup (optarg); + + if (prefix) + free (prefix); + + prefix = xstrdup ("(memdisk)/boot/grub"); break; case 'h': diff -x ChangeLog -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/util/i386/pc/grub-setup.c ./util/i386/pc/grub-setup.c --- ../grub2/util/i386/pc/grub-setup.c 2008-05-06 15:34:29.000000000 +0200 +++ ./util/i386/pc/grub-setup.c 2008-06-06 17:52:00.000000000 +0200 @@ -330,7 +330,6 @@ setup (const char *prefix, const char *d grub_le_to_cpu32 (*install_dos_part), grub_le_to_cpu32 (*install_bsd_part), prefix); - strcpy (install_prefix, prefix); /* Write the core image onto the disk. */ if (grub_disk_write (dest_dev->disk, embed_region.start, 0, core_size, core_img)) @@ -518,7 +517,6 @@ setup (const char *prefix, const char *d grub_le_to_cpu32 (*install_dos_part), grub_le_to_cpu32 (*install_bsd_part), prefix); - strcpy (install_prefix, prefix); /* Write the first two sectors of the core image onto the disk. */ core_path = grub_util_get_path (dir, core_file); --xHFwDpU9dbj6ez1V--