-   Linux - Embedded & Single-board computer (
-   -   chroot into linux root FS and give them a way to self unmount (

tux_mind 06-18-2013 02: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: ]
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 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 04:15 PM

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

Or maybe you need pivot_root?

tux_mind 06-19-2013 02:21 AM


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 06: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 08: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 03:17 PM.