Re: pivot_root. unmount old root
On Mon, 22 Mar 2010 15:03:58 -0400 (EDT), Katharina Haselhorst wrote:
> Stephen Powell wrote:
>> Maybe it's time to step back and ask a more basic question.
>> What is it that you are trying to accomplish? I know that you are trying
>> to do a pivot_root. But *why* are you trying to do a pivot_root?
>> Why do you think you need to do it? What is the real-world problem
>> that you are trying to solve?
> I want to go back into an initramfs setting so that only the running
> kernel and one specific process remains. Goal is to be able to boot a
> new system from there with a new hard drive (for example mounted via nfs
> or some other way) withouth the need to reboot the entire kernel. The
> whole thing is running within a xen domU atm. So the new hard disk could
> be passed through via xend or mounted via nfs. And for cleanly
> terminating the first system I need to unmount the root filesystem and
> somehow replace the old init process with my specific process running in
> that initramfs setting.
> According to the pivot_root manpage, it should be possible to clear all
> dependencies to the old root fs so that it can be unmounted after the
> pivot_root command. And that's what not working for me.
You would probably want to run all the executable files in /etc/rc6.d
in alphabetical order, supplying the "stop" parameter, with the
exception of the last one, which on my system is S90reboot.
Then run something like this:
# Example: mount the new root file system over NFS from 10.0.0.1:/my_root
# and run init.
ifconfig lo 127.0.0.1 up # for portmap
# configure Ethernet or such
portmap # for lockd (implicitly started by mount)
mount -o ro 10.0.0.1:/my_root /mnt
killall portmap # portmap keeps old root busy
pivot_root . old_root
exec chroot . sh -c 'umount /old_root; exec /sbin/init \
<dev/console >dev/console 2>&1
The "# configure Ethernet or such" line is what is most likely
to give you trouble. Exactly what goes there is dependent on
Another trick: "telinit -u" can sometimes be used to effectively
restart init, which may cause it to close the old files.
Debian uses this when applying maintenance
to the init program itself without rebooting.
.''`. Stephen Powell <firstname.lastname@example.org>
: :' :