Want to Persist Mount Using `systemd` and Link Sibling Directories

tldr; THEY KEEP TELLING ME THAT THE PROBLEM IS WITH A CASE SENSITIVE WORD AND THAT IT IS CURRENTLY user INSTEAD OF MY (OR SOME) ACTUAL USERNAME VALUE THAT IT SHOULD BE. I CAN’T FIND WHERE THE PROBLEM IS.


I’m a disabled person with cognitive issues - I don’t talk like everyone else and it sometimes cost me. I’ve been trying to get this problem resolved but because of how I talk - or something - I’ve been unable to reach the resolution. I’m trying to persist a mount using systemd for rclone and I simply don’t have the skill level to connect the dots on my own.

I’m familiar on the command line and have run Ubuntu for something like 12 yrs now (I LOVE UBUNTU!). When I tried to solve this the last 3 days the other place people were pointing out an error message but I could not find out what exactly to DO in order to solve the problem and no one would address that part.

I would happily pay someone to solve my problem (like on upwork or something) but I am on a fixed income and I can barely pay my bills as it is. Please can someone explain what to do to fix this? I can’t find it

Please understand that a lot of code you see pasted here is not stuff I know or know how to do - I was told it over the last 3 days but never to the solution.

Please don’t discard me if I mistakenly add something that doesn’t belong - I’m trying to give enough info to show the current state and what I’m trying to do - I really need help to do this. I’m a not changing things while I wait so that the state remains the same when people are trying to help.

Context

I’m trying to mount a cloud storage named MEGA to my local system. When I first tired to use gnome + google drive I saw it was not sufficient for my use case so I tried to connect google drive (for 3 days) using the cloud console - which ultimately hit a dead end. I knew I wanted to use rclone (thats a hard yes) but when google wouldn’t play I went and got a different solution.

I signed up for MEGA - which is purportedly easy to set up with rclone. The setup with rclone went smoothly and easily (apparently); but, when I tried to set up a service with systemd to make the mount persist it fails. I tried several times (and did find one mistake in my service file that got corrected). I can’t find WHAT exactly to DO to fix the problem. I see the error message, I’ve had other point out the error message (and in the log file), but I don’t know why it is there - or what to do.

Goal

To make MEGA mount persist through reboots so that I can access and use it on my local machine through the file manager or command line. It is the entire MEGA file system (at its root) that I need to mount.

To be able to link, ln -s, sibling directories in the home directory (the mount directory is in my home directory) into the synced directory so that they can continue to live where they are whilst at the same time being a part of the sync directory and of the cloud storage itself (some directories I don’t want to move into the sync directory to do this).

Goals For Local Storage Mount

Expected Result

The file system mounts without error persisting through reboots and can be worked with on the command line or through the file manager.

I am able to work in a directory that is linked into the mounted / sync directory from within that directory and have changes reflected in the sync directory and at the remote.

The entire point of doing all of this was so I could link sibling directories into the mounted sync directory and work in those directories - directly - and locally.

Noteworthy (and you can verify using output pasted below)

  • Mount Directory Name: MEGA
  • Mount Directory Path: /home/jake/MEGA
  • Remote Name: MEGA:
  • Service File Name: rclone-mega-sync.service
  • Service File Path: /home/jake/.config/systemd/user/

Please Note: the value user in the service file path /home/jake/.config/systemd/user/ is actually a default directory (I had nothing to do with that).

What Has Been Done?

I’ve updated rclone to the latest version.

~$ rclone version
rclone v1.69.1
- os/version: ubuntu 24.04 (64 bit)
- os/kernel: 6.8.0-53-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.24.0
- go/linking: static
- go/tags: none

I’ve run rclone config and it (seemingly) went smoothly + tested that I can mount the file system. I WAS able to mount the file system manually but that is no longer the case for some reason.

These are the current results (manually mounting with either of these fails / no successful mount).

jake@nixbox:~$ rclone mount mega:/ ~/MEGA --allow-other --vfs-cache-mode writes -vv --log-file /tmp/rclone.log
jake@nixbox:~$ rclone mount MEGA:/ ~/MEGA --allow-other --vfs-cache-mode writes -vv --log-file /tmp/rclone.log
^Cjake@nixbox:~$
~$ rclone config redacted
[MEGA]
type = mega
user = XXX
pass = XXX
### Double check the config for sensitive info before posting publicly

