Skip to content

Instantly share code, notes, and snippets.

@gmag11
Last active March 27, 2024 04:01
Show Gist options
  • Save gmag11/dc139ffd6a8ca8b622e98ca6422f8d79 to your computer and use it in GitHub Desktop.
Save gmag11/dc139ffd6a8ca8b622e98ca6422f8d79 to your computer and use it in GitHub Desktop.
Mount multiple RClone remotes on boot with a single SystemD forking service definition
# Rclone mount on boot
# Copy file to: /etc/systemd/system
# You need to create a remote on RClone and a folder on your disk, both with same name <rclone-remote>
# This example uses /cloud/ folder as origin to mount all remotes, change it to your needs
# This example use a linux user named rclone. Create it or adapt it to your needs. Rclone will get config from that user's home folder
# Register new service by typing:
# sudo systemctl daemon-reload
# Do the next one for every remote you want to load on boot
# sudo systemctl enable rclone-mount@<rclone-remote>.service
# systemctl start rclone-mount@<rclone-remote>.service
# Usage:
# To unmount drive use
# systemctl stop rclone-mount@<rclone-remote>.service
# To mount use:
# systemctl start rclone-mount@<rclone-remote>.service
# To disable mount on boot use:
# systemctl disable rclone-mount@<rclone-remote>.service
[Unit]
Description=rclone FUSE mount for %i
Documentation=http://rclone.org/docs/
After=network-online.target # externo.mount # This is only needed if you use an external USB hard drive in order to wait for it to be mounted
# Mount point in my system is on a USB drive, don't ask why :))), that's why I have to wait for it to get mounted
Requires=externo.mount
[Service]
#Type=forking
# This example use a linux user named rclone. Create it or adapt it to your needs. Rclone will get config from that user's home folder
User=rclone
Group=rclone
# This example uses /cloud/ folder as origin to mount all remotes, change it to your needs
# --vfs-cache-mode full activates cache for writting and reading. Check RClone documentation
ExecStart=/usr/bin/rclone mount %i: /cloud/%i --vfs-cache-mode full -v --allow-other
ExecStop=/bin/fusermount -uz /cloud/%i
[Install]
#Wants=network-online.target
#Alias=rclone-rs
#RequiredBy=
WantedBy=multi-user.target
@ADOBApps
Copy link

ADOBApps commented Mar 3, 2023

Buenas noches, vengo a compartirles la configuración con la que logré montar el servicio, seguí todas las intrucciones sin embargo no me funcionaba, (cabe resaltar que esto lo llevé a cabo en una antigua computadora con Lubuntu 18.04.5). Siguiendo las instrucciones lograba montar las unidades sin embargo el sistema de archivos no reconocía los "mountpoint" como carpetas y no era posible acceder a estos. Tras horas de busqueda, recordé que la función experimental rclone gui web había logrado montar las unidades sin problema, fui y revicé usando la documentación y logré llegar a esto

`[Unit] Description=rclone FUSE mount for %i #Wants=network-online.target After=network-online.target

[Service] Type=notify TimeoutStopSec=60 Environment=GOMAXPROCS=2

User=root Group=root

ExecStart=/usr/bin/rclone mount remote_drive: /media/SharedFiles/Gdrive_workstation --config /home/user/.config/rclone/rclone.conf --use-mmap --poll-interval=15s --vfs-cache-mode full --tpslimit 10 --vfs-write-back 5000000000s --vfs-cache-max-age 3600000000000 --vfs-cache-poll-interval 60000000000 --async-read --attr-timeout 1000000000 --max-read-ahead 131072 --noappledouble --umask 2 --uid 1000 --file-perms 666 --dir-perms 777 --gid 1000 --dir-cache-time 300000000000 --vfs-read-chunk-size 134217728 --allow-root --allow-other --default-permissions

ExecStop=/bin/fusermount -uz /media/SharedFiles/Gdrive_workstation

[Install] WantedBy=multi-user.target `

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