How do I mount a filesystem using Python?

前端 未结 10 1953
鱼传尺愫
鱼传尺愫 2020-12-16 09:41

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

10条回答
  •  北海茫月
    2020-12-16 10:04

    You can use Python bindings for libmount from util-linux project:

    import pylibmount as mnt
    
    cxt = mnt.Context()
    cxt.source = '/dev/sda1'
    cxt.target = '/mnt/'
    cxt.mount()
    

    For more information see this example.

提交回复
热议问题