I have a memory filesystem in Python, created in the following fashion:
import fs
mem_fs = fs.open_fs('mem://')
mem_fs.makedirs('/dir1')
with mem_fs.open('/dir1/file1', 'w') as file1:
file1.write('test')
I want to mount this filesystem onto a directory in my OS filesystem (e.g., /home/user/mem_dir). I can create an object that would reference OS filesystem:
os_fs = fs.open_fs('/home/user/mem_dir')
But then I have no idea how to go about mounting mem_fs onto os_fs. I tried using MountFS class, but it only creates a virtual filesystem. I need to create a mount point in a way that other external applications (e.g., nautilus) would be able to see it and copy files to/from there. Any feedback would be appreciated.
I had the same requirement, ans i've managed it this way
it does mount create a directory, with an arbitrary name suffixed by _toto
tmp/ramdisk ❯❯❯ ls
tmpa1_4azgi_toto
which is totaly available as a standard filesystem in the host as in your python code
it look quite magic as it does not appear at all in the mounted host's filesystem
and it does totally disepear when your code end, or when you call
tmp/ramdisk ❯❯❯ ls
tmp/ramdisk ❯❯❯
Cheers