CHANGE LEGEND: (you MUST replace these in the service file)
- USERNAME = your actual username e.g. gyarbij
- I recommend changing rclone.service to the name of eache drive if you have multiple mount points.
- If you already have rclone mounts check Step #2 then skip to Step #4 and place your mount point at
#MOUNT
Steps for RClone systemd to autostart on boot
- Install fusermount (if not already installed)
sudo apt install fuse3
- Allow non-root users to mount filesystems
sudo nano /etc/fuse.conf
Uncomment (remove the) # from the line:
allow_other
- Make the requisite directories for mount and cache.
sudo mkdir /mnt/rclonecache
or do all directories at once. You will need to chown
regardless.
sudo mkdir /mnt/{gdrive,rclonecache}
sudo chown -R USERNAME:USERNAME /mnt/{gdrive,rclonecache}
- Create the service(s):
sudo nano /etc/systemd/system/rclone.service
- Copy the below BASIC example 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 #check USERNMAE
RestartSec=10
ExecStart=/usr/bin/rclone mount gdrive: /mnt/gdrive \ #MOUNT
--allow-other \
--dir-cache-time 5000h \
--syslog \
--poll-interval 10s \
--umask 0000 \
--user-agent GoogleDrive \
--cache-dir=/mnt/rclonecache \
--vfs-cache-mode full \
--volname gdrive \ #MOUNT
--vfs-cache-max-size 60G \
--vfs-read-chunk-size 128M \
--vfs-read-ahead 2G \
--vfs-cache-max-age 5000h \
--bwlimit-file 100M
ExecStop=/bin/fusermount -uz /mnt/gdrive #MOUNT
Restart=on-failure
User=USERNAME #change
Group=USERNAME #change
[Install]
WantedBy=multi-user.target
- Save and then exit the file
ctrl+o | ctrl+x
- Run the follwoing commands in order to enable and then start the service:
sudo systemctl daemon-reload
sudo systemctl enable rclone
sudo systemctl start rclone
- To see if the service is running:
systemctl status rclone
- To see if the drive is mounted run:
df -H
-
Reboot and repeat step 7 for a final sanity check!
-
Prevent Docker from starting before mounts:
sudo systemctl edit docker.service
[Service]
#ExecStartPre=/bin/sleep 30
RequiresMountsFor=/mnt/gdrive /media/odrive