You are not logged in.
Pages: 1
Topic closed
Hi !
Could be bash script added to systemd? Or should it be binary file?
I've created new service file and put him into /usr/lib/systemd/system. Also I've created /etc/systemd/system/Samba-umount.wants directory and put a simlink to '/usr/lib/systemd/system/Samba-umount.service' here.
The problem is that I can't start my Samba-umount. When tried to start it I got an error:
[root@arch archer]# systemctl start Samba-umount.service
Job for Samba-umount.service failed. See 'systemctl status Samba-umount.service' and 'journalctl -xn' for details.
[root@arch archer]#
Here journalctl -xn output:
[root@arch archer]# journalctl -xn
Apr 03 12:59:12 arch systemd[1]: Starting Umount samba shares...
-- Subject: Unit Samba-umount.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/7d4958e842da4a758f6c1cdc7b36dcc5
--
-- Unit Samba-umount.service has begun starting up.
Apr 03 12:59:12 arch systemd[964]: Failed at step EXEC spawning /usr/lib/systemd/scripts/umount.sh: Exec format error
-- Subject: Process /usr/lib/systemd/scripts/umount.sh could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/641257651c1b4ec9a8624d7a40a9e1e7
--
-- The process /usr/lib/systemd/scripts/umount.sh could not be executed and failed.
--
-- The error number returned while executing this process is 8.
Apr 03 12:59:12 arch systemd[1]: Samba-umount.service: main process exited, code=exited, status=203/EXEC
Apr 03 12:59:12 arch systemd[1]: Failed to start Umount samba shares.
-- Subject: Unit Samba-umount.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/be02cf6855d2428ba40df7e9d022f03d
--
-- Unit Samba-umount.service has failed.
--
-- The result is failed.
Apr 03 12:59:12 arch systemd[1]: Unit Samba-umount.service entered failed state
Why script could not be executed? Script works fine when I starting it manually.
Here my script (/usr/lib/systemd/scripts/umount.sh):
#!/bin/bash
umount -f -l /mnt/share
umount -f -l /mnt/torr
and service file (/usr/lib/systemd/system/Samba-umount.service):
[Unit]
Description=Umount samba shares
DefaultDependencies=no
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=/usr/lib/systemd/scripts/umount.sh
StandardOutput=syslog
[Install]
WantedBy=multi-user.target
What's wrong here?
Thanks in advance.
Last edited by chord (2013-04-03 22:01:36)
Offline
I've created new service file and put him into /usr/lib/systemd/system.
Custom service files belong in /etc/systemd/system.
Also I've created /etc/systemd/system/Samba-umount.wants directory and put a simlink to '/usr/lib/systemd/system/Samba-umount.service' here.
That doesn't make any sense.
From the journal it looks like it cannot execute your script (missing execute permissions?). systemctl status <unit> would have helped more.
It would help even more if you would explain what you are actually trying to do. Do you want to start this on shutdown, and if so, why? systemd should unmount all shares automatically.
Offline
Thank for reply!
Yes, I want to run this script on shutdown/reboot, because systemd can't umnount share and my box hangs on every reboot/shutdown. Just hangs in 'Umount /mnt/torr' stage. So I should reset my box by hardware reset button.
Script works just fine when I starting it by hand from terminal. Chmod +x was did also.
Here systemctl status output, nothing helpful found (at least for me):
[root@arch archer]# systemctl start Samba-umount.service
Job for Samba-umount.service failed. See 'systemctl status Samba-umount.service' and 'journalctl -xn' for details.
[root@arch archer]# systemctl status Samba-umount.service
Samba-umount.service - Umount samba shares
Loaded: loaded (/usr/lib/systemd/system/Samba-umount.service; enabled)
Active: failed (Result: exit-code) since Wed 2013-04-03 14:43:46 MSK; 3s ago
Process: 693 ExecStart=/usr/lib/systemd/scripts/umount.sh (code=exited, status=203/EXEC)
Apr 03 14:43:46 arch systemd[1]: Starting Umount samba shares...
Apr 03 14:43:46 arch systemd[1]: Samba-umount.service: main process exited, code=exited, status=203/EXEC
Apr 03 14:43:46 arch systemd[1]: Failed to start Umount samba shares.
Apr 03 14:43:46 arch systemd[1]: Unit Samba-umount.service entered failed state
About service's location: All manuals says that service should be located in /usr/li/systemd/system.
Offline
About service's location: All manuals says that service should be located in /usr/li/systemd/system.
What are "All manuals"? The systemd manuals certainly don't tell you to put custom service files into /usr/lib.
The only other explanation I have is that you have a typo somewhere and the path is incorrect. Also, why do you set StandardOutput=syslog?
Nevertheless you shouldn't even have to do this, how do you configure your network? If the network service properly orders itself before network.target, this should just work without any workarounds.
Also post your /etc/fstab.
Offline
OK, service moved to /etc/systemd/system/ directory and removed 'StandardOutput=syslog' option. Also I recreated link to service (under /etc/systemd/system/Samba-umount.wants/ directory). I still getting the same error:
[root@arch archer]# systemctl start Samba-umount.service
Job for Samba-umount.service failed. See 'systemctl status Samba-umount.service' and 'journalctl -xn' for details.
[root@arch archer]# systemctl status Samba-umount.service
Samba-umount.service - Umount samba shares
Loaded: loaded (/etc/systemd/system/Samba-umount.service; enabled)
Active: failed (Result: exit-code) since Wed 2013-04-03 15:56:16 MSK; 2s ago
Process: 680 ExecStart=/usr/lib/systemd/scripts/umount.sh (code=exited, status=203/EXEC)
Apr 03 15:56:16 arch systemd[1]: Starting Umount samba shares...
Apr 03 15:56:16 arch systemd[1]: Samba-umount.service: main process exited, code=exited, status=203/EXEC
Apr 03 15:56:16 arch systemd[1]: Failed to start Umount samba shares.
Apr 03 15:56:16 arch systemd[1]: Unit Samba-umount.service entered failed state
networking configured properly and works fine.
fstab:
/dev/sda1 / ext4 defaults 0 0
also I tried to put into fstab cifs mount point - the same error.
Currently I mounting shares by running script manually, not via fstab
Offline
I found solution:
#!/bin/bash
should be:
#!/bin/bash -
So now I can start service manually. If shares are mounted, service unmounting them (status=0/SUCCESS). If not, fails with message 'not mounted'. Manual start seems OK.
Now another trouble: service automatically starting on boot instead of shutdown, I thought 'Before=shutdown.target' should start it on shutdown, not on boot.
Why service starts on boot?
Any idea?
Offline
Solved by changing wantby parameter.
Thanks for help, guys!
Offline
Can you post the corrected file? I'm having this issue also, I'll add it to the wiki also.
Offline
Can you post the corrected file? I'm having this issue also, I'll add it to the wiki also.
unfortunately I removed this service. One thing I do remember: WantedBy=multi-user.target is wrong. As far as I remember I combined a three or four targets under WantedBy parameter. It was something like:
WantedBy=reboot.target shutdown.target halt.target
Offline
Also I recreated link to service (under /etc/systemd/system/Samba-umount.wants/ directory).
As 65kid said, that doesn't make any sense. That directory name doesn't match systemd's naming scheme, but if it did you would be adding a recursive dependency, because you're making the service depend on itself
As man page says, probably best to not manually create such symlinks unless you know what you're doing.
Offline
brando56894 wrote:Can you post the corrected file? I'm having this issue also, I'll add it to the wiki also.
unfortunately I removed this service. One thing I do remember: WantedBy=multi-user.target is wrong. As far as I remember I combined a three or four targets under WantedBy parameter. It was something like:
WantedBy=reboot.target shutdown.target halt.target
Thanks, I'll give it a go but it's not really a prime concern right now since I have two computers side by side (one is Windows 7 and the other is Arch Linux). I'm trying to get everything on the Linux box (W7 via virtualbox in seamless mode) and I can do what I need on the W7 box for the time being and just remove the share from fstab for the time being.
My main goal right now is to try to get dual NICs to route traffic to different subnets and it's proving to be a challenge for me and others. If anyone wants to take a look at it, here's the thread: https://bbs.archlinux.org/viewtopic.php … 1#p1262421
Last edited by brando56894 (2013-04-22 19:56:01)
Offline
As the person who solved it ran away without posting a correct solution, and that I had an issue with the same symptom, I'll share the solution.
If the script that you try to run:
- Works when you run it manually
- Has the right permission (755)
- Produce some "Exec format error" like that:
[...] systemd[5196]: battery-log@resume.service: Failed at step EXEC spawning /usr/local/bin/batt.sh: Exec format error
[...] systemd[1]: Starting After suspend (at resume), log the battery percentage...
[...] systemd[1]: battery-log@resume.service: Main process exited, code=exited, status=203/EXEC
[...] systemd[1]: Failed to start After suspend (at resume), log the battery percentage.
[...] systemd[1]: battery-log@resume.service: Unit entered failed state.
[...] systemd[1]: battery-log@resume.service: Failed with result 'exit-code'.
[...] systemd[1]: Starting After suspend (at resume), log the battery percentage...
It might be that the script has no shell set on the first line.
If your script has some comments before the sheebang(something like "#!/bin/sh") or lacks it entierly, it work perfectly fine when run by hand but produce the error pasted above.
Since the same same symptom can have very different causes, this only shows one of the ways this can happen.
For instance if bash cannot be executed, it might produce a similar error message (or not).
Denis.
Offline
Please don't revive long dead threads, this one hasn't had a response for 3.5 years....
Offline
Thanks for sharing your findings. As noted, this is an old topic, so I'm going to go ahead and close it now.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
Pages: 1
Topic closed