There is a single file in my MEGA storage and I can see it in the web interface but not locally inside the ~/MEGA directory - I guess that means it isn’t mounting with either of those commands? The second one did not close (it just hung) so I though it was working but the contents were not there. The first one just gave a newline without any output.

The Service File I Have

Is there something in here I don’t seee? Some `user` instead of the actual value??

[Unit]
Description=Rclone Mount for Mega Sync Folder
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=jake
ExecStart=/usr/bin/rclone mount MEGA: /home/jake/MEGA \
   --allow-other \
   --vfs-cache-mode writes
ExecStop=/bin/fusermount -u /home/jake/MEGA
Restart=on-failure
RestartSec=10

[Install]
WantedBy=default.target

The Exact Commands I Ran Right After

 1985  nano ~/.config/systemd/user/rclone-mega-sync.service
 1986  systemctl --user stop rclone-mega-sync
 1987  systemctl --user daemon-reload
 1988  systemctl --user stop rclone-mega-sync
 1989  systemctl --user enable rclone-mega-sync
 1990  systemctl --user start rclone-mega-sync
 1991  systemctl --user status rclone-mega-sync
 1992  systemctl --user stop rclone-mega-sync
 1993  nano ~/.config/systemd/user/rclone-mega-sync.service
 1994  history

Outputs

Line 5: code=exited, status=216/GROUP - I don’t know why but I just want to fix it I don’t want to be an expert in linux or rclone to do it I just want to use it (please understand my sentiment).

