Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MuslimHS/4bbe8ec9bc08a9fbc71b73d298773c6b to your computer and use it in GitHub Desktop.
Save MuslimHS/4bbe8ec9bc08a9fbc71b73d298773c6b 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
@MuslimHS
Copy link
Author

MuslimHS commented Apr 26, 2025

📦 Rclone Mount via systemd User Service

Setup Instructions

1. Create the user systemd service

mkdir -p ~/.config/systemd/user
nano ~/.config/systemd/user/[email protected]

Paste this into the file:

# ~/.config/systemd/user/[email protected]

[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

2. Reload the user systemd daemon

systemctl --user daemon-reload

3. Enable and start the service

Replace <remote> with your rclone remote name (example: gdrive-muslim-indomode):

systemctl --user enable --now rclone@<remote>

Example:

systemctl --user enable --now rclone@gdrive-muslim-indomode

4. Check service status

systemctl --user status rclone@<remote>

or

systemctl --user status rclone@gdrive-muslim-indomode

If it shows active (running), the mount is successful!


📜 View Logs

Action Command
View rclone log file cat /tmp/rclone-<remote>.log
Watch log live (file) tail -f /tmp/rclone-<remote>.log
View systemd logs journalctl --user -u rclone@<remote>
Watch systemd logs live journalctl --user -u rclone@<remote> -f

⚡ Notes

  • Changes (uploads, deletes, edits) sync live to your cloud storage.
  • Rclone automatically polls for remote changes every 10 minutes.
  • Logs are saved temporarily in /tmp/ and will be deleted on reboot unless you move them to a permanent location.

✅ Example for gdrive-muslim-indomode

  • Mounts to: /home/muslim/mnt/gdrive-muslim-indomode
  • Log file: /tmp/rclone-gdrive-muslim-indomode.log
  • Start command:
systemctl --user enable --now rclone@gdrive-muslim-indomode

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