pivot_root alternative
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.
Quoted 6 lines · Salvatore De Paolis
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 thatpivot_rootshould be avoided. I want to ask now what i should do to switch to a real root?
use run-init from klibc?
Jan
Quoted 8 lines · Jan Engelhardt
Quoted 5 lines · Salvatore De Paolis
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 thatpivot_rootshould 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
Quoted 9 lines · On Sun, 24 Jun 2007 23:39:25 +0200 Arnd Hannemann <[email protected]> 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/newrootwon'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.
Quoted 1 line · Salvatore De Paolis
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 thatpivot_rootshould 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
Quoted 7 lines · Arnd Hannemann
Quoted 6 lines · Jan Engelhardt
Quoted 5 lines · Salvatore De Paolis
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 thatpivot_rootshould be avoided. I want to ask now what i should do to switch to a real root?
Quoted 7 lines
Quoted 1 line
use run-init from klibc?
However be aware of the limitation of run-init:
It only works for direct childs of root directory/mnt/newrootwon'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
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.
Quoted 4 lines · Salvatore De Paolis
Quoted 2 lines
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