Tue Dec 11 13:09:18 EST 2012

OpenWRT kernel -> Debian

I've been running a dual system: OpenWRT + Debian chroot.  This is too
complex.  Next step is to eliminate the OpenWRT layer and boot
straight into Debian.

Problems to solve:

- Keep the modules on the OpenWRT partition, i.e. start it as if it
  would be an initrd partition.  Maybe even do the whole Debian initrd

- If that doesn't work, just copy the modules onto the Debian
  partition, and (find out how to) do a root change.

Inspecting "init" script from a Debian initrd, it seems that the root
system is switched by "run-init" [2].  The key parts of that are:

  mount(".", "/", NULL, MS_MOVE, NULL);

It looks like both the moving mount and chroot are necessary.  The
moving is also possible from the shell as:

  mount --move <src> <dst>

The rest seems to make sure that all open files on the old /dev are
closed too.

It seems that I can keep my previous approach, and lauch the Debian
from OpenWRT with a full root transfer as long as there are no
references to the old filesystem (open filedescriptors), then just run

[1] http://www.linuxfromscratch.org/hints/downloads/files/initramfs.txt
[2] http://gitorious.org/opensuse/mkinitrd/blobs/cc9b2909fde7393feb2256080f5547b23311070e/src/run-init.c