Fusermount on android (rclone mount)

Search This thread

swie

Member
Jan 23, 2019
6
0
Hello.
I succesfully instaled fusermount on my LG k350n device (stock rom with supersu). But I have a problem doing rclone mount commad.
See below:
Code:
 $ rclone mount gcache: gdrive --allow-other --cache-db-purge --allow-non-empty --buffer-size 256M --dir-cache-time 72h --drive-chunk-size 32M --timeout 1h --vfs-cache-mode minimal --vfs-read-chunk-size 128M --vfs-read-chunk-size-limit 1G &
[1] 30993
$ 2019/10/22 13:43:43 mount helper error: fusermount: failed to open /dev/fuse: Permission denied
2019/10/22 13:43:43 Fatal error: failed to mount FUSE fs: fusermount: exit status 1
I try change permissions of fuse file but nothig helps.
Code:
 $ ls -al fuse                                     crwxrwxrwx 1 u0_a138 u0_a138 10, 229 Sep 29 10:00 fuse
Do You know how fix this ?
Sorry for my bugs in english language ;)
 

agnostic-apollo

Senior Member
Jun 2, 2015
236
88
Hello.
I succesfully instaled fusermount on my LG k350n device (stock rom with supersu). But I have a problem doing rclone mount commad.
See below:
Code:
 $ rclone mount gcache: gdrive --allow-other --cache-db-purge --allow-non-empty --buffer-size 256M --dir-cache-time 72h --drive-chunk-size 32M --timeout 1h --vfs-cache-mode minimal --vfs-read-chunk-size 128M --vfs-read-chunk-size-limit 1G &
[1] 30993
$ 2019/10/22 13:43:43 mount helper error: fusermount: failed to open /dev/fuse: Permission denied
2019/10/22 13:43:43 Fatal error: failed to mount FUSE fs: fusermount: exit status 1
I try change permissions of fuse file but nothig helps.
Code:
 $ ls -al fuse                                     crwxrwxrwx 1 u0_a138 u0_a138 10, 229 Sep 29 10:00 fuse
Do You know how fix this ?
Sorry for my bugs in english language ;)

run command with su permissions, if using termux install tsu or sudo
 
  • Like
Reactions: swie

swie

Member
Jan 23, 2019
6
0
Thank you.
Now. I have mounted my gdrive in /mnt/gdrive and I can list my files in termux. But only in termux.
So next question is how do it visible for any installed app in my phone ?
There is also possible to saw this in my computer connected with usb cable ?
 

agnostic-apollo

Senior Member
Jun 2, 2015
236
88
For people who are getting empty folders outside termux, is most likely because mount namespace seperation is enabled in their supersu or magisk. I don't use magisk so don't know the exact option but for supersu, just uncheck "Mount namespace seperation" in its settings and reboot and try after that.

Thank you.
Now. I have mounted my gdrive in /mnt/gdrive and I can list my files in termux. But only in termux.
So next question is how do it visible for any installed app in my phone ?
There is also possible to saw this in my computer connected with usb cable ?

check above... computer one over usb is probably not possible, atleast easily... set up rclone on computer with the same rclone config file, no point in connecting over a usb cable...
 

mirfatif

Senior Member
Oct 18, 2016
706
519
t.me
Sorry but it's not working for me. Still I don't have new partition visible in other apps.
Maybe I mount in wrong directory ? Should be in /storage ?
You need to take care of four things: 1. Ownership 2. Permission mode 3. SELinux context 4. Mount namesapce. Even if one is misconfigured, non-root apps won't be able to access mount point.
 
Last edited:
  • Like
Reactions: swie

swie

Member
Jan 23, 2019
6
0
It sounds complicated.
Can You help me step by step how do it ?
I don't know how check all this points.
 

ddogishere

Senior Member
Nov 9, 2013
269
21
hi is there link to a Step guide to view my unlimited gdrive as Plex server on rooted/magisk android himedia q10 pro?

