I’m trying to mount my googledrive on my ubuntu server. Mounting in the console does work, but I want it to mount automaticly after a reboot. So I tried creating a rclonemount.service in /etc/systemd/system/ :
qp:~# systemctl status rclonemount
● rclonemount.service - rclonemount
Loaded: loaded (/etc/systemd/system/rclonemount.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2016-12-02 11:13:19 CET; 27s ago
Process: 1222 ExecStart=/usr/sbin/rclone mount gdriveencrypted: /media/gdrivemount/ --config /root/.rc
Main PID: 1222 (code=exited, status=1/FAILURE)
Dec 02 11:13:17 qp systemd[1]: Started rclonemount.
Dec 02 11:13:18 qp rclone[1222]: 2016/12/02 11:13:18 Couldn't find home directory or read HOME environment variable.
Dec 02 11:13:18 qp rclone[1222]: 2016/12/02 11:13:18 Defaulting to storing config in current directory.
Dec 02 11:13:18 qp rclone[1222]: 2016/12/02 11:13:18 Use -config flag to workaround.
Dec 02 11:13:18 qp rclone[1222]: 2016/12/02 11:13:18 Error was: user: Current not implemented on linux/amd64
Dec 02 11:13:19 qp rclone[1222]: 2016/12/02 11:13:19 Failed to create file system for "gdriveencrypted:": failed to make remote
Dec 02 11:13:19 qp systemd[1]: rclonemount.service: Main process exited, code=exited, status=1/FAILURE
Dec 02 11:13:19 qp systemd[1]: rclonemount.service: Unit entered failed state.
Dec 02 11:13:19 qp systemd[1]: rclonemount.service: Failed with result 'exit-code'.
I’m not that linux-savvy, so any help is appreciated.
You need to give it a path to a config file with --config /path/to/config.file
Not sure what user that you’ll be starting it as, maybe you should make an rclone user to do this or do it under your own user. You do that by putting User=XXX in the [Service] section I think.
● rclonemount.service - rclonemount
Loaded: loaded (/etc/systemd/system/rclonemount.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2016-12-02 15:49:02 CET; 2h 11min ago
Main PID: 1235 (code=exited, status=1/FAILURE)
Dec 02 15:49:01 qp systemd[1]: Started rclonemount.
Dec 02 15:49:02 qp rclone[1235]: 2016/12/02 15:49:02 Failed to create file system for "gdriveencrypted:": failed to make remote "remotegdrive:encrypted" to wrap: couldn't read info about Drive: Get https://www.googleapis.com/drive/v2/about?alt=json: Post https://accounts.google.com/o/oauth2/token: dial tcp: lookup accounts.google.com on [::1]:53: read udp [::1]:55031->[::1]:53: read: connection refused
Dec 02 15:49:02 qp systemd[1]: rclonemount.service: Main process exited, code=exited, status=1/FAILURE
Dec 02 15:49:02 qp systemd[1]: rclonemount.service: Unit entered failed state.
Dec 02 15:49:02 qp systemd[1]: rclonemount.service: Failed with result 'exit-code'.
If I execute the same command rclone mount gdriveencrypted: /media/gdrivemount/ --config /root/.rclone.conf --allow-other --no-modtime --dir-cache-time 60m in a terminal, the mount works, so the google token should work.
Yes... Interesting that it complained about it. Must be something to do with the environment of systemd.
That looks like it is having trouble speaking to the name resolver - the udp reads on port 53. Not sure why that should be. It is trying to connect to [::1]:53 which is localhost port 53 in IPv6 speak. Are you running a nameserver on localhost?
No, I didn’t get the automount with systemd working.
I have a pretty dumb workaround: I started a tmux session and mounted the drive there. It doesnt autostart after a boot but at least it stays mounted even when i close the ssh connection to the server.
If anyone has a better, working alternative, please comment
I was able to start it manually so my suspicion was that is was a timing issue. In your config there is a parameter TimeoutStartSec=10, but that isn’t doing what you expect it would do. Configures the time to wait for start-up. If a daemon service does not signal start-up completion within the configured time, the service will be considered failed and will be shut down again
So it is not waiting 10 seconds, but it is considered failed when not started within 10 seconds
With systemd-analyze plot > plot.svg (image file can be opened in browser) I analyzed the systemd startup order and noticed that my rclonemount.service was very short after the network. so I pushed it back by making it depended of multi-user.target.
That seemed to do the trick
Still a bit dirty though I think, maybe the rclone mount command could get a wait command-line parameter before the actual mount is created
This is the easiest way to daemonize a process from an SSH terminal and/or from a shell script:
( rclone mount --<options> <src> <dst> &)&
It will immediately echo back that the process has completed, but the backgrounded sub-shell will continue even when you log out. You can verify by logging out and then back in:
ps -e | grep rclone
The parent process with be pid 1, just as if you had started it from systemd.
If you want to start on boot, add this to crontab:
@reboot ( /path/to/rclone mount --<options> <src> <dst> &)&
I just use the @reboot in cron as doing the network.online never worked for me. I didn’t care to spend much time to troubleshoot it.
> felix@plex:~/scripts$ crontab -l | grep media_mount
> @reboot /home/felix/scripts/media_mount
> felix@plex:~/scripts$ cat media_mount
> # Mount GD Fuse
> #/usr/bin/google-drive-ocamlfuse /GD -o allow_other,auto_cache -headless -debug >> /home/felix/.gdfuse/default/mount.log 2>&1 &
> /usr/bin/google-drive-ocamlfuse /GD -o allow_other,auto_cache -verbose >> /home/felix/.gdfuse/default/mount.log 2>&1 &
> sleep 2
> # Mount the 3 Directories via rclone for the encrypt
> /usr/bin/rclone mount \
> --allow-other \
> --default-permissions \
> --uid 1000 \
> --gid 1000 \
> --umask 002 \
> --acd-templink-threshold 0 \
> --buffer-size 100M \
> --syslog \
> --stats 1m \
> -v \
> media: /media &
> # Wait a sec
> sleep 2
> /usr/bin/unionfs-fuse -o cow,allow_other,direct_io,auto_cache,sync_read /local/movies=RW:/media/Movies=RO /Movies
> /usr/bin/unionfs-fuse -o cow,allow_other,direct_io,auto_cache,sync_read /local/tv=RW:/media/TV=RO /TV
> # Prime the directories
> sleep 2
> cd /Movies
> ls -alR | wc -l
> cd /TV
> ls -alR | wc -l
I just a run a checker ever 5 minutes to validate nothing is bad. Little clunky but it does what it needs to do:
*/5 * * * * /home/felix/scripts/check_GD
felix@plex:~/scripts$ cat check_GD
#!/bin/bash
if grep -qs '/local' /proc/mounts; then
sleep 1
else
echo "It's not mounted." | mail -s "/local not mounted" me@gmail.com
exit 1
fi
if grep -qs '/GD' /proc/mounts; then
#echo "It's mounted."
FILE=/GD/.exists_and_writeable
if [[ -r $FILE && -w $FILE ]]
then
#All is good
#echo "File exists and is writeable"
exit
else
echo "/GD is not writeable" | mail -s "/GD not writeable" me@gmail.com
/home/felix/scripts/media_unmount
sleep 10
/home/felix/scripts/media_mount
fi
else
echo "It's not mounted." | mail -s "/GD not mounted" me@gmail.com
/home/felix/scripts/media_unmount
sleep 10
/home/felix/scripts/media_mount
fi
I also would recommend setting the --syslog parameter. On my raspberry pi fuse claims that in the /etc.fuse.conf the user_allow_other option needs to be enabled if you use --allow-other parameter. And maybe you get some more output there.
Also use the -vv parameter for debug logging.
If you use the -vv flag, rclone will produce Error, Notice, Info and Debug messages.
I have some problems too mounting the drive with rclone on startup. When I start the service manually sudo systemctl start mount-rclone.service the drive mounts successfully. But at startup I got errors in the systemlog. Guess it's because the wlan is not up at this time. Need to check in the next days.
I am trying to do the same and since you said it needs to wait for the wifi, I did it like @misteriks in this topic and wait for multi-user.target. However, this is my error message in the logs:
2017/09/09 09:31:08 Failed to create file system for "onedrive:/": failed to get root: Get https:// api.onedrive .com/v1.0/drive/root:/: Post https:// login.live. com/oauth20_token.srf: dial tcp: lookup login. live .com on [::1]:53: read udp [::1]:43541->[::1]:53: read: connection refused
(I had to separate the links in the log line above, new users are only allowed two links per post )