How to use rclone with autofs, where to start?

What is the problem you are having with rclone?

I want to use rclone with autofs to allow on demand mounting and unmounting.

Setting up sshfs mounts with autofs was easy. There are many discussions and guides on the internet. I cannot however find any guide, tutorial or reference for how to use rclone with autofs in the rclone documentation, forum or elsewhere on the web.

Run the command 'rclone version' and share the full output of the command.

rclone v1.68.1

  • os/version: ubuntu 24.04 (64 bit)
  • os/kernel: 6.8.0-47-generic (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.23.1
  • go/linking: static
  • go/tags: none

Which cloud storage system are you using? (eg Google Drive)

Multiple, all of the remotes with when mounting directly from the command line.

The command you were trying to run (eg rclone copy /tmp remote:tmp)

Here is a basic example I have tried:

/etc/auto.master:
/mnt/rclone /etc/auto.rclone --timeout=15 --ghost

/etc/auto.rclone
rclone -fstype=rclone,config=/path/to/rclone.conf,allow_other,id=1000,gid=1000 remote:

When trying to setup my /etc/auto.rclone file I don't even know where to start with the -fstype option. Here are three example I found 3 options from searching this forum:

-fstype=fuse.rclonefs

-fstype=fuse.rclonefsdev

-fstype=rclone

it is not at all clear which one is correct? I have also tried different AIs and I get different answers on how to set this up however, none of them work so I guess this is not clearly documented anywhere?

Also, this post mentions a mount helper script: Automount with rclone but it seems it is not needed anymore with recent version. Is it still required with using autofs?

I also searched the documentation but I did not find any mention of autofs.

None of the forum posting I found actually indicated that the users seeking help were actually successful with using rclone and autfo but there are many posts going back several years so I assume it is possible?

If any users who have successfully setup autofs with rclone options could you please advise of the basic syntax to get it running and or link to a reference where I can find the different rclone options that are supported by autofs? It would be much appreciated.

hi,

just curious, why not use systemd?
TimeoutIdleSec Once the mount has been idle for the specified time, systemd will attempt to unmount

Good question, I tried systemd first for an entire day however I have a mix sshfs and rclone remotes. The premise of using systemd to manage sshfs mounts is fundamentally flawed. Fuse is a userspace utility and systemd does not allow --user units to automount on demand, root is required. systemd offers very basic options when mounting remote drives.

This has several implications such as you cannot use your .ssh/config file, you can also not use encrypted keys with passwords as the root user has no access to any user environment such as any ssh agent running which can supply the password.

autofs also mounts in root however it is much more flexible and scriptable and has the possible to access config, userenv and ssh agents. autofs also handles the mounts much better when the system needs to suspend whereas systemd often hangs.

It works great for sshfs and apparently it also works for rclone but I can't find any documentation on the basic syntax. I think according to this post: Example for rclone 1.57 together with autofs (without rclone-mount-helper-script) that -fstype=rclone is correct once your create the ln however my basic example still doesn't work:

/etc/auto.master:
/mnt/rclone /etc/auto.rclone --timeout=15 --ghost

/etc/auto.rclone
rclone -fstype=rclone,config=/path/to/rclone.conf,allow_other,id=1000,gid=1000 :remote:

When I systemctl start autofs autofs created the rclone mount point but doesn't mount anything. I don't see any errors in the journal either it just silently fails.

good answer ;)

maybe need to use rclone debug output and a rclone debug log?

Yes I tried adding the loglevel option but it did not have any effect:

rclone -fstype=rclone,config=/path/to/rclone.conf,allow_other,id=1000,gid=1000,log-level=DEBUG remote:

This is the problem I am having, I don't know which rclone options work with autofs, I assume not all of them but I also can't find a reference or guide either. I am hoping a user who has successfully manged to get these two working together can provide a basic working example. Then once it is here other users can find this thread and use it as a place to start.

Okay I don't have a reference yet but I did find a way to debug:

sudo service autofs stop
sudo automount -fFvd auto.master

from @ kforner post here: Ls on autofs triggered rclone mount hangs the first time

So a working basic case is this:

/etc/auto.master:
/mnt/rclone /etc/auto.rclone --timeout=15 --ghost

/etc/auto.rclone
rclone -fstype=rclone,config=/path/to/rclone.conf,allow_other,gid=1000,gid=1000 :remote:

the 'g' in gid=1000 was missing. I still don't understand what the colons around the remote mean: :remote:

Thanks for engaging @ asdffdsa and helping me get unstuck, as usual you are a credit to this forum.

Now I have to figure out a way to pass the rclone config password though to autofs which should be fun.

thanks much!


check this post from a few minutes ago. makes mention of autofs.
Unmount only if directory was mounted by rclone, e.g. don't unmount autofs hooks.