circular pivot_root, is this possible ?

From: David Bryson
Date: Mon Mar 01 2004 - 21:34:11 EST


Greetings!
I'm working on some embedded applications and I am wondering if
something like the following is possible. I have implemented most of
this but the last few steps are a bit of a mystery to me... and after
reading many threads in the lkml archives I don't believe it's
possible, but I thought I'd ask anyway.

flash media contains two filesystem images, an initrd.gz, a
sys.img(cramfs), and a kernel

1) kernel boots with initrd.gz as root, loading into ram0
2) initrd mounts the flash filesystem, and loads sys.img via loopback
3) a tmpfs is created, contents of sys.img are copied into the tmpfs
4) system does a pivot_root on the tmpfs, passing the initrd as
well(somewhere on the tmpfs filesytem)
5) system begins normal operation

This works find and is fairly easy. The next part is what I am having
trouble with.

Say the system needs an upgrade.... I want to

1) pivot_root _back out_ of the tmpfs, onto the initrd again
2) obtain via network a new sys.img, write it to the flash
3) wipe tmpfs, and recopy the contents of the new sys.img into memory
4) pivot_root back into the tmpfs and start the higher level system
again

pivot_root circles around root filesystems as various tasks are
completed.

Somehow init isn't behaving properly with me on this. My first
attempts included an init on both initrd.gz and sys.img. Having two
init's running at normal system startup. This did not work well but
got the job done, as init(PID:1 on the initrd) was running as well as
init(some other PID on sys.img)

Eventually I tried only running a script on the initrd.gz to get the
system pivot_root'd to tmpfs. But if I attempted to start the
circular pivot_root behavior(back to the inird) I still ended up with
init(PID:1) on the tmpfs, while my rootfs was in the initrd again.
Additionally I couldn't unmount devfs because I am assuming the old
processes running under init are still using it.

I also tried killing init with various singals, to see if it would
'reload' the config on the current rootfs(kill -1 1, kill -HUP 1) but
no success there.

So the question remains, is it possible to have circular pivot_roots ?
thanks
Dave

Attachment: pgp00000.pgp
Description: PGP signature