Anyone have an idiots guide to writing a script to mount drives on boot?

I’m new to Linux (only installed it to use rclone), and finding myself a little lost with the scripting.

In windows I would make a batch file and drop it in startup.

Any basics?

Make new service file:
sudo nano /etc/systemd/system/rclone-mount.service

Description=rclone Amazon Cloud Drive FUSE mount

ExecStart= rclone mount --allow-non-empty --allow-other --max-read-ahead 200M --checkers 16 acd:/ /storage/.acd/ &
ExecStop= fusermount -uz /storage/.acd


Proceed with
sudo systemctl daemon-reload
sudo systemctl enable rclone-mount.service
systemctl start rclone-mount.service

Enable ( so rclone does not do mount before internet is present on boot )
systemctl enable NetworkManager-wait-online.service

And thats it, now when you reboot your drive will be automatically mounted.
You can check if rclone mounted the drive with
findmnt | grep rclone

p.s. Dont forget to change your names for remote and paths for mount.

Hello @filthyrich,

If you are lucky (or savvy, despite being a beginner) enough to be running a distro free of the systemd abomination, you can just edit /etc/rc.local and put your commands in there – they will be run automatically at every boot.

@Ajki: is the above crapload of commands really necessary to do this very simple thing with systemd? I have avoided this latest Poettering abomination so far on philosophical grounds, seems it is good policy to avoid it in practical grounds too…



I’m on Ubuntu 16.04. I think it has system…

@Ajki thanks!!!

If I have 2 drives to mount (movies are separate from tv), would I put 2 entries in the one script, or use two scripts?

Thanks again!

I’ll provide an alternate method that I use and seems to work well. Easy and works for any number of mounts.

Make some script somewhere:
nano /root/

/usr/sbin/rclone mount acdcrypt: /mnt/acd &

Make sure to mark it executable:
chmod +x /root/

As root, go into crontab:
crontab -e

Then add a line like:
@reboot sh /root/

Just make more scripts for more mounts and add them all to cron.

So like nano /root/

nano /root/

etc etc?

Yeah, make 2 scripts with different filename and different mount command inside and add both in separate lines to crontab.


Thank you guys!

Its been quite irritating remounting drives every time you reboot.

@durval I know what you mean but since systemd became linux standard and its here to stay, I use it for all my services.

@filthyrich i would not use two mounts for movies and series you should consider mounting a folder that have movies & series as subfolders. ( you can use rclone move if you dont have it set like that atm )

I have it set up with 4 buckets at the moment:

1 ) TV-Current
2) TV-Old
3) Movies-Current
4) Movies-Old

Im trying to avoid bans from scanning so much.

I’m not so sure about that: beyond the Devuan distro which I’m using right now, there are quite a few other options for those unwilling to go the systemd way… for starters, there are 81 of them listed just on this page right now:

Of course you are within your rights, so more power to you. My post was directed towards those that haven’t made a commitment yet and so can still be saved :wink:

Anyway, before this gets completely OT, I will refrain from posting further on this subject.