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

**URL:** <https://forum.rclone.org/t/anyone-have-an-idiots-guide-to-writing-a-script-to-mount-drives-on-boot/842>\
**Category:** Help and Support\
**Created:** [January 23, 2017, 10:37pm UTC](https://forum.rclone.org/t/anyone-have-an-idiots-guide-to-writing-a-script-to-mount-drives-on-boot/842 "2017-01-23T22:37:37Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![filthyrich](https://forum.rclone.org/letter_avatar_proxy/v4/letter/f/e19adc/32.png) [@filthyrich](https://forum.rclone.org/u/filthyrich)\
**Post date:** [January 23, 2017, 10:37pm UTC](https://forum.rclone.org/t/anyone-have-an-idiots-guide-to-writing-a-script-to-mount-drives-on-boot/842/1 "2017-01-23T22:37:37Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Ajki](https://forum.rclone.org/user_avatar/forum.rclone.org/ajki/32/44_2.png) [@Ajki](https://forum.rclone.org/u/Ajki)\
**Post date:** [January 25, 2017, 8:24am UTC](https://forum.rclone.org/t/anyone-have-an-idiots-guide-to-writing-a-script-to-mount-drives-on-boot/842/2 "2017-01-25T08:24:26Z")

</div>

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

> [Unit]  
> Description=rclone Amazon Cloud Drive FUSE mount  
> Documentation=[Documentation](http://rclone.org/docs/)  
> After=network-online.target

> [Service]  
> Type=forking  
> User=plex  
> Group=plex  
> ExecStart= rclone mount --allow-non-empty --allow-other --max-read-ahead 200M --checkers 16 acd:/ /storage/.acd/ &  
> ExecStop= fusermount -uz /storage/.acd

> [Install]  
> Wants=network-online.target

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

Enable network-online.target ( 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.

---

<div class="post-metadata">

**Author:** ![durval](https://forum.rclone.org/user_avatar/forum.rclone.org/durval/32/33_2.png) [@durval](https://forum.rclone.org/u/durval)\
**Post date:** [January 25, 2017, 6:58pm UTC](https://forum.rclone.org/t/anyone-have-an-idiots-guide-to-writing-a-script-to-mount-drives-on-boot/842/3 "2017-01-25T18:58:55Z")

</div>

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…

## Cheers,

Durval.

---

<div class="post-metadata">

**Author:** ![filthyrich](https://forum.rclone.org/letter_avatar_proxy/v4/letter/f/e19adc/32.png) [@filthyrich](https://forum.rclone.org/u/filthyrich)\
**Post date:** [January 25, 2017, 8:30pm UTC](https://forum.rclone.org/t/anyone-have-an-idiots-guide-to-writing-a-script-to-mount-drives-on-boot/842/4 "2017-01-25T20:30:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![filthyrich](https://forum.rclone.org/letter_avatar_proxy/v4/letter/f/e19adc/32.png) [@filthyrich](https://forum.rclone.org/u/filthyrich)\
**Post date:** [January 25, 2017, 8:31pm UTC](https://forum.rclone.org/t/anyone-have-an-idiots-guide-to-writing-a-script-to-mount-drives-on-boot/842/5 "2017-01-25T20:31:37Z")

</div>

@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!

---

<div class="post-metadata">

**Author:** ![SirMaster](https://forum.rclone.org/letter_avatar_proxy/v4/letter/s/439d5e/32.png) [@SirMaster](https://forum.rclone.org/u/SirMaster)\
**Post date:** [January 26, 2017, 12:14am UTC](https://forum.rclone.org/t/anyone-have-an-idiots-guide-to-writing-a-script-to-mount-drives-on-boot/842/6 "2017-01-26T00:14:33Z")

</div>

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/mount.sh`

```
#!/bin/bash
/usr/sbin/rclone mount acdcrypt: /mnt/acd &

```

Make sure to mark it executable:  
`chmod +x /root/mount.sh`

As root, go into crontab:  
`crontab -e`

Then add a line like:  
`@reboot sh /root/mount.sh`

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

---

<div class="post-metadata">

**Author:** ![filthyrich](https://forum.rclone.org/letter_avatar_proxy/v4/letter/f/e19adc/32.png) [@filthyrich](https://forum.rclone.org/u/filthyrich)\
**Post date:** [January 26, 2017, 12:44am UTC](https://forum.rclone.org/t/anyone-have-an-idiots-guide-to-writing-a-script-to-mount-drives-on-boot/842/7 "2017-01-26T00:44:43Z")

</div>

So like nano /root/mount1.sh

nano /root/mount2.sh

etc etc?

---

<div class="post-metadata">

**Author:** ![SirMaster](https://forum.rclone.org/letter_avatar_proxy/v4/letter/s/439d5e/32.png) [@SirMaster](https://forum.rclone.org/u/SirMaster)\
**Post date:** [January 26, 2017, 12:55am UTC](https://forum.rclone.org/t/anyone-have-an-idiots-guide-to-writing-a-script-to-mount-drives-on-boot/842/8 "2017-01-26T00:55:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![filthyrich](https://forum.rclone.org/letter_avatar_proxy/v4/letter/f/e19adc/32.png) [@filthyrich](https://forum.rclone.org/u/filthyrich)\
**Post date:** [January 26, 2017, 12:57am UTC](https://forum.rclone.org/t/anyone-have-an-idiots-guide-to-writing-a-script-to-mount-drives-on-boot/842/9 "2017-01-26T00:57:07Z")

</div>

Nice!

Thank you guys!

Its been quite irritating remounting drives every time you reboot.

---

<div class="post-metadata">

**Author:** ![Ajki](https://forum.rclone.org/user_avatar/forum.rclone.org/ajki/32/44_2.png) [@Ajki](https://forum.rclone.org/u/Ajki)\
**Post date:** [January 26, 2017, 6:20am UTC](https://forum.rclone.org/t/anyone-have-an-idiots-guide-to-writing-a-script-to-mount-drives-on-boot/842/10 "2017-01-26T06:20:21Z")

</div>

@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 )

---

<div class="post-metadata">

**Author:** ![filthyrich](https://forum.rclone.org/letter_avatar_proxy/v4/letter/f/e19adc/32.png) [@filthyrich](https://forum.rclone.org/u/filthyrich)\
**Post date:** [January 26, 2017, 8:09am UTC](https://forum.rclone.org/t/anyone-have-an-idiots-guide-to-writing-a-script-to-mount-drives-on-boot/842/11 "2017-01-26T08:09:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![durval](https://forum.rclone.org/user_avatar/forum.rclone.org/durval/32/33_2.png) [@durval](https://forum.rclone.org/u/durval)\
**Post date:** [January 26, 2017, 9:07am UTC](https://forum.rclone.org/t/anyone-have-an-idiots-guide-to-writing-a-script-to-mount-drives-on-boot/842/12 "2017-01-26T09:07:18Z")

</div>

> [@Ajki](#):
>
> @durval I know what you mean but since systemd became linux standard and its here to stay,

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: [Without Systemd](http://without-systemd.org/wiki/index.php/Main_Page#GNU.2FLinux_distributions)

> [@Ajki](#):
>
> I use it for all my services.

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 😉

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

## Cheers,

Durval.

---

<div class="post-metadata">

**Author:** ![system](https://forum.rclone.org/uploads/default/original/2X/3/39ad3235f6ffec76ccd0c81616bd55697b4c300d.png) [@system](https://forum.rclone.org/u/system)\
**Post date:** [March 4, 2020, 12:35am UTC](https://forum.rclone.org/t/anyone-have-an-idiots-guide-to-writing-a-script-to-mount-drives-on-boot/842/13 "2020-03-04T00:35:43Z")

</div>

Closed on March 4, 2020, 12:35am UTC


