* pivot_root alternative
@ 2007-06-24 21:27 Salvatore De Paolis
2007-06-24 21:29 ` Jan Engelhardt
2007-06-24 23:29 ` Kyle Moffett
0 siblings, 2 replies; 9+ messages in thread
From: Salvatore De Paolis @ 2007-06-24 21:27 UTC (permalink / raw)
To: Linux Kernel Mailing List
hi all
i built the kernel with a busybox initramfs which runs from a usb stick. While
i boot i need to mount the real root and i'm using pivot_root.
Pivot_root . old-root return to me an "Invalid argument" error and googling i
found here http://lkml.org/lkml/2005/10/8/17 that pivot_root should be avoided.
I want to ask now what i should do to switch to a real root?
Regards
S.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: pivot_root alternative
2007-06-24 21:27 pivot_root alternative Salvatore De Paolis
@ 2007-06-24 21:29 ` Jan Engelhardt
2007-06-24 21:39 ` Arnd Hannemann
2007-06-24 23:29 ` Kyle Moffett
1 sibling, 1 reply; 9+ messages in thread
From: Jan Engelhardt @ 2007-06-24 21:29 UTC (permalink / raw)
To: Salvatore De Paolis; +Cc: Linux Kernel Mailing List
On Jun 24 2007 23:27, Salvatore De Paolis wrote:
>
>i built the kernel with a busybox initramfs which runs from a usb stick. While
>i boot i need to mount the real root and i'm using pivot_root.
>Pivot_root . old-root return to me an "Invalid argument" error and googling i
>found here http://lkml.org/lkml/2005/10/8/17 that pivot_root should be avoided.
>I want to ask now what i should do to switch to a real root?
use run-init from klibc?
Jan
--
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: pivot_root alternative
2007-06-24 21:29 ` Jan Engelhardt
@ 2007-06-24 21:39 ` Arnd Hannemann
2007-06-24 22:08 ` Salvatore De Paolis
2007-06-25 3:59 ` H. Peter Anvin
0 siblings, 2 replies; 9+ messages in thread
From: Arnd Hannemann @ 2007-06-24 21:39 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: Salvatore De Paolis, Linux Kernel Mailing List
Jan Engelhardt schrieb:
> On Jun 24 2007 23:27, Salvatore De Paolis wrote:
>> i built the kernel with a busybox initramfs which runs from a usb stick. While
>> i boot i need to mount the real root and i'm using pivot_root.
>> Pivot_root . old-root return to me an "Invalid argument" error and googling i
>> found here http://lkml.org/lkml/2005/10/8/17 that pivot_root should be avoided.
>> I want to ask now what i should do to switch to a real root?
>
> use run-init from klibc?
However be aware of the limitation of run-init:
It only works for direct childs of root directory
/mnt/newroot won't work
/newroot should work ;-)
Good luck,
Arnd
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: pivot_root alternative
2007-06-24 21:39 ` Arnd Hannemann
@ 2007-06-24 22:08 ` Salvatore De Paolis
2007-06-25 10:19 ` Michael Tokarev
2007-06-25 3:59 ` H. Peter Anvin
1 sibling, 1 reply; 9+ messages in thread
From: Salvatore De Paolis @ 2007-06-24 22:08 UTC (permalink / raw)
To: Linux Kernel Mailing List
On Sun, 24 Jun 2007 23:39:25 +0200
Arnd Hannemann <arnd@arndnet.de> wrote:
> use run-init from klibc?
> However be aware of the limitation of run-init:
> It only works for direct childs of root directory
> /mnt/newroot won't work
> /newroot should work ;-)
>
> Good luck,
> Arnd
Thank you both, i'll take a look at run-init:)
Nice to know about the child limitation but i just have to find klibc-utils
inside buildroot or busybox if even exists:)
Regards
S.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: pivot_root alternative
2007-06-24 21:27 pivot_root alternative Salvatore De Paolis
2007-06-24 21:29 ` Jan Engelhardt
@ 2007-06-24 23:29 ` Kyle Moffett
2007-06-25 5:04 ` Salvatore De Paolis
1 sibling, 1 reply; 9+ messages in thread
From: Kyle Moffett @ 2007-06-24 23:29 UTC (permalink / raw)
To: Salvatore De Paolis
Cc: Linux Kernel Mailing List, Jan Engelhardt, Arnd Hannemann
On Jun 24, 2007, at 17:27:34, Salvatore De Paolis wrote:
> i built the kernel with a busybox initramfs which runs from a usb
> stick. While i boot i need to mount the real root and i'm using
> pivot_root. Pivot_root . old-root return to me an "Invalid
> argument" error and googling i found here http://lkml.org/lkml/
> 2005/10/8/17 that pivot_root should be avoided. I want to ask now
> what i should do to switch to a real root?
One interesting fact about the mount() syscall is this: when
overmounting a directory tree, a process whose current working
directory is within said directory tree will see the old vfsmounts
until it does an absolute chdir(). Shells tend not to be terribly
useful for this because they use absolute paths more than necessary,
but I think you can make it work. For instance, if you run these
commands after mounting the root filesystem:
mount -t proc proc /realroot/proc
cd /
mount --move /realroot /
find /proc/$$/cwd/ -mindepth 1 -maxdepth 1 -print0 \
| xargs -0 rm -rf -- '{}' ';'
cd /
This will set up proc on the new root filesystem, move /realroot to
the root directory, and delete the contents of the old initramfs
using the old current-working-directory link of your shell. The
amusing thing is that you are using the "find" and "rm" commands from
the newly mounted root filesystem to remove the contents of the
completely hidden initramfs. The only reason it's actually possible
is because you have the tenuous thread of the working directory.
Cheers,
Kyle Moffett
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: pivot_root alternative
2007-06-24 21:39 ` Arnd Hannemann
2007-06-24 22:08 ` Salvatore De Paolis
@ 2007-06-25 3:59 ` H. Peter Anvin
1 sibling, 0 replies; 9+ messages in thread
From: H. Peter Anvin @ 2007-06-25 3:59 UTC (permalink / raw)
To: Arnd Hannemann
Cc: Jan Engelhardt, Salvatore De Paolis, Linux Kernel Mailing List
Arnd Hannemann wrote:
> Jan Engelhardt schrieb:
>> On Jun 24 2007 23:27, Salvatore De Paolis wrote:
>>> i built the kernel with a busybox initramfs which runs from a usb stick. While
>>> i boot i need to mount the real root and i'm using pivot_root.
>>> Pivot_root . old-root return to me an "Invalid argument" error and googling i
>>> found here http://lkml.org/lkml/2005/10/8/17 that pivot_root should be avoided.
>>> I want to ask now what i should do to switch to a real root?
>> use run-init from klibc?
>
> However be aware of the limitation of run-init:
> It only works for direct childs of root directory
> /mnt/newroot won't work
> /newroot should work ;-)
>
Hm, that should probably be fixed. It should be able to work on any
directory as long as there isn't another *filesystem* involved...
-hpa
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: pivot_root alternative
2007-06-24 23:29 ` Kyle Moffett
@ 2007-06-25 5:04 ` Salvatore De Paolis
0 siblings, 0 replies; 9+ messages in thread
From: Salvatore De Paolis @ 2007-06-25 5:04 UTC (permalink / raw)
To: LKML
So i choice to use switch_root which is already inside the busybox but with a
bit(?) of unluck cause it still wont run.
It hangs on !S_ISREG(st1.st_mode)
Can you explain to me how to interpret it?
Regards
S.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: pivot_root alternative
2007-06-24 22:08 ` Salvatore De Paolis
@ 2007-06-25 10:19 ` Michael Tokarev
0 siblings, 0 replies; 9+ messages in thread
From: Michael Tokarev @ 2007-06-25 10:19 UTC (permalink / raw)
To: Salvatore De Paolis; +Cc: Linux Kernel Mailing List
Salvatore De Paolis wrote:
>
>> use run-init from klibc?
>
> Thank you both, i'll take a look at run-init:)
By the way, busybox now includes similar applet,
named switch_root.
/mjt
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: pivot_root alternative
@ 2007-06-25 10:34 Salvatore De Paolis
0 siblings, 0 replies; 9+ messages in thread
From: Salvatore De Paolis @ 2007-06-25 10:34 UTC (permalink / raw)
To: Linux Kernel Mailing List
On Mon, 25 Jun 2007 14:19:02 +0400
Michael Tokarev <mjt@tls.msk.ru> wrote:
> Salvatore De Paolis wrote:
> >
> >> use run-init from klibc?
> >
> > Thank you both, i'll take a look at run-init:)
>
> By the way, busybox now includes similar applet,
> named switch_root.
>
> /mjt
yeah, i saw it yesterday after a while. Anyway the problem got a solution,
everything seems to work just fine.
Regards
S.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2007-06-25 10:52 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-24 21:27 pivot_root alternative Salvatore De Paolis
2007-06-24 21:29 ` Jan Engelhardt
2007-06-24 21:39 ` Arnd Hannemann
2007-06-24 22:08 ` Salvatore De Paolis
2007-06-25 10:19 ` Michael Tokarev
2007-06-25 3:59 ` H. Peter Anvin
2007-06-24 23:29 ` Kyle Moffett
2007-06-25 5:04 ` Salvatore De Paolis
-- strict thread matches above, loose matches on Subject: below --
2007-06-25 10:34 Salvatore De Paolis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox