From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KMVVt-0007gj-SA for mharc-grub-devel@gnu.org; Fri, 25 Jul 2008 18:11:49 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KMVVs-0007ge-17 for grub-devel@gnu.org; Fri, 25 Jul 2008 18:11:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KMVVq-0007gS-HB for grub-devel@gnu.org; Fri, 25 Jul 2008 18:11:46 -0400 Received: from [199.232.76.173] (port=35146 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KMVVq-0007gP-BW for grub-devel@gnu.org; Fri, 25 Jul 2008 18:11:46 -0400 Received: from aybabtu.com ([69.60.117.155]:50344) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KMVVq-0005Hg-0g for grub-devel@gnu.org; Fri, 25 Jul 2008 18:11:46 -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.69) (envelope-from ) id 1KMVPc-0005fB-QA for grub-devel@gnu.org; Sat, 26 Jul 2008 00:05:21 +0200 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1KMVUw-00088o-2a for grub-devel@gnu.org; Sat, 26 Jul 2008 00:10:50 +0200 Date: Sat, 26 Jul 2008 00:10:50 +0200 From: Robert Millan To: The development of GRUB 2 Message-ID: <20080725221050.GA31179@thorin> References: <20080722133416.GB5524@archvile> <20080722095021.p15u40gtyc88csco-cebfxv@webmail.spamcop.net> <3FA357AE49694559941A663191155DE2@fz> <5A50C2D990914B3F8A73A02D520E8DED@fz> <1216918145.22586.14.camel@dv> <20080725210840.GA19505@thorin> <1217022420.3957.3.camel@dv> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="NzB8fVQJ5HfG6fxh" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1217022420.3957.3.camel@dv> 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] use UUIDs for cross-disk installs (Re: Issue with boot != root and chainloading) 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, 25 Jul 2008 22:11:48 -0000 --NzB8fVQJ5HfG6fxh Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Fri, Jul 25, 2008 at 05:47:00PM -0400, Pavel Roskin wrote: > On Fri, 2008-07-25 at 23:08 +0200, Robert Millan wrote: > > On Thu, Jul 24, 2008 at 12:49:05PM -0400, Pavel Roskin wrote: > > > > > > As I said, GRUB uses its internal ID instead of BIOS ID. We need to fix > > > it. > > > > Why not just remove that logic and use UUIDs instead? It would also simplify > > the code both in grub-setup and in kernel, maybe even make it smaller. > > I have no objections to that plan. We'll need UUID search functionality > on core.img. I understand you implemented it already. Is it committed? Yes. There's a virtual disk in fs_uuid.mod which can be optionaly loaded in. > Where should we put the root UUID in core.img? In grub_prefix. It already supports this, since it was needed for root-in-LVM setups. See attached patch. I'm afraid it doesn't make kernel smaller as promised; I expected to get rid of make_install_device() in kernel, but later noticed that this is still needed for non-cross installs. 2008-07-26 Robert Millan * include/grub/i386/pc/kernel.h (GRUB_KERNEL_MACHINE_DATA_END): Increase from 0x50 to 0x60. * util/i386/pc/grub-install.in: Detect cross-disk installs, and use UUIDs to identify the root drive for them. If that's not possible, abort. * util/i386/pc/grub-setup.c (setup): Do not special-case, or even check, for cross-disk installs. -- 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 /.) --NzB8fVQJ5HfG6fxh Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="uuid_boot.diff" 2008-07-26 Robert Millan * include/grub/i386/pc/kernel.h (GRUB_KERNEL_MACHINE_DATA_END): Increase from 0x50 to 0x60. * util/i386/pc/grub-install.in: Detect cross-disk installs, and use UUIDs to identify the root drive for them. If that's not possible, abort. * util/i386/pc/grub-setup.c (setup): Do not special-case, or even check, for cross-disk installs. Index: include/grub/i386/pc/kernel.h =================================================================== --- include/grub/i386/pc/kernel.h (revision 1733) +++ include/grub/i386/pc/kernel.h (working copy) @@ -41,7 +41,7 @@ #define GRUB_KERNEL_MACHINE_PREFIX 0x20 /* End of the data section. */ -#define GRUB_KERNEL_MACHINE_DATA_END 0x50 +#define GRUB_KERNEL_MACHINE_DATA_END 0x60 /* The size of the first region which won't be compressed. */ #if defined(ENABLE_LZO) Index: util/i386/pc/grub-install.in =================================================================== --- util/i386/pc/grub-install.in (revision 1733) +++ util/i386/pc/grub-install.in (working copy) @@ -233,15 +233,34 @@ # Device abstraction module, if any (lvm, raid). devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}` +# The order in this list is critical. Be careful when modifying it. +modules="$modules $fs_module $partmap_module biosdisk $devabstraction_module" + +prefix_drive= if [ "x${devabstraction_module}" = "x" ] ; then - prefix_drive= + if echo "${install_device}" | grep -qx "(.*)" ; then + install_drive="${install_device}" + else + install_drive="`$grub_probe --target=drive --device ${install_device}`" + fi + grub_drive="`$grub_probe --target=drive --device ${grub_device}`" + + # Strip partition number + install_drive="`echo ${install_drive} | sed -e s/,[0-9]*//g`" + grub_drive="`echo ${grub_drive} | sed -e s/,[0-9]*//g`" + if [ "x${grub_drive}" != "x${install_drive}" ] ; then + uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`" + if [ "x${uuid}" = "x" ] ; then + echo "You attempted a cross-disk install, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2 + exit 1 + fi + prefix_drive="(UUID=${uuid})" + modules="$modules fs_uuid" + fi else prefix_drive=`$grub_probe --target=drive --device ${grub_device}` fi -# The order in this list is critical. Be careful when modifying it. -modules="$modules $fs_module $partmap_module biosdisk $devabstraction_module" - grub_prefix="${prefix_drive}`make_system_path_relative_to_its_root ${grubdir}`" || exit 1 $grub_mkimage --output=${grubdir}/core.img --prefix=${grub_prefix}/ $modules || exit 1 Index: util/i386/pc/grub-setup.c =================================================================== --- util/i386/pc/grub-setup.c (revision 1733) +++ util/i386/pc/grub-setup.c (working copy) @@ -339,18 +339,12 @@ if (grub_disk_write (dest_dev->disk, embed_region.start, 0, core_size, core_img)) grub_util_error ("%s", grub_errmsg); - /* The boot image and the core image are on the same drive, - so there is no need to specify the boot drive explicitly. */ - *boot_drive = 0xff; + /* FIXME: can this be skipped? */ + *boot_drive = 0xFF; + *root_drive = 0xFF; + *kernel_sector = grub_cpu_to_le64 (embed_region.start); - /* If the root device is different from the destination device, - it is necessary to embed the root drive explicitly. */ - if (root_dev->disk->id != dest_dev->disk->id) - *root_drive = (grub_uint8_t) root_dev->disk->id; - else - *root_drive = 0xFF; - /* Write the boot image onto the disk. */ if (grub_disk_write (dest_dev->disk, 0, 0, GRUB_DISK_SECTOR_SIZE, boot_img)) @@ -480,15 +474,8 @@ *kernel_sector = grub_cpu_to_le64 (first_sector); - /* If the destination device is different from the root device, - it is necessary to embed the boot drive explicitly. */ - if (root_dev->disk->id != dest_dev->disk->id) - *boot_drive = (grub_uint8_t) root_dev->disk->id; - else - *boot_drive = 0xFF; - - /* When the core image is not embedded, the root device always follows - the boot device. */ + /* FIXME: can this be skipped? */ + *boot_drive = 0xFF; *root_drive = 0xFF; *install_dos_part = grub_cpu_to_le32 (dos_part); --NzB8fVQJ5HfG6fxh--