SOLVED If any lost souls find themselves here in a similar situation let it be known that the file that worked for me was creating a file at ‘%h/.config/systemd/user/google-drive-ocamlfuse.service’ with the following content:
[Unit]
Description=FUSE filesystem over Google Drive
After=network.target
[Service]
ExecStart=google-drive-ocamlfuse %h/googledrive
ExecStop=fusemount -u %h/googledrive
Restart=always
RestartSec=300
Type=forking
[Install]
WantedBy=default.target
Howdy, I have very recently installed Opensuse Tumbleweed alongside Windows 10 (On a seperate drive) and am trying to get things setup to where I can fully transition to linux. One of the first things I have hit a wall on is getting a file to execute on boot using systemd.
I am trying to use this package to be able to access my google drive from Dolphin. And so far it works okay. Except that it doesn’t survive a reboot. I have to run the command:
google-drive-ocamlfuse ~/googledrive
after each reboot in order for the google drive directories to be accessible. So I googled how to make that happen automagically on boot and found this guide that helped me get a startup script going.
I created /usr/local/bin/ocamlfuseStartup.sh as a file that contains the command from before:
google-drive-ocamlfuse ~/googledrive
and verified that it works as intended when I enter ./ocamlfuseStartup.sh from that directory.
I then created another file at /usr/lib/systemd/system/startup.service that contains the following:
[Unit]
Description=Startup Script
[Service]
ExecStart=/bin/bash /usr/local/bin/ocamlfuseStartup.sh
[Install]
WantedBy=multi-user.target
I have no idea what the /bin/bash portion is for because I found it from a googling but without it I get the following error:
startup.service: Main process exited, code=exited, status=203/EXEC
However with it I get this error:
startup.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
which I take to mean that there is something wrong with my ocamlfuseStartup.sh file maybe? But since it works when I manually execute the file I’m kind of at a loss.
I found this thread where it seemed like someone else was having a similar issue but I didn’t really grok what they were talking about.
Any and all help is greatly appreciated!
The 203 error you got is because your script isnt a valid executable, it needs to have a shebang at the top, you can change it to something like this and set the executable bit with
chmod +x <file>
#!/usr/bin/env bash google-drive-ocamlfuse ~/googledrive
this tells it to run using bash as the interpreter.
Im not familliar with this google drive software, but im figuring that its exiting with an error code cuz its running as a system service, and $HOME probobly isnt set so
~
doesnt expand and the software gets an invalid path.But I recommend using a user service for this, it will run when you login, you should be able to copy the service file you already have into
~/.config/systemd/user/
and runsystemctl --user daemon-reload
andsystemctl --user enable startup.service --now
, this will enable and start the service in one go.I also recommend adding the following lines under
[Service]
Type=simple Restart=always RestartSec=60
idk if the software will exit if it loses network or wifi or anything, but this will have it automatically restart after 60 seconds, should it exit for any reason.
If you need it to run before login, it is possible to do with a system service, but it will need a bit more setup
Thanks a ton for your help! I’m not quite there but I feel like I’m learning more lol
With your help I have made the changes you listed as well as some other changes while trying to troubleshoot. In no particular order:
Moved ocamlfuseStartup.sh to ~/.local/bin/ocamlfuseStartup.sh because I now am more familiar with what an immutable distro is and does and also added the shebang. File now reads:
#!/usr/bin/env bash /usr/bin/google-drive-ocamlfuse ~/googledrive
Moved startup.service to ~/home/tyler/.config/systemd/user/startup.service, file now reads as follows:
[Unit] Description=Startup Script [Service] Type=simple Restart=always RestartSec=60 ExecStart=/bin/bash ~/.local/bin/ocamlfuseStartup.sh [Install] WantedBy=default.target
I am now getting (code=exited, status=127) when I run “systemctl --user status startup.service --now.” Which I have googled and determined that it is now having difficulty finding the program or one of the dependencies according to the bash man page. I attempted to troubleshoot this error by adding the full location of the program /usr/bin/google-drive-ocamlfuse to the ocamlfuseStartup.sh file. I’m unsure how to proceed from here though. Once again, super appreciative of your help. I’m going to bed now though…
I dont think systemd will expand the
~
, try replacing theExecStart=/bin/bash ~/.local/bin/ocamlfuseStartup.sh
line withExecStart=/bin/bash %h/.local/bin/ocamlfuseStartup.sh
, this will expand to your home directory, if its still giving a not found error, try runningwhich google-drive-ocamlfuse
in a terminal and make sure the path is correctI really appreciate your help with this. With your changes we have even acheived some partial success!
I did verify the package location with which google-drive-ocamlfuse, and replaced the ~ with %h.
The current configuration for ocamlfuseStartup.sh is:
#!/usr/bin/env bash /usr/bin/google-drive-ocamlfuse /home/tyler/googledrive
startup.service is now:
spoiler
[Unit] Description=Startup Script [Service] Type=simple Restart=always RestartSec=60 ExecStart=/bin/bash %h/.local/bin/ocamlfuseStartup.sh [Install] WantedBy=default.target
This current configuration leads to 0=SUCCESS, and boy howdy was I ELATED! Until… I realized that it didn’t actually do the thing… The directory %h/googledrive remains empty unless I manually run the command “google-drive-ocamlfuse ~/googledrive” as before.
Interestingly enough, status shows all good in the hood as far as I can tell:
spoiler
~> systemctl --user status startup.service --now ● startup.service - Startup Script Loaded: loaded (/home/tyler/.config/systemd/user/startup.service; enabled; preset: disabled) Active: activating (auto-restart) since Sat 2025-03-29 15:37:04 CDT; 58s ago Invocation: 96b64438a1be4e36a12018e86418d8c6 Process: 3822 ExecStart=/bin/bash /home/tyler/.local/bin/ocamlfuseStartup.sh (code=exited, status=0/SUCCESS) Main PID: 3822 (code=exited, status=0/SUCCESS) CPU: 49ms
journalctl also shows no whammies as far as I can tell:
spoiler
~> journalctl --user -xeu google-drive-ocamlfuse.service Mar 29 15:33:54 DESKTOP-MDJUBMM.attlocal.net systemd[1716]: Started FUSE filesystem over Google Drive. ░░ Subject: A start job for unit UNIT has finished successfully ░░ Defined-By: systemd ░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel ░░ ░░ A start job for unit UNIT has finished successfully. ░░ ░░ The job identifier is 704. Mar 29 15:38:56 DESKTOP-MDJUBMM.attlocal.net systemd[1716]: google-drive-ocamlfuse.service: Scheduled restart job, restart counter is at 2. ░░ Subject: Automatic restarting of a unit has been scheduled ░░ Defined-By: systemd ░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel ░░ ░░ Automatic restarting of the unit UNIT has been scheduled, as the result for ░░ the configured Restart= setting for the unit. Mar 29 15:38:56 DESKTOP-MDJUBMM.attlocal.net systemd[1716]: Started FUSE filesystem over Google Drive. ░░ Subject: A start job for unit UNIT has finished successfully ░░ Defined-By: systemd ░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel ░░ ░░ A start job for unit UNIT has finished successfully. ░░ ░░ The job identifier is 806. lines 16-38/38 (END)
So I am once again stumped. I feel like it’s so close.
However, with resources from others in this thread I have begun a war on two fronts. Introducing our newest contender ~/.config/systemd/user/google-drive-ocamlfuse.service Which as far as I can tell is another way of skinning this cat that doesn’t involve a seperate .sh file to be called. Seems cleaner than the angle I had started working from, but what do I know. Special thanks to Oscar with his github link to documentation and after some iterative monkeying google-drive-ocamlfuse.service looks like so:
spoiler
[Unit] Description=FUSE filesystem over Google Drive After=network.target [Service] ExecStart=google-drive-ocamlfuse /home/tyler/googledrive Restart=always RestartSec=300 Type=simple [Install] WantedBy=default.target
And again 0=SUCCESS and premature elation, but alas no joy. Remarkably similar status and journalctl entries, so I remain stumped. Or possibly double stumped…
spoiler
~> systemctl --user status google-drive-ocamlfuse.service --now ● google-drive-ocamlfuse.service - FUSE filesystem over Google Drive Loaded: loaded (/home/tyler/.config/systemd/user/google-drive-ocamlfuse.service; enabled; preset: disabled) Active: activating (auto-restart) since Sat 2025-03-29 15:49:00 CDT; 1min 5s ago Invocation: 813f1d3ce9fd4c21b409074a9fca7776 Process: 4271 ExecStart=google-drive-ocamlfuse /home/tyler/googledrive (code=exited, status=0/SUCCESS) Main PID: 4271 (code=exited, status=0/SUCCESS) CPU: 42ms
~> journalctl --user -xeu google-drive-ocamlfuse.service Mar 29 15:43:57 DESKTOP-MDJUBMM.attlocal.net systemd[1716]: Started FUSE filesystem over Google Drive. ░░ Subject: A start job for unit UNIT has finished successfully ░░ Defined-By: systemd ░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel ░░ ░░ A start job for unit UNIT has finished successfully. ░░ ░░ The job identifier is 908. Mar 29 15:48:58 DESKTOP-MDJUBMM.attlocal.net systemd[1716]: google-drive-ocamlfuse.service: Scheduled restart job, restart counter is at> ░░ Subject: Automatic restarting of a unit has been scheduled ░░ Defined-By: systemd ░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel ░░ ░░ Automatic restarting of the unit UNIT has been scheduled, as the result for ░░ the configured Restart= setting for the unit. Mar 29 15:48:58 DESKTOP-MDJUBMM.attlocal.net systemd[1716]: Started FUSE filesystem over Google Drive. ░░ Subject: A start job for unit UNIT has finished successfully ░░ Defined-By: systemd ░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel ░░ ░░ A start job for unit UNIT has finished successfully. ░░ ░░ The job identifier is 1031. lines 46-68/68 (END)
I have attempted to run these competing services seperately as well as in tandem with the same lack of results. I feel that if I can’t get it licked soon I will kick systemd to the curb and attempt another method outlined in the github link provided by Oscar. Most likely the fstab method that he mentioned because it sounds violent and that’s the vibe at the moment lol. Once again thank you for any and all assistance.
It looks like its creating a new process and going in the background and systemd cant track it anymore, so it thinks that its exited and tries restarting. I took a link Oscar sent, and I saw that there is a systemd service and the
Type
is set toforking
, I think this could solve the problem, they also have anExecStop
line, id set it toExecStop=fusermount -u %h/googledrive
so it will unmount properly whenever you manually stop the service. So try settingType=forking
, and adding theExecStop
line, hopefully this will stop systemd from restarting it when it hasnt actually exitedHOLY SHIT WE DID IT!!! I have now rebooted several times and the changes you recommended have made it work automagically! I’m so relieved! I can’t thank you enough, and I definitely owe you a beer.
They could use loginctl enable-persist if they want a user service to run at boot. I use it for my home nas server, just to make it slightly easier to manage my non-root services.
Thanks for your input, I’ll look into this.