I\'m sure this is a easy question, my Google-fu is obviously failing me.
How do I mount a filesystem using Python, the equivalent of running the shell command
As others have stated, a direct access to the syscall will not help you, unless you're running as root (which is generally bad, for many reasons). Thus, it is best to call out to the "mount" program, and hope that /etc/fstab
has enabled mounts for users.
The best way to invoke mount is with the following:
subprocess.check_call(["mount", what])
where what
is either the device path, or the mountpoint path. If any problems arise, then an exception will be raised.
(check_call
is an easier interface than Popen
and its low-level brethren)