Many thanks.
 

ddogishere

Senior Member
Nov 9, 2013
269
21
Hi all in rclone I get message:not enough space when copy or mount 1gb+ file to storage/cloud written gdrive unlimited storage any idea why?
Thx
 
Last edited:

swie

Member
Jan 23, 2019
6
0

Still withought succes.
I use command
Code:
rclone mount gcache: /mnt/runtime/write/emulated/0/gdrive --uid=0 --gid=9997 --umask=022 --allow-other --cache-db-purge --allow-non-empty --buffer-size 64M --dir-cache-time 72h --drive-chunk-size 16M  --timeout 1h  --vfs-cache-mode minimal --vfs-read-chunk-size 128M --vfs-read-chunk-size-limit 1G &
So I set permissions like another visible folder. But then my cloud files are visible only for root user.
What command should be correct and where I must mount ?
Please help.
 

agnostic-apollo

Senior Member
Jun 2, 2015
236
88
Still withought succes.
I use command
Code:
rclone mount gcache: /mnt/runtime/write/emulated/0/gdrive --uid=0 --gid=9997 --umask=022 --allow-other --cache-db-purge --allow-non-empty --buffer-size 64M --dir-cache-time 72h --drive-chunk-size 16M  --timeout 1h  --vfs-cache-mode minimal --vfs-read-chunk-size 128M --vfs-read-chunk-size-limit 1G &
So I set permissions like another visible folder. But then my cloud files are visible only for root user.
What command should be correct and where I must mount ?
Please help.

alas...

you are supposed to run rclone mount command to some dir outside the .../runtime/.../emulated/* directory like inside /mnt/grdrive and then run "mount -o bind" commands from /mnt/gdrive to all 3 runtime dirs

I have written a few bash scripts and tasker projects that handles all this safely... the bash scripts can be uploaded in a day or two, have to do some testing and write documentation... let me know if anybody needs them... testers would be helpful actually...

For now, try following the following...
hopefully it should help and work for you, working for me. I haven't tested the android version <6 code but it should work...


Code:
###rclone mount commands must be run from global mount namespace, otherwise mounts will not be seen outside the terminal/shell and you will get empty directories in other apps
#check if you are in global namespace
[[ "$(readlink /proc/1/ns/mnt)" == "$(readlink /proc/self/ns/mnt)" ]] && echo "using global mount namespace" || "not using global mount namespace"

#If not, then in your superuser app, disable mount namespace separation or enable global mount namespace and reboot device
#SuperSu Settings -> Uncheck "Mount namespace separation"
#Magisk  Settings -> Set "Mount Namespace Mode" to "Global"



####mount
#remount android rootfs as rw
mount -o rw,remount /

#create main mount point
mkdir -p "/mnt/rclone_gdrive"

#run rclone mount command
rclone mount --daemon --allow-other "gdrive:" "/mnt/rclone_gdrive"

#create bind mount points so that all apps can see remote
#create bind mount point directory and set permissions
mkdir -p "/data/media/0/rclone_gdrive"
chown media_rw:media_rw "/data/media/0/rclone_gdrive"
chmod 0700 "/data/media/0/rclone_gdrive"

#run bind mount commands for android version >=6
mount -o bind "/mnt/rclone_gdrive" "/mnt/runtime/default/emulated/0/rclone_gdrive"
mount -o bind "/mnt/rclone_gdrive" "/mnt/runtime/read/emulated/0/rclone_gdrive"
mount -o bind "/mnt/rclone_gdrive" "/mnt/runtime/write/emulated/0/rclone_gdrive"

#run bind mount commands for android version <6
mount -o bind "/mnt/rclone_gdrive" "/data/media/0/rclone_gdrive"
mount -o bind "/mnt/rclone_gdrive" "/storage/emulated/0/rclone_gdrive"

#remount android rootfs back as ro
mount -o ro,remount /

#note that 
#android version >=6 uses runtime permissions model and hence there are runtime mounts
"/data/media/0" is the main ext4 filesystem which is emulated/mounted on "/mnt/runtime/{default,read,write}/emulated/0" and "/storage/emulated/0" using sdcardfs filesystem
#apps can only see the "/storage/emulated/0" depending on the permissions the app has
#bind mounting on all 3 runtime directories may be necessary depending on the device
#in my LG G5 7.0, it is necessary, and bind mounting on "/mnt/runtime/default/emulated/0" automatically creates the mount on "/storage/emulated/0"
#if that isn't being created then manually create it
#for versions below use install-time permissions model and there are no runtime mounts
#instead "/data/media/0" is just mounted at "/storage/emulated/0" using fuse filesystem
#the "0" indicated the user "0"



###unmount
#kill rclone mount command
pgrep -f "rclone mount .* /mnt/rclone_gdrive.*" | xargs kill

#run mount command to check all active mounts
mount

#if "gdrive: /mnt/rclone_gdrive" is still listed, it means rclone mount command quit with unmounting it
#this could be because some process like your file browser was using the mount point when rclone mount command was killed
#try unmounting main mount point manually
umount "/mnt/rclone_gdrive"
#you may get target or resource is busy errors
#run fuser to kill all processes using mount point
fuser -mks "/mnt/rclone_gdrive"
#then unmount
umount "/mnt/rclone_gdrive"
#if instead you got transport endpoint not connected errors
#then lazy unmount
umount -l "/mnt/rclone_gdrive"
#invalid arguments errors would mean that mount point is not mounted

#unmount all bind mount points for android version >=6
umount "/mnt/runtime/default/emulated/0/rclone_gdrive"
umount "/mnt/runtime/read/emulated/0/rclone_gdrive"
umount "/mnt/runtime/write/emulated/0/rclone_gdrive"

#run bind mount commands for android version <6
umount "/data/media/0/rclone_gdrive"
umount "/storage/emulated/0/rclone_gdrive"


###refresh rclone mount point so that any changes in remote can be seen
#sending SIGHUP to rclone mount command makes it drop all caches
#otherwise changes appear after cache timeout is over
pgrep -f "rclone mount .* /mnt/rclone_gdrive.*" | xargs kill -s SIGHUP
 
Last edited:
  • Like
Reactions: Cubuss and swie

mirfatif

Senior Member
Oct 18, 2016
706
519
t.me
Still withought succes.
I use command
Code:
rclone mount gcache: /mnt/runtime/write/emulated/0/gdrive --uid=0 --gid=9997 --umask=022 --allow-other --cache-db-purge --allow-non-empty --buffer-size 64M --dir-cache-time 72h --drive-chunk-size 16M  --timeout 1h  --vfs-cache-mode minimal --vfs-read-chunk-size 128M --vfs-read-chunk-size-limit 1G &
So I set permissions like another visible folder. But then my cloud files are visible only for root user.
What command should be correct and where I must mount ?
Please help.

I just tested:
Code:
~# nsenter -t 1 -m -- rclone mount GDrive: /mnt/runtime/write/emulated/0/GDrive --gid 9997 --dir-perms 0771 --file-perms 0660 --umask=0 --allow-other
And it works perfectly. My file explorer and gallery apps are able to see the files. Rclone doesn't accept mount "--option" at the moment, so can't pass "context=" option. But the default SELinux label for FUSE (u:eek:bject_r:fuse:s0) is readable/writable by apps in default SELinux policy, so it works in "enforcing" mode.
Mounting to "read" and "default" views isn't necessary. READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE belong to same permission group. So granting one to an app also grants the other (except if you explicitly deny one using "pm"). "default" is only to let apps (which don't have READ|WRITE STORAGE permission) traverse "/sdcard/Android/data" directories, no other files in "/sdcard" are readable at all.
Also in my experience mounting to one view also propagates to the other two (at least on "sdcardfs").
 
Last edited:
  • Like
Reactions: swie

agnostic-apollo

Senior Member
Jun 2, 2015
236
88
I just tested:
Code:
~# nsenter -t 1 -m rclone mount GDrive: /mnt/runtime/write/emulated/0/GDrive --gid 9997 --dir-perms 0771 --file-perms 0660 --umask=0 --allow-other
And it works perfectly. My file explorer and gallery apps are able to see the files. Rclone doesn't accept mount "--option" at the moment, so can't pass "context=" option. But the default SELinux label for FUSE (u:eek:bject_r:fuse:s0) is readable/writable by apps in default SELinux policy.
Mounting to "read" and "default" views isn't necessary. READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE belong to same permission group. So granting one to an app also grants the other (except if you explicitly deny one using "pm"). "default" is only to let apps (which don't have READ|WRITE STORAGE permission) traverse "/sdcard/Android/data" directories, no other files in "/sdcard" are readable at all.
Also in my experience mounting to one view also propagates to the other two, so mounting to all isn't necessary.


no propogation in my case whether i bind mount at default or write, like i said, it would depend on the device itself, it might not be universal... mounting to only write does give apps access in my case but maintaining the convention of mounting to all 3 runtime directories should be maintained like its done for internal and external storage by android, even though it might not be necessary for most people, but it could potentially break on some random device, custom implementation or use case and then those people are left with an unknown bug and bang their head about it ;)

3eTKEZp.jpg
 
  • Like
Reactions: Cubuss

mirfatif

Senior Member
Oct 18, 2016
706
519
t.me
no propogation in my case whether i bind mount at default or write, like i said, it would depend on the device itself, it might not be universal...
I can't recall exactly what was the case with FUSE (it's been a few years), but with "sdcardfs" emulation "/mnt/runtime/read/emulated" and "/mnt/runtime/write/emulated" are actually bind mounted from "/mnt/runtime/default/emulated" first, then remounted with changed permissions. So mounting on one VIEW propagates to others due to bind mount.
it could potentially break on some random device, custom implementation or use case
I can't think of a practical situation where things may break because of this but to be on safe side is a good thing. However you may consider putting a check so that 3 mounts don't become 9. Though this won't either break anything but output from "mount" command may again perplex someone.
 

pmj_pedro

Member
Dec 20, 2014
37
14
I had no idea that there was so much interest in this. Sorry for ghosting but I didn't receive any notifications from this thread. @agnostic-apollo thanks for creating a Magisk Module, I may want to use in the future on my MediaPad.
 

Cubuss

Member
Aug 5, 2014
21
11
just wanna say thank you guys , after messning around with webdav and smb to mount a network drive with no avail.
i did find the rclone magisk module but unfortunately the vfs-cache-mode wasn'nt working which i did need in my usecase,

Nice thing to have rclone natively on android now with mount working,,
 

darfri

Senior Member
Nov 13, 2008
936
64
OnePlus 6T
just wanna say thank you guys , after messning around with webdav and smb to mount a network drive with no avail.
i did find the rclone magisk module but unfortunately the vfs-cache-mode wasn'nt working which i did need in my usecase,

Nice thing to have rclone natively on android now with mount working,,
Its nice to see someone happy with magisk version as it is very hard to get adequate support for it.
I tried to have mine over sftp and all I had were empty folders from sever, I think it was one level directory depth only also
 

Cubuss

Member
Aug 5, 2014
21
11
Its nice to see someone happy with magisk version as it is very hard to get adequate support for it.
I tried to have mine over sftp and all I had were empty folders from sever, I think it was one level directory depth only also

Like i said at first i was using the magisk module to but it was getting me empty folders when using the vfs-cache-mode parameter ,
Really needed vfs-cache-mode for my use case so i found this thread and im now running rclone directly via termux without magisk,
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 9
    Disclaymer: I am not responsible by what this binary can cause to your phone.

    In the past month I have been struggling with getting "rclone mount" working on my phone, and after not finding anyway to have fuse working on my phone I decided to compile the fusermount.
    Yoy should copy the binary to /system/bin or add to your path "export PATH=$PATH:/path_to_fusermount"

    I use the source code from: https://github.com/LineageOS/android_external_fuse/tree/cm-14.1
    and https://github.com/kirbyfan64/zdata/blob/master/fs/jni/fusermount.mk to compile the binary

    In my case I can now use rclone in the following way (you still need to have root access), on a terminal (termux) for android:
    Code:
    su
    rclone mount Box:/ /storage/cloud --vfs-cache-mode minimal --allow-other --gid 1015

    Tested on:
    • Mi4c cm14.1 (android 7.1)
    • Huawei Mediapad M5 (android 8)
    2
    Still withought succes.
    I use command
    Code:
    rclone mount gcache: /mnt/runtime/write/emulated/0/gdrive --uid=0 --gid=9997 --umask=022 --allow-other --cache-db-purge --allow-non-empty --buffer-size 64M --dir-cache-time 72h --drive-chunk-size 16M  --timeout 1h  --vfs-cache-mode minimal --vfs-read-chunk-size 128M --vfs-read-chunk-size-limit 1G &
    So I set permissions like another visible folder. But then my cloud files are visible only for root user.
    What command should be correct and where I must mount ?
    Please help.

    alas...

    you are supposed to run rclone mount command to some dir outside the .../runtime/.../emulated/* directory like inside /mnt/grdrive and then run "mount -o bind" commands from /mnt/gdrive to all 3 runtime dirs

    I have written a few bash scripts and tasker projects that handles all this safely... the bash scripts can be uploaded in a day or two, have to do some testing and write documentation... let me know if anybody needs them... testers would be helpful actually...

    For now, try following the following...
    hopefully it should help and work for you, working for me. I haven't tested the android version <6 code but it should work...


    Code:
    ###rclone mount commands must be run from global mount namespace, otherwise mounts will not be seen outside the terminal/shell and you will get empty directories in other apps
    #check if you are in global namespace
    [[ "$(readlink /proc/1/ns/mnt)" == "$(readlink /proc/self/ns/mnt)" ]] && echo "using global mount namespace" || "not using global mount namespace"
    
    #If not, then in your superuser app, disable mount namespace separation or enable global mount namespace and reboot device
    #SuperSu Settings -> Uncheck "Mount namespace separation"
    #Magisk  Settings -> Set "Mount Namespace Mode" to "Global"
    
    
    
    ####mount
    #remount android rootfs as rw
    mount -o rw,remount /
    
    #create main mount point
    mkdir -p "/mnt/rclone_gdrive"
    
    #run rclone mount command
    rclone mount --daemon --allow-other "gdrive:" "/mnt/rclone_gdrive"
    
    #create bind mount points so that all apps can see remote
    #create bind mount point directory and set permissions
    mkdir -p "/data/media/0/rclone_gdrive"
    chown media_rw:media_rw "/data/media/0/rclone_gdrive"
    chmod 0700 "/data/media/0/rclone_gdrive"
    
    #run bind mount commands for android version >=6
    mount -o bind "/mnt/rclone_gdrive" "/mnt/runtime/default/emulated/0/rclone_gdrive"
    mount -o bind "/mnt/rclone_gdrive" "/mnt/runtime/read/emulated/0/rclone_gdrive"
    mount -o bind "/mnt/rclone_gdrive" "/mnt/runtime/write/emulated/0/rclone_gdrive"
    
    #run bind mount commands for android version <6
    mount -o bind "/mnt/rclone_gdrive" "/data/media/0/rclone_gdrive"
    mount -o bind "/mnt/rclone_gdrive" "/storage/emulated/0/rclone_gdrive"
    
    #remount android rootfs back as ro
    mount -o ro,remount /
    
    #note that 
    #android version >=6 uses runtime permissions model and hence there are runtime mounts
    "/data/media/0" is the main ext4 filesystem which is emulated/mounted on "/mnt/runtime/{default,read,write}/emulated/0" and "/storage/emulated/0" using sdcardfs filesystem
    #apps can only see the "/storage/emulated/0" depending on the permissions the app has
    #bind mounting on all 3 runtime directories may be necessary depending on the device
    #in my LG G5 7.0, it is necessary, and bind mounting on "/mnt/runtime/default/emulated/0" automatically creates the mount on "/storage/emulated/0"
    #if that isn't being created then manually create it
    #for versions below use install-time permissions model and there are no runtime mounts
    #instead "/data/media/0" is just mounted at "/storage/emulated/0" using fuse filesystem
    #the "0" indicated the user "0"
    
    
    
    ###unmount
    #kill rclone mount command
    pgrep -f "rclone mount .* /mnt/rclone_gdrive.*" | xargs kill
    
    #run mount command to check all active mounts
    mount
    
    #if "gdrive: /mnt/rclone_gdrive" is still listed, it means rclone mount command quit with unmounting it
    #this could be because some process like your file browser was using the mount point when rclone mount command was killed
    #try unmounting main mount point manually
    umount "/mnt/rclone_gdrive"
    #you may get target or resource is busy errors
    #run fuser to kill all processes using mount point
    fuser -mks "/mnt/rclone_gdrive"
    #then unmount
    umount "/mnt/rclone_gdrive"
    #if instead you got transport endpoint not connected errors
    #then lazy unmount
    umount -l "/mnt/rclone_gdrive"
    #invalid arguments errors would mean that mount point is not mounted
    
    #unmount all bind mount points for android version >=6
    umount "/mnt/runtime/default/emulated/0/rclone_gdrive"
    umount "/mnt/runtime/read/emulated/0/rclone_gdrive"
    umount "/mnt/runtime/write/emulated/0/rclone_gdrive"
    
    #run bind mount commands for android version <6
    umount "/data/media/0/rclone_gdrive"
    umount "/storage/emulated/0/rclone_gdrive"
    
    
    ###refresh rclone mount point so that any changes in remote can be seen
    #sending SIGHUP to rclone mount command makes it drop all caches
    #otherwise changes appear after cache timeout is over
    pgrep -f "rclone mount .* /mnt/rclone_gdrive.*" | xargs kill -s SIGHUP
    1
    Has anyone got afwall? What to unblock? I'd hate to unblock multicomponent system apps.
    Maybe a custom iptables script?
    1
    For people who are getting empty folders outside termux, is most likely because mount namespace seperation is enabled in their supersu or magisk. I don't use magisk so don't know the exact option but for supersu, just uncheck "Mount namespace seperation" in its settings and reboot and try after that.

    I have successfully done a 64-bit on-device build inside termux for fusermount with the relevant patches. Its working fine for now and most likely will work better for people. I plan to release the binaries, the source code and tasker projects related to it hopefully in the next few days, but if someone needs the binaries earlier, let me know.
    1
    I get an error
    Using rclone installed by magisk 20.4 on xperia xz2 compact Android 9
    type = dropbox
    token = {"access_token" deleted this ,"token_type":"bearer","expiry":"0001-01-01T00:00:00Z"}
    --------------------
    y) Yes this is OK (default)
    e) Edit this remote
    d) Delete this remote
    y/e/d> y
    2020/07/19 11:51:11 Failed to save config after 10 tries: Failed to create temp file for new config: open /.rclone.conf683676049: read-only file system
    1|:/storage/emulated/0/Android/data/com.sonelli.juicessh/files #

    What can i do?
    Wait for it to be updated with a fix for config file location. The root location "/.rclone" can't be created because of permissions. It should be saved to sdcard/.rclone