From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JCGI7-00046L-PH for mharc-grub-devel@gnu.org; Tue, 08 Jan 2008 10:22:59 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JCGI6-00045H-1f for grub-devel@gnu.org; Tue, 08 Jan 2008 10:22:58 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JCGI4-00044M-FD for grub-devel@gnu.org; Tue, 08 Jan 2008 10:22:57 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JCGI4-00044D-51 for grub-devel@gnu.org; Tue, 08 Jan 2008 10:22:56 -0500 Received: from aybabtu.com ([69.60.117.155]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JCGI3-0001o6-Lf for grub-devel@gnu.org; Tue, 08 Jan 2008 10:22:55 -0500 Received: from [192.168.10.6] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1JCGHv-00028i-O1; Tue, 08 Jan 2008 16:22:52 +0100 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1JCGGE-0003T3-Jl; Tue, 08 Jan 2008 16:21:02 +0100 Date: Tue, 8 Jan 2008 16:21:02 +0100 From: Robert Millan To: The development of GRUB 2 Message-ID: <20080108152102.GA13078@thorin> References: <20080107220751.GB23660@thorin> <1199745077.7025.38.camel@localhost.localdomain> <20080108092431.GB4044@thorin> <1199787703.7671.18.camel@localhost.localdomain> <20080108121314.GC4270@thorin> <1199797210.7601.3.camel@localhost.localdomain> <1199798453.7601.17.camel@localhost.localdomain> <20080108150140.GA470@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="pWyiEgJYm5f9v55/" Content-Disposition: inline In-Reply-To: <20080108150140.GA470@thorin> 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. Cc: Trent Buck , "Centurion Computer Technology \(2005\) Ltd" , Sam Morris , Jan Nieuwenhuizen Subject: Re: [PATCH] force load of lvm and raid before entering normal mode (Re: LVM on debian) 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: Tue, 08 Jan 2008 15:22:58 -0000 --pWyiEgJYm5f9v55/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jan 08, 2008 at 04:01:40PM +0100, Robert Millan wrote: > > It's a bit funny. I tried to fix your problem, and at some point I realized > I was fixing something else. Ok, so I fixed lvm/raid handling in core.img (by grub-install). This will help those who (unlike you) have their /boot under LVM or software RAID. Please could someone test? (I'm CCing a few people who I heard have this problem) -- Robert Millan I know my rights; I want my phone call! What use is a phone call, if you are unable to speak? (as seen on /.) --pWyiEgJYm5f9v55/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="lvmraid.diff" diff -x '*~' -x configure -x config.h.in -ur grub2/include/grub/util/getroot.h test/include/grub/util/getroot.h --- grub2/include/grub/util/getroot.h 2007-07-22 01:32:25.000000000 +0200 +++ test/include/grub/util/getroot.h 2008-01-08 16:07:30.000000000 +0100 @@ -21,6 +21,6 @@ char *grub_guess_root_device (const char *dir); char *grub_get_prefix (const char *dir); -char *grub_util_get_grub_dev (const char *os_dev); +char *grub_util_get_grub_dev (const char *dev_type, const char *os_dev); #endif /* ! GRUB_UTIL_GETROOT_HEADER */ diff -x '*~' -x configure -x config.h.in -ur grub2/util/getroot.c test/util/getroot.c --- grub2/util/getroot.c 2007-07-22 01:32:31.000000000 +0200 +++ test/util/getroot.c 2008-01-08 16:11:01.000000000 +0100 @@ -239,11 +239,41 @@ return os_dev; } +static char *dev_types[] = { + "", + "lvm", + "raid", +}; + +enum { + TYPE_RAW, + TYPE_LVM, + TYPE_RAID, +}; + char * -grub_util_get_grub_dev (const char *os_dev) +grub_util_get_dev_type (const char *os_dev) { /* Check for LVM. */ if (!strncmp (os_dev, "/dev/mapper/", 12)) + return dev_types[TYPE_LVM]; + + /* Check for RAID. */ + if (!strncmp (os_dev, "/dev/md", 7)) + return dev_types[TYPE_RAID]; + + /* If it's not RAID or LVM, it should be a biosdisk. */ + return dev_types[TYPE_RAW]; +} + +char * +grub_util_get_grub_dev (const char *type, const char *os_dev) +{ + if (! type) + type = grub_util_get_dev_type (os_dev); + + /* Check for LVM. */ + if (!strcmp (type, "lvm")) { char *grub_dev = xmalloc (strlen (os_dev) - 12 + 1); @@ -253,7 +283,7 @@ } /* Check for RAID. */ - if (!strncmp (os_dev, "/dev/md", 7)) + if (!strcmp (type, "raid")) { const char *p; char *grub_dev = xmalloc (20); diff -x '*~' -x configure -x config.h.in -ur grub2/util/grub-probe.c test/util/grub-probe.c --- grub2/util/grub-probe.c 2007-07-22 21:17:26.000000000 +0200 +++ test/util/grub-probe.c 2008-01-08 16:12:38.000000000 +0100 @@ -39,10 +39,13 @@ #define _GNU_SOURCE 1 #include -#define PRINT_FS 0 -#define PRINT_DRIVE 1 -#define PRINT_DEVICE 2 -#define PRINT_PARTMAP 3 +enum { + PRINT_FS, + PRINT_DRIVE, + PRINT_DEVICE, + PRINT_PARTMAP, + PRINT_TYPE, +}; int print = PRINT_FS; @@ -74,6 +77,7 @@ { char *device_name; char *drive_name = NULL; + char *type_name; grub_device_t dev; grub_fs_t fs; @@ -87,7 +91,17 @@ goto end; } - drive_name = grub_util_get_grub_dev (device_name); + type_name = grub_util_get_dev_type (device_name); + if (! type_name) + grub_util_error ("cannot identify drive type for %s.\n", device_name); + + if (print == PRINT_TYPE) + { + printf ("(%s)\n", type_name); + goto end; + } + + drive_name = grub_util_get_grub_dev (type_name, device_name); if (! drive_name) grub_util_error ("cannot find a GRUB drive for %s.\n", device_name); diff -x '*~' -x configure -x config.h.in -ur grub2/util/i386/pc/grub-install.in test/util/i386/pc/grub-install.in --- grub2/util/i386/pc/grub-install.in 2007-12-30 09:52:06.000000000 +0100 +++ test/util/i386/pc/grub-install.in 2008-01-08 16:14:31.000000000 +0100 @@ -223,8 +223,11 @@ # filesystem will be accessible). partmap_module=`$grub_probe --target=partmap --device-map=${device_map} ${grubdir} 2> /dev/null` +# Device type module, if any (lvm, raid). +devtype_module=`$grub_probe --target=type --device-map=${device_map} ${grubdir}` + # _chain is often useful -modules="$modules $fs_module $partmap_module biosdisk _chain" +modules="$modules $fs_module $partmap_module $devtype_module biosdisk _chain" $grub_mkimage --output=${grubdir}/core.img --prefix=`make_system_path_relative_to_its_root ${grubdir}` $modules || exit 1 diff -x '*~' -x configure -x config.h.in -ur grub2/util/i386/pc/grub-setup.c test/util/i386/pc/grub-setup.c --- grub2/util/i386/pc/grub-setup.c 2008-01-05 13:20:28.000000000 +0100 +++ test/util/i386/pc/grub-setup.c 2008-01-08 16:10:30.000000000 +0100 @@ -668,7 +668,7 @@ if (! dest_dev) { /* Possibly, the user specified an OS device file. */ - dest_dev = grub_util_get_grub_dev (argv[optind]); + dest_dev = grub_util_get_grub_dev (NULL, argv[optind]); if (! dest_dev) { fprintf (stderr, "Invalid device `%s'.\n", argv[optind]); @@ -694,7 +694,7 @@ } else { - root_dev = grub_util_get_grub_dev (grub_guess_root_device (dir ? : DEFAULT_DIRECTORY)); + root_dev = grub_util_get_grub_dev (NULL, grub_guess_root_device (dir ? : DEFAULT_DIRECTORY)); if (! root_dev) { grub_util_info ("guessing the root device failed, because of `%s'", @@ -734,7 +734,7 @@ dir ? : DEFAULT_DIRECTORY, boot_file ? : DEFAULT_BOOT_FILE, core_file ? : DEFAULT_CORE_FILE, - root_dev, grub_util_get_grub_dev (devicelist[i]), 1); + root_dev, grub_util_get_grub_dev (NULL, devicelist[i]), 1); } free (raid_prefix); --pWyiEgJYm5f9v55/--