rclone Systemd startup mount script
Category : How-to
Rclone is a command line utility used for reading and writing to almost any type of cloud or remote storage. From Google Drive to Ceph, rclone supports almost any cloud-based remote storage platform you can think of. You can perform upload, download or
In addition to this,
Before we get going, make sure you have rclone installed on your system and configured with a remote.
curl https://rclone.org/install.sh | sudo bash
rclone config
Once you have a remote defined, it’s time to create the mountpoint and systemd script. I’ll be using Google Drive for this example, but the mount command works for any supported remote.
Create the mount point directory to use for the remote storage:
mkdir /mnt/google-drive
Next, create the below systemd script and edit it as required:
vi /etc/systemd/system/rclone.service
# /etc/systemd/system/rclone.service
[Unit]
Description=Google Drive (rclone)
AssertPathIsDirectory=/mnt/google-drive
After=plexdrive.service
[Service]
Type=simple
ExecStart=/usr/bin/rclone mount \
--config=/root/.config/rclone/rclone.conf \
--allow-other \
--cache-tmp-upload-path=/tmp/rclone/upload \
--cache-chunk-path=/tmp/rclone/chunks \
--cache-workers=8 \
--cache-writes \
--cache-dir=/tmp/rclone/vfs \
--cache-db-path=/tmp/rclone/db \
--no-modtime \
--drive-use-trash \
--stats=0 \
--checkers=16 \
--bwlimit=40M \
--dir-cache-time=60m \
--cache-info-age=60m gdrive:/ /mnt/google-drive
ExecStop=/bin/fusermount -u /mnt/google-drive
Restart=always
RestartSec=10
[Install]
WantedBy=default.target
The important parts are detailed below, however, there are various other options are detailed on the
- –config – the path to the config file created by rclone config. This is usually located in the users home directory.
gdrive :/ /mnt/google-drive – details two things; firstly the config name created in rclone config, and secondly the mount point on the local filesystem to use.
Once all this is in place you’ll need to start the service and enable the service at system startup (if required)
systemctl start rclone
systemctl enable rclone
12 Comments
Peter
13-Feb-2019 at 10:45 amThanks for your post. I still have issues with autostarting rclone on ubuntu 16. I will try your configuration and let you know if it fixed it!
Filippo
14-Mar-2019 at 6:39 amHi, thanks for the guide: it’s pretty straightforward. However i CAN’T mount my google drive.
I created a folder in my “data disk” /mnt/79f72362-129f-42e4-ae4a-98159748c9c6/Gdrive and my rclone config file is store in my home folder /home/mosco/.config/rclone/rclone.conf
Remote in rclone is called gdrive:
I can mount it manually via rclone mount gdrive: /mnt/79f72362-129f-42e4-ae4a-98159748c9c6/Gdrive
I edited the script you posted like this
# /etc/systemd/system/rclone.service
[Unit]
Description=Google Drive (rclone)
AssertPathIsDirectory=/mnt/79f72362-129f-42e4-ae4a-98159748c9c6/Gdrive
After=plexdrive.service
[Service]
Type=simple
ExecStart=/usr/bin/rclone mount \
–config=/home/mosco/.config/rclone.conf \
–allow-other \
–cache-tmp-upload-path=/tmp/rclone/upload \
–cache-chunk-path=/tmp/rclone/chunks \
–cache-workers=8 \
–cache-writes \
–cache-dir=/tmp/rclone/vfs \
–cache-db-path=/tmp/rclone/db \
–no-modtime \
–drive-use-trash \
–stats=0 \
–checkers=16 \
–bwlimit=40M \
–dir-cache-time=60m \
–cache-info-age=60m gdrive:/ /mnt/79f72362-129f-42e4-ae4a-98159748c9c6/Gdrive
ExecStop=/bin/fusermount -u /mnt/79f72362-129f-42e4-ae4a-98159748c9c6/Gdrive
Restart=always
RestartSec=10
[Install]
WantedBy=default.target
Steve
14-Apr-2019 at 1:44 pmHi…
I’m just about to fire up rclone and use its mount function so came looking for insights. I wondered whether you made any progress?
Matt Penfold
16-Jun-2019 at 11:56 amI don’t know if you solved this, but I have one question for you.
Do you have Plex installed? If not, this service as written will never run as it will only run once the plexdrive.service has succesfully run.
H. L.
14-Jul-2019 at 11:16 pmCan this service be configured to mount only specific (multiple) directories from Google Drive (haven’t enough space on my laptop for everything)?
Kenny
25-Aug-2019 at 12:25 amI want to mount multiple rclone remotes that are defined in the rclone.conf. I’m assuming I could do this under the same service? Would it just be multiple [Service] sections, each specific to the mount? I also have some S3 stuff defined in rclone.conf and it would seem useful to mount those too.
John
17-Mar-2020 at 8:51 pmHi Kenny, did you figure this out? I want to mount multiple remotes also.
Amy
22-May-2020 at 4:27 pmI turned this into a templated user service, which I’ve uploaded to a github gist. I used a user service because I didn’t need it running while I wasn’t logged in.
https://gist.github.com/kabili207/2cd2d637e5c7617411a666d8d7e97101
Nick
19-Jun-2020 at 8:25 amThanks for this, it’s really easy to get working.
Nick
14-Jul-2020 at 9:17 amThank you. This helped me configure my VPS to access both pCloud and MEGA.
Can you please help me again? Is it possible to have two entries in rclone.service? I’d like to mount both pCloud and MEGA upon reboot.
Thanks.
Fabio
30-Aug-2021 at 10:27 pmThanks for sharing, this saved me some time!
Viktor
22-Jan-2022 at 8:08 amhow to create automount Google cloud on Android?
like rclone service or something… please help