Skip to content

Instantly share code, notes, and snippets.

@kabili207
Last active July 21, 2025 23:00
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 [email protected] 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 [email protected])
# 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
@kabili207
Copy link
Author

I'm glad you caught that because I added the logging for testing initially and completely forgot about it

@SourLemonJuice
Copy link

SourLemonJuice commented Jul 20, 2025

Hi, and thanks for your template. I have two things want to mention though.
The rclone mount#systemd document says:

you should provide --config and --cache-dir explicitly as absolute paths via rclone arguments...

But this template only provides the config path.
Second, the systemd specifiers are already provided XDG_CONFIG_HOME(as %E) and XDG_CACHE_HOME(as %C), so I guess I can use them directly(?)
I use this for my computer:

ExecStart=/bin/rclone mount \
    --config="%E/rclone/rclone.conf" \
    --cache-dir="%C/rclone" \
    --vfs-cache-mode=writes \
    "%i:" "%h/mnt/%i"

By the way, I'm on archlinux with kde plasma, and I don't know why, but I didn't need the --allow-other. Just saying.

@SourLemonJuice
Copy link

@rolfn

In my experience, the -z option (lazy unmount) can be useful in some cases for safely unmounting rclone mounts; at least, its use is not harmful.

I didn't even know about "lazy unmount" this concept in the past. This should solve the problem caused by incomplete data transfer during unmounting. I've already lost some test data before.

Suggestion:

--log-level INFO \
--log-systemd \

They didn't document this flag on the website, almost missed it.

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