4

I had rclone mount my Google Drive on my Android 7 box with the Magisk module and Termux. But it has stopped working and now there's only an empty folder. This is the rclone log:

2020/06/03 07:33:54 mount helper error: CANNOT LINK EXECUTABLE "fusermount": library "libandroid-support.so" not found
2020/06/03 07:33:54 Fatal error: failed to mount FUSE fs: fusermount: signal: aborted.

I just want to mount rclone on my rooted HiMedia Q10 Pro Android TV box so that I can view my GDrive as a permanent folder on my file system.

Irfan Latif
  • 20,353
  • 3
  • 70
  • 213
donpoku
  • 41
  • 1
  • 1
  • 3

1 Answers1

9

The Magisk module you linked is using fusermount binary from this thread which is built for Termux environment. But LD_LIBRARY_PATH environment variable is not being set properly in the module, so the error occurs. A simple approach is to use static fusermount binary, I already posted in the same thread.

rclone uses FUSE which you can mount manually from CLI without relying on Magisk module. I have explained in detail How to bind mount a folder inside /sdcard with correct permissions?. Some issues related to using FUSE on Android are explained in this post. Here I'm describing steps briefly related to rclone only. I'm using Termux for explanation. You can use some other terminal emulator app or adb shell with differences in paths.

Instructions below require that you have a rooted device.

  • Install rclone binary available in Termux repos (by running pkg install rclone) or download from official website official website. Download static fusermount binary from here (available for both aarch64 and armeabi-v7a). Extract the downloaded archive files. I assume that downloaded files are placed in /sdcard/Download/.

  • For ease of repeated use create a shell script /sdcard/Download/rclone_mount.sh using any text editor. Copy/paste the following lines:

    #!/data/data/com.termux/files/usr/bin/bash -e
    

    must be run with root privileges

    [ $(id -u) -eq 0 ] || exec su --mount-master -c "LD_LIBRARY_PATH=$LD_LIBRARY_PATH HOME=$HOME PATH=$PATH:$HOME/bin $0"

    make sure to be in root mount namespace

    [ $(readlink /proc/1/ns/mnt) = $(readlink /proc/self/ns/mnt) ] || nsenter -t 1 -m -- "$0"

    Unmount() { fusermount -u /mnt/runtime/write/emulated/0/GDrive 2>/dev/null || : }

    make sure it's not already mounted

    Unmount

    make sure it's unmounted after rclone is killed

    trap 'sleep 1; Unmount' EXIT

    mount remote in /sdcard/

    rclone -v mount GDrive: /mnt/runtime/write/emulated/0/GDrive --gid 9997 --dir-perms 0771 --file-perms 0660 --umask=0 --allow-other

    See rclone mount manual for explanation on commandline options. Some options may impact the performance.

  • Make sure Termux is granted Storage permission and execute following commands:

    ~$ cd
    ~$ pkg install -y util-linux
    ~$ mkdir -p bin /sdcard/GDrive
    ~$ cp /sdcard/Download/{fusermount,rclone,rclone_mount.sh} bin/
    ~$ chmod -R 0755 bin
    ~$ dos2unix bin/rclone_mount.sh
    ~$ bin/rclone config
    

    Follow the instruction on screen (see rclone config manual for details) to create configuration file (~/.config/rclone/rclone.conf) for Google Drive (or whatever remote service you want to use). I assume you chose the remote name GDrive (as used in above script).


Whenever you need to mount rclone, open Termux and run bin/rclone_mount.sh (or create Termux Widget to run the script from home screen conveniently).

  • All apps with Storage permissions should be able to explore GDrive folder (bind mounting to read and default views isn't necessarily required). But some apps may crash due to slow network activity, others may require more caching (see options) etc.
  • Trigger a Media Scan if e.g. pictures on remote don't appear in gallery app.
  • When done press Ctrl ^C to stop rclone process and mount.
Irfan Latif
  • 20,353
  • 3
  • 70
  • 213
  • Thanks for your detailed answer. You answered about 16 months ago. Is it still the case that the fusermount binary needs to be changed? I'm using rclone-mount 1.16 Magisk module which comes from https://github.com/Magisk-Modules-Repo/com.piyushgarg.rclone. I'm not using Termux and I would prefer a fully automatic full-time mount (which I assume the Magisk module provides). My question is, after 16 months, do you still recommend the Termux approach as described in your answer instead of Magisk module? – MountainX Oct 12 '21 at 21:58
  • 1
    @MountainX I don't use Magisk module, so can't say how well it works. But the manual method I explained should always work. This is how it'll work on any UNIX-like operating system including Android. – Irfan Latif Oct 13 '21 at 01:29
  • So... I have the Magisk module installed. I did a good bit of troubleshooting & it still is not working. Now I tried running your mount command rclone -v mount MYMOUNT: /mnt/runtime/write/emulated/0/MYMOUNT --gid 9997 --dir-perms 0771 --file-perms 0660 --umask=0 --allow-other and it works as expected. I did not change my binaries or use Termux or run your script. I just ran the mount cmd as root. Curious why the the Magisk module mounts are failing when clearly my config and my binaries are capable of working. But I do plan to use your approach. I like that it is clear. Thanks! – MountainX Oct 14 '21 at 02:54
  • I posted a related question here: scripts - How to use rclone-mount with Termux:Boot? - Android Enthusiasts Stack Exchange. I'm not having success with Termux:Boot yet. – MountainX Oct 21 '21 at 04:47
  • @IrfanLatif I believe this approach is no longer need in Android 12. I have managed to mount rclone with a simple command but the problem is that there is no write access, only read and the /mnt/runtime directory seems always empty on Android 12? Or am I missing something? – m33ts4k0z Oct 22 '23 at 17:56
  • The directory tree seems to end here: /mnt/runtime/write/emulated – m33ts4k0z Oct 22 '23 at 18:03
  • I used this method for years to mount pCloud on my phone. But recently I moved to a new model. I tried to setup the mount in the same way, but I got the following error when calling to rclone_mount.sh: 2024/02/16 09:35:38 ERROR : /: Dir.Stat error: couldn't list files: Get "https://eapi.pcloud.com/listfolder?folderid=0": dial tcp: lookup eapi.pcloud.com on [::1]:53: read udp [::1]:41532->[::1]:53: read: connection refused

    The directory to which the cloud storage should be mounted was empty.

    – Ido Feb 16 '24 at 09:43
  • If anyone interested, here is how I solved it. First, I updated rclone binary to a newer version. Most likely pCloud's API has changed and the old binary didn't handle it properly. Second, I replaced this nsenter -t 1 -m -- "$0" with nsenter -t 1 -m -- "$HOME/bin/rclone_mount.sh. Lastly, I created a link to fusermount, so it would also be recognized as fusermount3: ln -s $HOME/bin/fusermount $HOME/bin/fusermount3. Now everything works properly. – Ido Feb 16 '24 at 10:15