Re: pivot_root. unmount old root

2010-03-26 Thread Katharina Haselhorst

What I still need to figure out is how I can replace init with a custom
process... but I think for that I will have to patch init itself.


Why do you need to patch init?


I'm not sure if I really have to but I don't want to run all init 
scripts of the new system right away but do some other stuff. Would be 
nice to put the whole system back into the state of the early initramfs 
phase. But perhaps some workaround with init is sufficient. I'll do some 
research on that topic.

Thx, for your help with the pivot_root issue!

K. Haselhorst


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/4bac7564.90...@mathematik.uni-marburg.de



Re: pivot_root. unmount old root

2010-03-22 Thread Katharina Haselhorst

Hello,


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.


K. Haselhorst


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/4ba7bf1e.1020...@mathematik.uni-marburg.de



Re: pivot_root. unmount old root

2010-03-22 Thread Katharina Haselhorst

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 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
cd /mnt
pivot_root . old_root
exec chroot . sh -c 'umount /old_root; exec /sbin/init \
  dev/consoledev/console 21

--


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?


K. Haselhorst


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/4ba7ecfc.3020...@mathematik.uni-marburg.de



Re: pivot_root. unmount old root

2010-03-21 Thread Katharina Haselhorst

Hello,


fuser -m /home

will list the process ids which are accessing any file under /home.
Compare that to the output of ps aux to see which processes you
need to terminate in order to be able to umount /home.


Since I'm doing a pivot_root before trying to umount the old root there 
are still several processes keeping some files open inside the old root 
subdirs. Init is still running, als well as rc and one shutdown script 
(atm I'm doing the pivot_root just before shutdown, because most 
processes are terminted by the time). If I kill one of these processes, 
the systems gets shut down.
I don't understand why there is still that shutdown script running, 
because I'm doing a exec chroot. The pivot_root's manual says:  Note 
that exec chroot changes the running executable, which is necessary if 
the  old root  directory  should be unmounted afterwards.
And the init process is always running, so how does pivot_root handle 
the open files of init?
I did move the /proc and /dev mountpoints from old-root to the new root 
- might that cause some problems? If I don't do that - lsof or fuser of 
course don't show any open files for old-root, but I'm not able to 
unmount to old-root either.


K. Haselhorst


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/4ba62144.9050...@mathematik.uni-marburg.de



pivot_root. unmount old root

2010-03-20 Thread Katharina Haselhorst

Hello,

I'm running debian lenny with xen kernel 2.6.26, amd64. Inside a domU I 
need to make a pivot_root and unmount the old root afterwards.

I've done the following:

cd /newroot
(newroot contains a minimal system from initrd, dev/console, dev/null 
and old-root are available unter newroot/)

exec dev/console dev/console 21
pivot_root . old-root
exec chroot . bin/sh
umount -n old-root

but I always get: device is busy - so I can't umount the old root.
/proc/mounts shows that the proc fs is still mounten under old-root/proc 
and an umount old-root/proc doesn't work either (device is busy, too).


I also tried to umount proc before doing the pivot_root, but no luck either.
Why doesn't pivot_root remove the proc mountpoint from old-root? As I 
understand the documentation - it should clear all dependencies so that 
the old-root can be unmounted afterwards...


Any ideas or suggestions to help would be great!

K. Haselhorst


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/4ba4a71f.8060...@mathematik.uni-marburg.de



Re: pivot_root. unmount old root

2010-03-20 Thread Katharina Haselhorst

no, I don't have X. I just tried to mount --move /dev and /proc to the
new root before actually doing the pivot-root. proc/mounts doesn't show
any mountpoints under old-root afterwards, but an umount still gives
device busy...

On 03/20/2010 02:33 PM, Rogerio Luz Coelho wrote:

are you doing this with X enabled?

If so stop X before atempting a umount

Rogerio

2010/3/20 Katharina Haselhorst bran...@mathematik.uni-marburg.de
mailto:bran...@mathematik.uni-marburg.de

Hello,

I'm running debian lenny with xen kernel 2.6.26, amd64. Inside a
domU I need to make a pivot_root and unmount the old root afterwards.
I've done the following:

cd /newroot
(newroot contains a minimal system from initrd, dev/console,
dev/null and old-root are available unter newroot/)
exec dev/console dev/console 21
pivot_root . old-root
exec chroot . bin/sh
umount -n old-root

but I always get: device is busy - so I can't umount the old root.
/proc/mounts shows that the proc fs is still mounten under
old-root/proc and an umount old-root/proc doesn't work either
(device is busy, too).

I also tried to umount proc before doing the pivot_root, but no luck
either.
Why doesn't pivot_root remove the proc mountpoint from old-root? As
I understand the documentation - it should clear all dependencies so
that the old-root can be unmounted afterwards...

Any ideas or suggestions to help would be great!

K. Haselhorst


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
mailto:debian-user-requ...@lists.debian.org with a subject of
unsubscribe. Trouble? Contact listmas...@lists.debian.org
mailto:listmas...@lists.debian.org
Archive:
http://lists.debian.org/4ba4a71f.8060...@mathematik.uni-marburg.de





--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org

Archive: http://lists.debian.org/4ba4ed31.2040...@mathematik.uni-marburg.de