Subject: kern/24745: kernel prompts for a root device when using md_root
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <j.momose@ieee.org>
List: netbsd-bugs
Date: 03/11/2004 14:02:40
>Number: 24745
>Category: kern
>Synopsis: kernel prompts for a root device when using md_root
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Mar 11 14:03:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: Jared Momose
>Release: NetBSD-current
>Organization:
none
>Environment:
NetBSD kiwi.ams.apc.com 1.6ZF NetBSD 1.6ZF (CC405EP) #204: Thu Mar 11 03:47:22 EST 2004 jmomose@jaredlap.rrg.ams.apc.com:/usr/src-13NOV03/sys/arch/evbppc/compile/CC405EP evbppc
>Description:
When md is used as the root device, the kernel always prompts the console user to specify a root device. This is a bit annoying as it prevents the kernel from booting completely without user interaction.
This problem occurs because the RB_ASKNAME flag for boothowto is set when the function finddevice:kern_subr.c fails to find the correct device.
>How-To-Repeat:
1. Compile a kernel with space/configured for md as root
2. mdsetimage a ramdisk.fs into the kernel
3. Boot and observe that the kernel prompts for a root device
>Fix:
My solution was to add a small section of code in kern_subr.c that, if the kernel option MEMORY_DISK_IS_ROOT is set, will allow finddevice:kern_subr.c to search the list of md devices (fakemdrootdev) for a match before it searches the list of auto detected devices (alldevs). This change is nearly identitical to that made for RAID. See my patch below:
-------------------- CUT HERE - patch-md-root ---------------------
Index: src/sys/kern/kern_subr.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_subr.c,v
retrieving revision 1.107
diff -u -r1.107 kern_subr.c
--- src/sys/kern/kern_subr.c 2003/10/31 03:28:14 1.107
+++ src/sys/kern/kern_subr.c 2003/12/19 20:27:46
@@ -716,6 +716,10 @@
static struct device fakemdrootdev[NMD];
#endif
+#ifdef MEMORY_DISK_IS_ROOT
+#define BOOT_FROM_MEMORY_HOOKS 1
+#endif
+
#include "raid.h"
#if NRAID == 1
#define BOOT_FROM_RAID_HOOKS 1
@@ -1061,16 +1065,30 @@
const char *name;
{
struct device *dv;
+#ifdef BOOT_FROM_MEMORY_HOOKS
+ int i;
+#endif /* BOOT_FROM_MEMORY_HOOKS */
#ifdef BOOT_FROM_RAID_HOOKS
int j;
+#endif /* BOOT_FROM_RAID_HOOKS */
+#ifdef BOOT_FROM_RAID_HOOKS
for (j = 0; j < numraid; j++) {
if (strcmp(name, raidrootdev[j].dv_xname) == 0) {
dv = &raidrootdev[j];
return (dv);
}
}
-#endif
+#endif /* BOOT_FROM_RAID_HOOKS */
+
+#ifdef BOOT_FROM_MEMORY_HOOKS
+ for (i = 0; i < NMD; i++) {
+ if (strcmp(name, fakemdrootdev[i].dv_xname) == 0) {
+ dv = &fakemdrootdev[i];
+ return (dv);
+ }
+ }
+#endif /* BOOT_FROM_MEMORY_HOOKS */
for (dv = TAILQ_FIRST(&alldevs); dv != NULL;
dv = TAILQ_NEXT(dv, dv_list))
--------------------------- END ---------------------------------
>Release-Note:
>Audit-Trail:
>Unformatted: