LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (http://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   chroot into linux root FS and give them a way to self unmount (http://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/chroot-into-linux-root-fs-and-give-them-a-way-to-self-unmount-4175466529/)

tux_mind 06-18-2013 03:48 PM

chroot into linux root FS and give them a way to self unmount
 
hi all,
i'm developing and android universal bootloader.
this thread should NOT be moved to android forums!
our project it's to make users able to boot any OS ( linux, Mac, Windows, android and so on ) from any arm device. [ wiki: https://github.com/tux-mind/tf201-dev/wiki ]
our root_chooser works as /init replacement.
it chroot to an user defined device and substitute itself with another user specified init program ( usually /sbin/init ).
my problem is that the booted OS cannot unmount itself.
we are mounting the user-defined blockdevice over /newroot, chroot into /newroot ( or a subfolder ) and execv() the /sbin/init program.
for example gentoo say "cannot umount /newroot - we are using /newroot" in the shutdown phase.
i'm asking your help because every time i reboot the first mount() on the user-defined blockdevice takes so long due to unclean filesystem.
is there anyway to chroot into another linux root with giving him a way to unmount himself?
many init programs checks that they are the 1'st process....so a fork is not possible.
but i belive that there is a way since many initramfs do this.

thanks in advance for your help.

-- open source rocks!

Firerat 06-18-2013 05:15 PM

I'm sure I'm missing something here..
Why not just unmount /newroot once chroot exits?


Or maybe you need pivot_root?
http://linux.die.net/man/8/pivot_root

tux_mind 06-19-2013 03:21 AM

Quote:

Originally Posted by Firerat (Post 4974417)
Why not just unmount /newroot once chroot exits?

thanks for your suggestions,
i can't unmount /newroot, i have to exec binaries that are into /newroot....

btw, pivot_root seems to be what i'm looking for :)
i'll try it today and let you known if it works.

thanks for your help.

tux_mind 06-19-2013 07:26 AM

pivot_root shouldn't be used by the initramfs,
you have to use switch_root instead.
BUT both require that the newroot it's a mountpoint.
our target it's to chroot inside a subdirectory of a device ( or a fs dd image ).
after looking around for pivot_root and switch_root i learned that mount accept the "move" option.
maybe this can help me.

but if i move the /newroot to /, and than chroot into a subfolder,
how can the spawned init unmount the real / ?

thanks in advance!

onebuck 06-19-2013 09:51 AM

Moderator Response
 
Moved: This thread is more suitable in <Linux - Embedded & Single-board computer> and has been moved accordingly to help your thread/question get the exposure it deserves.


All times are GMT -5. The time now is 01:16 PM.