~$ systemctl --user status rclone-mega-sync
● rclone-mega-sync.service - Rclone Mount for Mega Sync Folder
     Loaded: loaded (/home/jake/.config/systemd/user/rclone-mega-sync.service; enabled; preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Fri 2025-02-21 12:10:56 PST; 6s ago
    Process: 11571 ExecStart=/usr/bin/rclone mount MEGA: /home/jake/MEGA --allow-other --vfs-cache-mode writes (code=exited, status=216/GROUP)
   Main PID: 11571 (code=exited, status=216/GROUP)
        CPU: 0
rclone mount mega:/ ~/MEGA --allow-other --vfs-cache-mode writes -vv --log-file /tmp/rclone.log # Places some log contents into this file

Links I’ve Seen But Not See The Answer Now

*Can anyone please show me how to fix this?*

Wow, really nice, well-worded, very-detailed, complete post!

A few things off the top of my head as someone who does not use rclone (:warning:!)

Who’s “they?” Do you have a link to this conversation or can you quote what they specifically said?

Looking at the manpage, I see this syntax:

rclone mount remote:path /path/to/mountpoint [flags]

Based on that, I think you want to do:

rclone mount MEGA:MEGA /home/jake/MEGA --allow-other --vfs-cache-mode writes -vv --log-file /tmp/rclone.log

Reading the log file kind of hints at problems with syntax, too:

DEBUG : Creating backend with remote "mega:/"
CRITICAL: Failed to create file system for "mega:/": didn't find section in config file ("mega")

but you said about the remote:

I think calling your remote and directory and mount the same exact name as the actual backend creates a lot of confusion. I’m sure if they were all something other than a variation on a theme, it would be quite obvious where the problem lies.

I hope that helps.

1 Like

Thank you so very much - I expected to get kicked off of here like they did at the other place this morning. I can’t tell you how much it means to me to hear that. I’m sorry but the thread seems to be gone now. I didn’t talk right for them or something.

jake@nixbox:~$ rclone mount MEGA:MEGA /home/jake/MEGA --allow-other --vfs-cache-mode writes -vv --log-file /tmp/rclone.log 

Has an appearance of mounting but then looks like its really not…


That (above) is exactly what is confusing me. I don’t know where that is coming from, don’t see anything in the service file that would indicate that, and the command to try and manually mount fails in a weird way (weird to me anyhow).

Is the right thing to do to delete my rclone config then recerated it with a different case name - like mega instead of MEGA? Err… But I thought I was getting told there was a value user causing the issue (like a placeholder that didn’t get changed or something) :thinking:

I think it would be best here to ignore the service file for the time being. You said:

Since those commands don’t work by themselves, they’re not going to work in the service file. We need to figure out how to do this right. So I would work on refining that until you get it right. Then worry about the service file.

Looking carefully at the configuration instructions and paying particular attention to the lines that include something> or something: where something is some word, thus indicating a prompt for “something,” I see the user being asked for the following:

name> remote
Storage> mega
user> you@example.com
password:

The result produces this configuration:

- type: mega
- user: you@example.com
- pass: *** ENCRYPTED ***

Note four lines above but three lines below. I think that’s because it’s missing the stanza which is the name. So really, the whole config should look like:

[remote]
- type: mega
- user: you@example.com
- pass: *** ENCRYPTED ***

Now you said you had:

[MEGA]
type = mega
user = XXX
pass = XXX

So in this case, the name of your remote is indeed MEGA and it is of type mega.

Since you’re trying to mount the root folder of that remote, you might need to use something else than what I suggested above.

In fact, what you might want to do is this:

rclone mount MEGA:/ /home/jake/MEGA --allow-other --vfs-cache-mode writes -vv --log-file /tmp/rclone.log

Since your remote doesn’t include the folder MEGA, that is why you’re not seeing the file with my original suggestion. Think about this in a Linux way:

  • The root of your filesystem is /
  • A folder called foo in the root of your filesystem is /foo
  • A file called baz in the root of your filesystem is /baz
  • A file called bar in the aforementioned foo folder is /foo/bar

So your file is actually at the equivalent of /baz above. You want to mount /. My first suggestion (MEGA:MEGA) is trying to mount the /MEGA folder, which doesn’t exist.

Looking at your log, it seems there is one successful mount in it and it seems to be when you use MEGA:/:

DEBUG : rclone: Version "v1.69.1" starting with parameters ["rclone" "mount" "MEGA:/" "/home/jake/MEGA" "--allow-other" "--vfs-cache-mode" "writes" "-vv" "--log-file" "/tmp/rclone.log"]
DEBUG : Creating backend with remote "MEGA:/"
DEBUG : mega root '': Mounting on "/home/jake/MEGA"

If that works, replace the command used in your service file accordingly and you should be all set.

P.S. scp and sftp kind of work similarly. Sometimes you can refer to the root in other ways like remote: (which seems what you’re trying to do in your service file) or remote:. but I don’t think that works for rclone.

P.P.S. If you want to see your config file itself and edit it directly rather than through rclone, it appears to be at /home/jake/.config/rclone/rclone.conf. This is why you don’t need to specify the type of mount and just refer to it by name.

P.P.P.S. Finally to put your mind at ease, the reason why Failed to create file system for "mega:/": didn't find section in config file ("mega") is confusing is because it came up when you tried to use rclone mount mega:/ et al. There mega refers to the name of the remote. Yours is, as you said, MEGA. As you know, Linux is case sensitive, so those tow things are not the same. When it searches the config file, it can’t find it. This is why I was saying that calling the remote, the local mount folder, and (supposedly, although not actually) the remote folder MEGA which itself is a variation on the type mega is all very confusing. If you had named those three things all something different and not anything to do with mega, it would have been obvious.

Ok so

The command you gave does work - we have mount (and the real contents) - and The only diff is a single forward slash.

rclone mount MEGA:/ /home/jake/MEGA --allow-other --vfs-cache-mode writes -vv --log-file /tmp/rclone.log

but this one fails,

rclone mount MEGA:MEGA /home/jake/MEGA --allow-other --vfs-cache-mode writes -vv --log-file /tmp/rclone.log
^Cjake@nixbox:~$

Edited Service File But Still Fails…

Here is the edited version of the service file. Note the change on line 9 (addition of a single forward slash - see diff).

[Unit]
Description=Rclone Mount for Mega Sync Folder
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=jake
ExecStart=/usr/bin/rclone mount MEGA:/ /home/jake/MEGA \ # Change is here
   --allow-other \
   --vfs-cache-mode writes
ExecStop=/bin/fusermount -u /home/jake/MEGA
Restart=on-failure
RestartSec=10

[Install]
WantedBy=default.target

Then I ran these commands…

 2000  cd ~/.config/systemd/user/
 2001  ls -al
 2002  less rclone-mega-sync.service 
 2003  nano rclone-mega-sync.service 
 2004  history | grep systemctl
 2005  systemctl --user stop rclone-mega-sync
 2006  systemctl --user daemon-reload
 2007  systemctl --user stop rclone-mega-sync
 2008  systemctl --user disable rclone-mega-sync
 2009  systemctl --user enable rclone-mega-sync
 2010  systemctl --user start rclone-mega-sync
 2011  systemctl --user status rclone-mega-sync
 2012  less rclone-mega-sync.service 
 2013  history

And this was the result (notice line 5 in the output)…

~/.config/systemd/user$ systemctl --user status rclone-mega-sync
● rclone-mega-sync.service - Rclone Mount for Mega Sync Folder
     Loaded: loaded (/home/jake/.config/systemd/user/rclone-mega-sync.service; enabled; preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Fri 2025-02-21 17:38:43 PST; 7s ago
    Process: 25437 ExecStart=/usr/bin/rclone mount MEGA:/ /home/jake/MEGA --allow-other --vfs-cache-mode writes (code=exited, status=216/GROUP)
   Main PID: 25437 (code=exited, status=216/GROUP)
        CPU: 0

I would have thought that to access a folder MEGA on my mega remote it would be something more like…

rclone mount MEGA:/MEGA /home/jake/MEGA --allow-other --vfs-cache-mode writes -vv --log-file /tmp/rclone.log

not…

rclone mount MEGA: /home/jake/MEGA --allow-other --vfs-cache-mode writes -vv --log-file /tmp/rclone.log

Or a directory foo on the mega remote

I would have thought that to access a folder MEGA on my mega remote it would be something more like…

rclone mount MEGA:/foo /home/jake/MEGA --allow-other --vfs-cache-mode writes -vv --log-file /tmp/rclone.log

not…

rclone mount foo: /home/jake/MEGA --allow-other --vfs-cache-mode writes -vv --log-file /tmp/rclone.log

But I think maybe there is something going on I’m not aware of (like mega naming your root directory MEGA or some such thing. Idk.

This should be correct. You just don’t have a MEGA folder in your remote’s root, so that wouldn’t work currently.

That shouldn’t work from what I can tell because in that case the remote folder is unspecified. The remote folder is what comes after the colon after the name of your remote. You can see it’s null, so that’s why it should fail.

That should be correct, but again, your root doesn’t have that folder, so it wouldn’t work currently. It might “silently fail” as in the case with my original suggestion.

That shouldn’t work for two reasons:

  1. The remote name is “foo,” but yours is “MEGA”
  2. The remote folder is unspecified, as above.

Now with scp I can do something like:

scp remote:some-file .

Which will pull some-file from the folder that the SCP access begins (to . or the present working directory of my local system). This can vary depending on the setup. It’s most likely your remote home folder, but it’s rarely ever the root of that remote filesystem. Doing this would fail because that actually is pointing to the root of the filesystem:

scp remote:/some-file .

But you can see rclone is different in its syntax. A little confusing for sure.

1 Like

WAIT WAIT UPDATE…


The filesystem is in fact mounted correctly after using the edited service file…

[Unit]
Description=Rclone Mount for Mega Sync Folder
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=jake
ExecStart=/usr/bin/rclone mount MEGA:/ /home/jake/MEGA \
   --allow-other \
   --vfs-cache-mode writes
ExecStop=/bin/fusermount -u /home/jake/MEGA
Restart=on-failure
RestartSec=10

[Install]
WantedBy=default.targett

But I get the following output from systemctl --user status rclone-mega-sync - which seems to indicate and error (see line 5)…

~/.config/systemd/user$ systemctl --user status rclone-mega-sync
● rclone-mega-sync.service - Rclone Mount for Mega Sync Folder
     Loaded: loaded (/home/jake/.config/systemd/user/rclone-mega-sync.service; enabled; preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Fri 2025-02-21 17:38:43 PST; 7s ago
    Process: 25437 ExecStart=/usr/bin/rclone mount MEGA:/ /home/jake/MEGA --allow-other --vfs-cache-mode writes (code=exited, status=216/GROUP)
   Main PID: 25437 (code=exited, status=216/GROUP)
        CPU: 0

So is code=exited, status=216/GROUP not REALLY an error even though it says exited and status=216?


Got it!

I’m sorry bro we crossed lines will I was making an edit to the comment. It now has the result of a trial after editing the service file. The command in the service file is not formed the same way (or does not look like the one we used to manually mount). I took a guess that if the only difference between the manual one that worked and the manual one that didn’t was the one forward slash so I though that was the thing to change.

Tried an edited version (in my reply above) but it failed. I was a little bit guessing what to change you can see the diff here.

Am I supposed to literally put that exact command in my service file so that it looks like this?..

[Unit]
Description=Rclone Mount for Mega Sync Folder
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=jake
ExecStart=rclone mount MEGA:/ /home/jake/MEGA \
--allow-other \
--vfs-cache-mode writes

ExecStop=/bin/fusermount -u /home/jake/MEGA
Restart=on-failure
RestartSec=10

[Install]
WantedBy=default.target

Mount Does Not Persist Through Reboot

After rebooting I see that there is NO mount present in the file manager, the contents of the mount directory are empty, and this is the output of from systemctl --user status rclone-mega-sync. I think it might be identical to what it was before the reboot.

~$ systemctl --user status rclone-mega-sync
● rclone-mega-sync.service - Rclone Mount for Mega Sync Folder
     Loaded: loaded (/home/jake/.config/systemd/user/rclone-mega-sync.service; enabled; preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Fri 2025-02-21 18:12:19 PST; 7s ago
    Process: 6142 ExecStart=/usr/bin/rclone mount MEGA:/ /home/jake/MEGA --allow-other --vfs-cache-mode writes (code=exited, status=216/GROUP)
   Main PID: 6142 (code=exited, status=216/GROUP)
        CPU: 0

YAY!

Thank you wxl! :partying_face:

I just rebooted and guess what the first thing I saw was.

Let’s Check Out What Changed…

See the diff.

So the problem turned out to be some permissions thing where my user cannot be the one to run a service. Comment out the User= line in the service file and your off to the races! And I think the forward slash in front of the remote name for its root directory was important too. So I don’t know what user it normally runs under (maybe root or something unique like apache2 does) but it ain’t jake. I think that line can be safely removed and systemd will gracefully handle it and run the system under the correct user. I should have never had that line in there.

~$ systemctl --user status rclone-mega-sync
Warning: The unit file, source configuration file or drop-ins of rclone-mega-sync.service changed on disk. Run 'systemctl --user daemon-reload' to reload units.
● rclone-mega-sync.service - Rclone Mount for Mega Sync Folder
     Loaded: loaded (/home/jake/.config/systemd/user/rclone-mega-sync.service; enabled; preset: enabled)
     Active: active (running) since Fri 2025-02-21 18:22:06 PST; 36min ago
   Main PID: 2082 (rclone)
      Tasks: 14 (limit: 18812)
     Memory: 63.9M (peak: 72.8M)
        CPU: 1.100s
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/rclone-mega-sync.service
             └─2082 /usr/bin/rclone mount MEGA:/ /home/jake/MEGA --allow-other --vfs-cache-mode writes

Feb 21 18:22:06 nixbox systemd[1875]: Started rclone-mega-sync.service - Rclone Mount for Mega Sync Folder.

YEP! Just did it again and its still there!

1 Like

Glad we figured it out together!

1 Like

So I wanted to go a little further with it (linking sibling directories / syncing sibling directories) but I’m not sure if I should start a new thread for that?

I looked into it a little and it looks like you can use rclone for that too but it may not be the best way to do it (not very performant / drags the system)? I could be wrong but unison SEEMED like it might be real simple to use.

  • Use unison for Bidirectional Sync?
  • Use rclone with Cron Jobs or Systemd Timers?
  • Use lsyncd for Real-Time Sync?

I think I better start a new thread.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.