LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices

Reply
 
Search this Thread
Old 06-18-2013, 02:48 PM   #1
tux_mind
LQ Newbie
 
Registered: Apr 2012
Distribution: gentoo
Posts: 9

Rep: Reputation: Disabled
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!
 
Old 06-18-2013, 04:15 PM   #2
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
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

Last edited by Firerat; 06-18-2013 at 04:25 PM. Reason: pivot_root
 
Old 06-19-2013, 02:21 AM   #3
tux_mind
LQ Newbie
 
Registered: Apr 2012
Distribution: gentoo
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Firerat View Post
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.
 
Old 06-19-2013, 06:26 AM   #4
tux_mind
LQ Newbie
 
Registered: Apr 2012
Distribution: gentoo
Posts: 9

Original Poster
Rep: Reputation: Disabled
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!
 
Old 06-19-2013, 08:51 AM   #5
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 11,312
Blog Entries: 3

Rep: Reputation: 1463Reputation: 1463Reputation: 1463Reputation: 1463Reputation: 1463Reputation: 1463Reputation: 1463Reputation: 1463Reputation: 1463Reputation: 1463
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.
 
  


Reply

Tags
chroot, initramfs, mount, unmount


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Failed to change real root to fake root using chroot. Aswathy Linux - Newbie 1 06-29-2011 03:34 AM
CD-ROM wont unmount unless logged in as root redsmoke Debian 3 12-13-2004 07:09 AM
Can't mount or unmount cdrom unless I'm root jsfueston Slackware - Installation 1 01-30-2004 04:05 PM
How to Unmount stuff without having to be Root? lostchild Mandriva 2 01-22-2004 07:57 PM


All times are GMT -5. The time now is 12:36 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration