Run a few Python commands from a temporary filesystem when the rootfs is halted

Dan Stromberg drsalists at gmail.com
Sat Apr 23 04:59:23 CEST 2011


You could open a pivot_root subprocess using the subprocess module, or
you could run pivot_root() directly using ctypes.  I doubt any
preexisting Python module wraps pivot_root(), but I'd love to be
surprised.  You may find that your Python module path does amusing
things right after the pivot, so don't be taken aback much if import
suddenly doesn't see some module.

On Fri, Apr 22, 2011 at 5:52 PM, Frederick Grose <fgrose at gmail.com> wrote:
> Forwarded conversation
> Subject: Run a few Python commands from a temporary filesystem when the
> rootfs is halted
> ------------------------
>
> From: Frederick Grose <fgrose at gmail.com>
> Date: Fri, Apr 22, 2011 at 7:54 PM
> To: tutor at python.org
>
>
> With Bash, when one needs to halt the current root filesystem, to pivot to a
> new filesystem, one can copy some of the command files and their
> dependencies to a temporary file system and execute from that code base.
>
> Is there a way to accomplish the same within a Python script?
>
> Or must I chain Python and Bash together for this?
>
>           --Fred
>
> ----------
> From: Steve Willoughby <steve at alchemy.com>
> Date: Fri, Apr 22, 2011 at 7:59 PM
> To: tutor at python.org
>
>
> I'm not sure those words mean what you think they mean, or I'm missing what
> you're trying to do here.  halting the root filesystem? pivot? code base?
>
> You're not trying to talk about jail/chroot, perhaps?
>
> --
> Steve Willoughby / steve at alchemy.com
> "A ship in harbor is safe, but that is not what ships are built for."
> PGP Fingerprint 4615 3CCE 0F29 AE6C 8FF4 CA01 73FE 997A 765D 696C
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
> ----------
> From: Frederick Grose <fgrose at gmail.com>
> Date: Fri, Apr 22, 2011 at 8:14 PM
> To: tutor at python.org
>
>
> The particulars are that I've rebuilt a Fedora LiveOS filesystem image from
> a currently running instance (incorporating the filesystem changes in the
> device-mapper overlay into a new base filesystem image file).
>
> I'd like to halt the active rootfs, switch to its mirror, copy over the
> halted filesystem image file with the refreshed version, and then switch
> back.
>
>         --Fred
>
> ----------
> From: Steven D'Aprano <steve at pearwood.info>
> Date: Fri, Apr 22, 2011 at 8:22 PM
> To: tutor at python.org
>
>
> This is way off-topic for a Python tutor list. This is about learning the
> Python programming language, not the intricate corners of (I assume) Linux
> system administration.
>
> I would imagine that it would be very, very difficult in Python, because you
> would need somehow to end the *current* Python process and start up a *new*
> Python process running from executables on the new file system, without
> manual intervention.
>
> I strongly suggest you take this question to the main Python list,
> python at python.org, which is also available as a news group comp.lang.python,
> and show the bash code you are trying to duplicate. There's no guarantee
> you'll get an answer there either, but it's more likely than here.
>
> Good luck!
>
>
> --
> Steven
>
> The Bash code I'm trying to simulate is from Douglas McClendon's
> ZyX-LiveInstaller,
> http://cloudsession.com/dawg/projects/zyx-liveinstaller/
>
> After copying /sbin/dmsetup and its dependencies to
> /dev/shm/zyx-liveinstaller (/dev/shm is mounted on a tmpfs), the following
> code is executed:
>
> LD_LIBRARY_PATH=/dev/shm/zyx-liveinstaller \
>     /dev/shm/zyx-liveinstaller/dmsetup \
>     --noudevrules --noudevsync \
>     suspend "${liveos_root_dev}"
> LD_LIBRARY_PATH=/dev/shm/zyx-liveinstaller \
>     /dev/shm/zyx-liveinstaller/dmsetup \
>     --noudevrules --noudevsync \
>     resume "${liveos_root_dev}-sub"
> LD_LIBRARY_PATH=/dev/shm/zyx-liveinstaller \
>     /dev/shm/zyx-liveinstaller/dmsetup \
>     --noudevrules --noudevsync \
>     resume "${liveos_root_dev}"
>
>
>
>
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>



More information about the Python-list mailing list