Skip to content

Instantly share code, notes, and snippets.

@canemacchina
Forked from Gyarbij/rclone.service.md
Created July 23, 2023 15:40
Show Gist options
  • Save canemacchina/86e6f1eeba82c8f45b336c3294bcc99c to your computer and use it in GitHub Desktop.
Save canemacchina/86e6f1eeba82c8f45b336c3294bcc99c to your computer and use it in GitHub Desktop.
Steps and example RClone systemd with mounted Google Drive for use with Plex en Jellyfin and other similar use-cases. Replace 'nano' with vi or your editor of choice if not on distro with nano included or because you like misery... your kinks are yours :)

CHANGE LEGEND: (you MUST replace these in the service file)

  • USERNAME = your actual username e.g. gyarbij
  1. Make the requisite directories for mount and cache.
   sudo mkdir /mnt/rclonecache
   sudo chown -R USERNAME:USERNAME /mnt/rclonecache
  1. Create the service @:
sudo nano /etc/systemd/system/rclone.service
  1. Copy the below to the service file created/opened above:
[Unit]
Description=RClone Service
Wants=network-online.target
After=network-online.target
AssertPathIsDirectory=/mnt/gdrive

[Service]
Type=notify
Environment=RCLONE_CONFIG=/home/USERNAME/.config/rclone/rclone.conf
RestartSec=10
ExecStart=/usr/bin/rclone mount gdrive: /mnt/gdrive \
   --allow-other \
   --dir-cache-time 5000h \
   --syslog \
   --poll-interval 10s \
   --umask 002 \
   --user-agent GoogleDrive \
   --cache-dir=/mnt/rclonecache \
   --vfs-cache-mode full \
   --volname gdrive \
   --vfs-cache-max-size 60G \
   --vfs-read-chunk-size 1M \
   --vfs-read-ahead 2G \
   --vfs-cache-max-age 5000h \
   --bwlimit-file 100M

ExecStop=/bin/fusermount -uz /mnt/gdrive
Restart=on-failure
User=USERNAME
Group=plex

[Install]
WantedBy=multi-user.target
  1. Save and then exit the file.

  2. Run the follwoing commands in order to enable and then start the service:

sudo systemctl daemon-reload

systemctl enable rclone

systemctl start rclone
  1. To see if the service is running:
systemctl status rclone
  1. To see if the drive is mounted run:
df -H
  1. Reboot and repeat step 7 for a final sanity check!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment