Mount how to start automatically at boot

What is the problem you are having with rclone?

I would like help on how to set my rclone so that whenever I restart my server it automatically mounts. I tried several tutorials without success.

Run the command 'rclone version' and share the full output of the command.
rclone v1.69.1

  • os/version: almalinux 8.10 (64 bit)
  • os/kernel: 4.18.0-553.33.1.el8_10.x86_64 (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.24.0
  • go/linking: static
  • go/tags: none

Which cloud storage system are you using? (eg Google Drive)
Mega

The command you were trying to run (eg rclone copy /tmp remote:tmp)
rclone mount mega:/BKP-Sites/educative-sites /bkp --cache-db-purge --vfs-cache-mode writes -P -v -l

Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.
[mega]
type = mega
user = XXX
pass = XXX

[root@vmi2492323 ~]# mount -a
mount: /etc/fstab: parse error at line 14 -- ignored
[root@vmi2492323 ~]#

nano /etc/fstab
UUID=82937238-3da4-4dda-9db2-29556dccce0a / xfs defaults 0 0
UUID=37e38df4-28dc-4d9c-acb5-1a2fd7e6130b /boot xfs defaults 0 0
UUID=3F31-DBA5 /boot/efi vfat defaults,uid=0,gid=0,umask=077,shortname=winnt 0 2
UUID=82937238-3da4-4dda-9db2-29556dccce0a mega: /BKP-Sites/andre-amcorp/ /bkp rw,noauto,nofail,x-systemd.automount,args2env,vfs_cache_mode=writes,config=/root/.config/rclone/rclone.conf,cache_dir=/var/cache/rclone,uid=$

Last line. What is this UUID?

If you find it too difficult to use fstab then try systemd. You can find tones of examples on Internet.

I find it very reliable to start it using systemd.

Here is a sample systemd unit file I use for one of my mounts:

# /etc/systemd/system/onedrive.service
[Unit]
Description=OneDrive
AssertPathIsDirectory=/home/username/OneDrive
After=network-online.target

[Service]
Type=simple
User=username
ExecStart=/usr/bin/rclone mount \
        --config=/home/username/.config/rclone/rclone.conf \
        --vfs-cache-mode full \
        --vfs-cache-max-age 4h \
        --vfs-cache-max-size 7G \
        --vfs-fast-fingerprint \
        --vfs-refresh \
        --onedrive-delta \
        --vfs-read-ahead 5G \
        --allow-other \
        --user-agent "ISV|rclone.org|rclone/v1.69.1" \
        --log-file=/var/log/rclone_onedrive.log \
        --log-level DEBUG \
        onedrive: /home/username/OneDrive
ExecStop=/bin/fusermount -u /home/username/OneDrive
Restart=always
RestartSec=10

[Install]
WantedBy=default.target

1 Like

You'd want to use notify over simple.

You'd want to change that to fusermount3 on most recent systems/builds too.

1 Like

Why, what's the difference?
(honest question, I don't know, I only know the bare minima to run the services I want to run and when they run successfully I tend not to touch them :sweat_smile:)

Notify let's systemd know when the mount has actually started up rather than simple, which reports 'ready' once the process is started. Just a little cleaner.

But can I use 'notify' in some sort of way to catch the mount not starting? Or how else does it help me?

At the moment I have a script running testing all the mounts regularly and notifying me for any mounts that have gone bad.

It's up to you and your use case.

I used systemd and cleanly shut down all my services and built depdencies with systemd to ensure things started in the proper order and shutdown if rclone had an issue.

If you already have something that works properly for your specific setup and meets your needs, use that. If you want to use systemd, you'd want to use notify over simple since that helps latter services start not when the process is started, but when the mount reports that it's ready.

I tended to use the easiest approach for things that worked for me. Rather than writing a script, I used system and how it works.

1 Like

Thank you, this is very helpful. I had some issues where an rclone mount didn't come on fast enough and the docker service relying on it went nuts (Immich), but I solved it with 'requires' etc in systemd unit files. However, I will not look into these types as well, sounds like 'notify' can make it even more robust.

is it rclone remote login?

Could you help me create a service based on the information I have? I'm using AlmaLinux 8 for my servers, but I don't have much knowledge about systemd. I'm just starting to learn and am a beginner at this.

I suggest you hit Google. There is plenty of information there including examples. Both about systemd itself and about using it to mount rclone remotes. Educate yourself, experiment and enjoy learning new things.

Example:

https://medium.com/@nunyezmiko/mounting-onedrive-in-linux-using-rclone-601752ae1e36

Then come back here if you have some specific questions related to rclone. Please note that this is not "how to use Linux" forum:)

No, the user field in systemd unit files sets the linux user that the service will run as.

[root@srvbr system]# cat /etc/os-release
NAME="CloudLinux"
VERSION="8.10 (Vladimir Aksyonov)"
ID="cloudlinux"
ID_LIKE="rhel fedora centos"
VERSION_ID="8.10"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CloudLinux 8.10 (Vladimir Aksyonov)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:cloudlinux:cloudlinux:8.10:GA:server"
HOME_URL="https://www.cloudlinux.com/"
BUG_REPORT_URL="https://www.cloudlinux.com/support"
VARIANT_ID="cloudlinux"

[root@srvbr system]# systemctl status rclone.service
● rclone.service - Mega
Loaded: loaded (/etc/systemd/system/rclone.service; enabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: exit-code) since Tue 2025-03-11 08:25:46 -03; 4s ago
Process: 186518 ExecStart=/usr/bin/rclone mount mega:/BKP-Sites/rockmedia /bkp (code=exited, status=1/FAILURE)
Main PID: 186518 (code=exited, status=1/FAILURE)

Mar 11 08:25:46 srvbr.rockmedia.com.br systemd[1]: rclone.service: Main process exited, code=exited, status=1/FAILURE
Mar 11 08:25:46 srvbr.rockmedia.com.br systemd[1]: rclone.service: Failed with result 'exit-code'.
[root@srvbr system]#

[Unit]
Description=Mega
AssertPathIsDirectory=/bkp
After=network-online.target

[Service]
Type=simple
ExecStart=/usr/bin/rclone mount mega:/BKP-Sites/rockmedia /bkp
--config=/root/.config/rclone/rclone.conf
--vfs-cache-mode full
--vfs-cache-max-age 4h
--vfs-cache-max-size 7G
--vfs-fast-fingerprint
--vfs-refresh
--onedrive-delta
--vfs-read-ahead 5G
--allow-other
--user-agent "ISV|rclone.org|rclone/v1.69.1"
--log-file=/var/log/rclone_onedrive.log
--log-level NOTICE
ExecStop=/bin/fusermount -u /bkp
Restart=always
RestartSec=10

[Install]
WantedBy=default.target

You need to set your loglevel to something like DEBUG and go check the logs to see exactly why the service is not starting.

Hello, yes now it is working correctly starting services

I have this error below, how can I solve it? Backups are not going to the remote, correct?

Mar 11 10:12:04 srvbr rclone[280119]: ERROR : IO error: failed to copy to temporary spool file: write /tmp/rclone-spool2581463334: no space left on device
Mar 11 10:13:35 srvbr rclone[280119]: ERROR : 2025-03-11/accounts/cafesendeski.tar.gz: WriteFileHandle.New Rcat failed: failed to copy to temporary spool file: write /tmp/rclone-spool1048567161: no space left on device
Mar 11 10:13:35 srvbr rclone[280119]: ERROR : 2025-03-11/accounts/cafesnn.tar.gz: WriteFileHandle.Write error: io: read/write on closed pipe
Mar 11 10:13:35 srvbr rclone[280119]: ERROR : IO error: io: read/write on closed pipe
Mar 11 10:13:36 srvbr rclone[280119]: ERROR : 2025-03-11/accounts/cafesnn.tar.gz: WriteFileHandle.Write: can't seek in file without --vfs-cache-mode >= writes
Mar 11 10:13:36 srvbr rclone[280119]: ERROR : 2025-03-11/accounts/cafesnn.tar.gz: WriteFileHandle.Flush error: failed to copy to temporary spool file: write /tmp/rclone-spool1048567161: no space left on device
Mar 11 10:13:36 srvbr rclone[280119]: ERROR : IO error: failed to copy to temporary spool file: write /tmp/rclone-spool1048567161: no space left on device
Mar 11 10:15:09 srvbr rclone[280119]: ERROR : 2025-03-11/accounts/cafesnn.tar.gz: WriteFileHandle.New Rcat failed: failed to copy to temporary spool file: write /tmp/rclone-spool3646905151: no space left on device
Mar 11 10:15:09 srvbr rclone[280119]: ERROR : 2025-03-11/accounts/cafesnn.tar.gz: WriteFileHandle.Write error: io: read/write on closed pipe
Mar 11 10:15:09 srvbr rclone[280119]: ERROR : IO error: io: read/write on closed pipe
Mar 11 10:15:10 srvbr rclone[280119]: ERROR : 2025-03-11/accounts/cafesnn.tar.gz: WriteFileHandle.Write: can't seek in file without --vfs-cache-mode >= writes
Mar 11 10:15:10 srvbr rclone[280119]: ERROR : 2025-03-11/accounts/cafesnn.tar.gz: WriteFileHandle.Flush error: failed to copy to temporary spool file: write /tmp/rclone-spool3646905151: no space left on device
Mar 11 10:15:10 srvbr rclone[280119]: ERROR : IO error: failed to copy to temporary spool file: write /tmp/rclone-spool3646905151: no space left on device

[root@srvbr accounts]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 2.9G 0 2.9G 0% /dev
tmpfs 2.9G 0 2.9G 0% /dev/shm
tmpfs 2.9G 290M 2.7G 10% /run
tmpfs 2.9G 0 2.9G 0% /sys/fs/cgroup
/dev/sda4 200G 153G 47G 77% /
none 2.9G 4.0K 2.9G 1% /var/lve/dbgovernor-shm
/dev/sda3 507M 463M 45M 92% /boot
/dev/sda2 200M 5.9M 194M 3% /boot/efi
/dev/loop0 3.9G 304K 3.7G 1% /tmp
tmpfs 594M 0 594M 0% /run/user/0
mega:BKP-Sites/rockmedia 2.0T 1.5T 577G 72% /bkp

fwiw, best to get the mount command working on the command line. once that is working, then try systemd.

and need to post a full debug log, not snippets

Solve this first :wink:

Also try to use the three accents ( this one x3 --> `, but without spaces between them) when pasting logs or code, it's much more readable, like so:

Code without accents

code with accents
1 Like

It is also possible to use ~. Might be easier with some foreign keyboard layouts.

~~~
test test
~~~

becomes:

test

Not formatted logs and commands' outputs are very difficult to read. I simply ignore them:) If somebody needs help then should show some effort to make others life easier.

I am absolutely with you on this one, but beginners may not know about all the tools that are available to make others' life easier or the norms around asking for help. Imagine if we have e.g. 13-year-olds here learning by themselves and taking their first steps. Something like the accents or ~ and its functionality in Discourse forums may be something they've never seen or heard before :wink: