Prevent writing in directory when Rclone mount is offline in Linux

Is there a way to disable writes to a directory until the RCLONE is properly mounted under Linux?
My program does not know or care if RCLONE is mounted and will just write into the directory which in this case is the local disc.

Now Rclone service is started errors because there is stuff in the said directory. The option allow non empty is a problem because of conflicting files i assume?

Proxmox server is coming up where directory /mnt/mrplex is entered as store. Proxmox likes to have its own file structure and happily writes it. A few seconds later systemd is starting mrplex.service and errors out because the directory is not empty. To proceed I remove all contents written by Proxmox in the /mnt/mrplex directory and restart the service. Everything is working until the rclone mount is offline upon which point i have todo the same again.

DEBIAN buster
systemd mounts an encrypted Gdrive Folder to directory /mnt/mrplex


this is the goto systemd script in the forum, from a fellow rcloner.

and this is a wiki

is that is not helpful, then post the systemd service file

hey thanks for your reply. my systemd looks very similar to the one you posted.
But i dont see how that is solving my problem :confused: dont get me wrong i am able to succesfully mount with rclone. But in the time that it is not mounted i want no other program to be able to write into the directory.

Description=RClone Service


ExecStart=/usr/bin/rclone mount mrplexcrypt: /mnt/mrplex
--dir-cache-time 1440m
--log-level INFO
--log-file /var/log/rclone.log
--poll-interval 15s
--umask 002
--user-agent itstheroot1
--vfs-cache-max-size 40G
--vfs-cache-mode writes
--vfs-cache-max-age 336h
--buffer-size 1024M
--tpslimit 10
--bwlimit 85M

ExecStop=/bin/fusermount -uz /mnt/mrplex


well, now that you posted the systemd file and tried the simple stuff.

we have linux/systemd experts and hopefully one will stop by soon.

If proxmox is started via a systemd unit (e.g. proxmox.service) then you could create a local config for it in /etc/system/proxmox.service.d/local.conf (make sure the ".d" name matches the service file name).

In it put the lines


Now proxmox shouldn't(!!) start until the mount has completed.

(At least that's the directory for CentOS 7; I assume Debian puts it in the same place!)

In my case (non-rclone related) I need xinetd to start after a specific NFS mount has completed so I have

% cat /etc/systemd/system/xinetd.service.d/local.conf 

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