Transferring the root filesystem to a ramdisk?

Cordula's Web cpghost at cordula.ws
Sun Feb 1 03:28:29 PST 2004


> > 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/



More information about the freebsd-multimedia mailing list