Skip site navigation (1)Skip section navigation (2)
Date:      Sun,  1 Feb 2004 12:27:47 +0100 (CET)
From:      Cordula's Web <cpghost@cordula.ws>
To:        julian@elischer.org
Cc:        freebsd-multimedia@freebsd.org
Subject:   Re: Transferring the root filesystem to a ramdisk?
Message-ID:  <20040201112747.7785640826@fw.farid-hajji.net>
In-Reply-To: <Pine.BSF.4.21.0401311525520.38031-100000@InterJet.elischer.org> (message from Julian Elischer on Sat, 31 Jan 2004 15:26:54 -0800 (PST))
References:  <Pine.BSF.4.21.0401311525520.38031-100000@InterJet.elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> > Now, all I need would be a syscall to switch the kernel's notion
> > of the root device.
> > 
> > Or is there a way to umount root, and remount it on the md drive?
>
> you could mount the replacement root device on '/'
> 
> alternatively you could make init do the chroot (you have source no? :-)

chroot()ing init looks like a good idea, but:
  1. Isn't /sbin/init itself mmap()ed to the physical device 
     which I'd like to turn off later?
  2. Other processes, forked earlier from init will also
     be mmap()ed to the physical device, so they'll have to die?

1. means that chroot() can only happen before /sbin/init is
created, somewhere around /usr/src/sys/kern/init_main.c:mi_startup()

2. means that all these processes will die, when the device
is turned off.

I'm not a kernel hacker, so the following is just a guess:

  * A new syscall foo(device_t) is needed.
  * foo() manipulates the vnode for "/", effectively mounting the
    memory device.
  * foo() creates a new process 1, but doesn't switch to it yet
  * foo() loads process 1 from /sbin/init, which is now on
    the memory device.
  * foo() removes all old processes (including the old init process)
    from the process table, cleans up vm etc...
  * foo() starts (the new) init process, effectively rebooting
    with a new root.

That's way above and beyond my modest understanding of the kernel.
It may be an easy task for kernel gurus though...

Thanks,
-cpghost.

-- 
Cordula's Web. http://www.cordula.ws/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040201112747.7785640826>