Re: linux-2.1.90 PATCH: kmod hangs in initial ramdisk

Matthias Urlichs (
19 May 1998 09:03:33 +0200

"Adam J. Richter" <> writes:
> Here is the patch that move the start of kmod to before
> the running of the initial ramdisk. It works for me. I am writing
> this message from a machine running 2.1.90 that had its disk drivers
> loaded by an initial ramdisk.
That won't work either.

The problem is that you need access to the current root file system. When
you start kmod before /linuxrc, the current root is the RAM disk.
Afterwards, kmod still has that disk open even though the real root is now
on the hard disk, thus preventing the RAM disk from being freed. :-(

The real fix would probably to disassociate from the root file system
when kmod is forked, and then to reattach to the calling process's root
directory before calling modprobe.

This would also mean that if you load a module from a chrooted environment,
that environment is used for loading the module. This may or may not be a
Good Thing.

Anyway, I'd just forget all the kmod stuff from within /linuxrc. /linuxrc
is a special environment. Why don't you just call modprobe directly, for
the modules which you'll need until you can switch to the real root?

Here's a stopgap patch to make kmod+initrd work until this problem is
sorted out correctly.

+ prcs diff -f -rdev kernel_linux kernel/kmod.c -- -u -b
+ less -p '^Index'
prcs: Producing diffs from dev.29 to new.7(w).
Index: kernel/kmod.c
--- kernel/kmod.c.orig Mon, 16 Mar 1998 10:20:16 +0100 smurf (kernel_linux/K/b/50_kmod.c 1.2 664) dev.29
+++ kernel/kmod.c Wed, 25 Mar 1998 17:32:00 +0100 smurf (kernel_linux/K/b/50_kmod.c 1.2 664) new.7(w)
@@ -19,6 +19,7 @@
char module_name[64] = "";
char * argv[] = { "modprobe", "-k", NULL, NULL, };
char * envp[] = { "HOME=/", "TERM=linux", NULL, };
+static int kmod_running = 0;

kmod_queue synchronizes the kmod thread and the rest of the system
@@ -43,6 +44,7 @@
current->pgrp = 1;
sprintf(current->comm, "kmod");
+ kmod_running = 1;

This is the main kmod_thread loop. It first sleeps, then
@@ -136,6 +138,9 @@
the module into module_name. Once that is done, wake up
+ if(!kmod_running)
+ return 0;
strcpy(module_name, name);

Matthias Urlichs
noris network GmbH

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to