Subject: Re: boot on mfs
To: matthew green <mrg@eterna.com.au>
From: Artur Grabowski <art@stacken.kth.se>
List: tech-kern
Date: 08/17/2000 18:48:15
matthew green <mrg@eterna.com.au> writes:

>    When NetBSD boots on mfs, all ports stop in single-user mode. Is there a
>    particular reason for it ?
> 
> 
> first off, s/mfs/md/.  mfs is a userland process that allocates some VM,
> newfs's it, and mounts it as an ffs.  the in-kernel "memory disk" is a
> different beast.
> 
> 
> anyway, the issue here is that the these /sbin/init programs have been
> compiled -DSMALL (see distrib/utils/x_init, i believe), and that enables
> a very simple init that doesn't do multi user mode at all (i think).

The problem exists even if you include a normal init in the memory disk.

We distribute the software for our routers in images that are kernels with
the filesystem in a memory disk (to make upgrading and image selection easy).

The change needed to the kernel to make it work "multi user" is appended below.

The comment is btw. untrue. It just makes the assumption that kernels with
memory disks will only be used for installations. I think this should be
made optional by some kernel option (FORCE_SINGLE_USER or something like
that). And the forcing of single user should be made in main() and not
in a driver. (diff for that appended too, it probably needs options(4),
opt_foo.h and conversion of all installation kernels, but that's not my
problem. ;))

//art (wearing my Dynarc hat)

Index: md_root.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/i386/md_root.c,v
retrieving revision 1.11
diff -u -u -r1.11 md_root.c
--- md_root.c	1999/03/17 18:59:22	1.11
+++ md_root.c	2000/08/17 16:15:47
@@ -76,8 +76,4 @@
 	int unit;
 	struct md_conf *md;
 {
-	if (unit == 0) {
-		/* The root ramdisk only works single-user. */
-		boothowto |= RB_SINGLE;
-	}
 }



Index: init_main.c
===================================================================
RCS file: /cvsroot/syssrc/sys/kern/init_main.c,v
retrieving revision 1.166
diff -u -u -r1.166 init_main.c
--- init_main.c	2000/03/24 11:57:14	1.166
+++ init_main.c	2000/08/17 16:25:26
@@ -581,6 +581,13 @@
 		panic("init: couldn't allocate argument space");
 	p->p_vmspace->vm_maxsaddr = (caddr_t)addr;
 
+#ifdef FORCE_INIT_SINGLE
+	/*
+	 * Force init to run single user.
+	 */
+	boothowto |= RB_SINGLE;
+#endif
+
 	for (pathp = &initpaths[0]; (path = *pathp) != NULL; pathp++) {
 		ucp = (char *)(addr + PAGE_SIZE);