Escaping my own chroot...
Nick Craig-Wood
nick at craig-wood.com
Wed Feb 11 10:31:56 EST 2009
r0g <aioe.org at technicalbloke.com> wrote:
> I'm writing a linux remastering script in python where I need to chroot
> into a folder, run some system commands and then come out and do some
> tidying up, un-mounting proc & sys etc.
>
> I got in there with os.chroot() and I tried using that to get back out
> but that didn't work so... is my script trapped in there forever now or
> is there an un-hacky way to escape?
No!
> If it is an OS restriction rather than my ignorance of python is there a
> canonical way of dealing with it? Should I maybe fork a process, have it
> do the chroot and wait for it to terminate before continuing?
That is the only way...
However this is a solved problem if you use schroot (which works very
well in my experience)
http://packages.debian.org/sid/schroot
http://www.debian-administration.org/articles/566
There are definitely debian, ubuntu and centos packages for it if you
look!
--
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick
More information about the Python-list
mailing list