[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: pivot_root. unmount old root

On Mon, 22 Mar 2010 18:19:40 -0400 (EDT), Katharina Haselhorst wrote:
> Stephen Powell wrote:
>> 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.
> that's what I was doing - only with runlevel 0 without doing the actual 
> halt at the end.


>> Then run something like this:
>> ----------
>> #!/bin/sh
>> # Example: mount the new root file system over NFS from
>> # and run init.
>> ifconfig lo up   # for portmap
>> # configure Ethernet or such
>> portmap  # for lockd (implicitly started by mount)
>> mount -o ro /mnt
>> killall portmap   # portmap keeps old root busy
>> cd /mnt
>> pivot_root . old_root
>> exec chroot . sh -c 'umount /old_root; exec /sbin/init \
>>   <dev/console>dev/console 2>&1
>> ----------
> I only see 2 places (without patching init itself) to put these commands:
> 1. into a new shutdown script in place of S90{halt,reboot}
> 2. into the rc script
> But no matter which of these I choose there remains at least init and 
> perhaps the process executing rc running and keeping the old root busy. 
> So I cannot unmount it. At least on my system init has opened some 
> shared libraries in old-root/lib/... and rc as well (if it is still running)
> The same would happen if I restarted init with telinit -u runlevel...
> Your script above is from the manpage of pivot_root, isn't it?


> I really wonder in which context this example (and also the other one given
> in the manpage) could work? Have you sucessfully tried it on your system?

No, I've never had occasion to.
But where exactly is the failure occuring?
Does the mount command fail?
Does the pivot_root command fail?  Does exec chroot fail?

Kill should be able to kill any process *except* init itself.
And "telinit -u" should be able to refresh init.

Something like this occurs during boot with the transition from the initial
RAM filesystem to the permanent root filesystem.  Perhaps you should
study the scripts in /etc/rcS.d to find how the root file system is
changed there.  Maybe that will give you some clues.

  .''`.     Stephen Powell    <zlinuxman@wowway.com>
 : :'  :
 `. `'`

Reply to: