Skip to content

Instantly share code, notes, and snippets.

@kabili207
Last active January 24, 2025 06:13
Show Gist options
  • Save kabili207/2cd2d637e5c7617411a666d8d7e97101 to your computer and use it in GitHub Desktop.
Save kabili207/2cd2d637e5c7617411a666d8d7e97101 to your computer and use it in GitHub Desktop.
Rclone systemd user service

rclone systemd service

Preparation

This service will use the same remote name you specified when using rclone config create. If you haven't done that yet, do so now.

Next, create the mountpoint for your remote. The service uses the location ~/mnt/<remote> by default.

mkdir ~/mnt/dropbox

The --allow-other option is required in order to work in many desktop environments. This flag must be enabled by adding user_allow_other to /etc/fuse.conf. If you aren't using a desktop environment, such as on a server, this option can be omitted.

Adding the service

Save the rclone@.service file in ~/.config/systemd/user/ Make sure you include the @. This is required to work.

As your normal user, run:

systemctl --user daemon-reload

Using the service

You can now start/enable each remote by using rclone@<remote>

systemctl --user enable --now rclone@dropbox
# User service for Rclone mounting
#
# Place in ~/.config/systemd/user/
# File must include the '@' (ex rclone@.service)
# As your normal user, run
# systemctl --user daemon-reload
# You can now start/enable each remote by using rclone@<remote>
# systemctl --user enable --now rclone@dropbox
[Unit]
Description=rclone: Remote FUSE filesystem for cloud storage config %i
Documentation=man:rclone(1)
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
ExecStartPre=-/usr/bin/mkdir -p %h/mnt/%i
ExecStart= \
/usr/bin/rclone mount \
--config=%h/.config/rclone/rclone.conf \
--vfs-cache-mode writes \
--vfs-cache-max-size 100M \
--log-level INFO \
--log-file /tmp/rclone-%i.log \
--umask 022 \
--allow-other \
%i: %h/mnt/%i
ExecStop=/bin/fusermount -u %h/mnt/%i
[Install]
WantedBy=default.target
@jibarozzo
Copy link

Hi, my service stopped working all of a sudden. It would fail to start after reboot and reloading daemon. I reinstalled fuse3 and Plasma 6 , and removed the --allow_users flag. After this the service started fine. I realized that something might have broken with updating this week(Arch on LTS kernel). When I checked the /etc/fuse.conf file user_allow_other was commented. This was un-commented before. I also tried it with the --allow_users flag again and user_allow_other un-commented and it worked as before. Just an FYI.

@GavinKCLS
Copy link

Just wanted to say thanks for this - works great for me

@nilreml
Copy link

nilreml commented May 5, 2024

Hi, my service stopped working all of a sudden. It would fail to start after reboot and reloading daemon. I reinstalled fuse3 and Plasma 6 , and removed the --allow_users flag. After this the service started fine. I realized that something might have broken with updating this week(Arch on LTS kernel). When I checked the /etc/fuse.conf file user_allow_other was commented. This was un-commented before. I also tried it with the --allow_users flag again and user_allow_other un-commented and it worked as before. Just an FYI.

Good point, thanks. /etc/fuse.conf gets overwritten on upgrading whenever it's content in the package changes, and multiple config file loading like /etc/apt/sources.list.d/* isn't yet supported AFAIK.

If you don't need to access the mount with users other than your own, it's actually safer and easier to just remove --allow-other from rclone mount options, which doesn't require setting user_allow_other.

Tested on Debian 12.5, rclone 1.66

@Nathan22211
Copy link

gave this a go but no luck, I get this Job for rclone@gDrive.service failed because the control process exited with error code. See "systemctl --user status rclone@gDrive.service" and "journalctl --user -xeu rclone@gDrive.service" for details.

@kabili207
Copy link
Author

@Nathan22211 I would recommend running the two commands it suggests to see what went wrong

@Nathan22211
Copy link

ok well it's definitely something with fuse... Failed to start rclone: Remote FUSE filesyste m for cloud storage config gDrive. I have fuse 3 and fuse 2 on my system. fuse3 for rclone and fuse2 for orca slicer

@kabili207
Copy link
Author

That's just systemd taking the description from line 11 and saying it couldn't start it.

Try copying the command on lines 20 through 28 and running it directly in the terminal. You'll need to replace the values %h with the path to your home directory and %i with the name of the remote when you do this

@Nathan22211
Copy link

yeah that did nothing at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment