Thanks! So I have figured out that "Device or resource busy" is because mpd is not giving up access to music on my msata drive.
I've got a
user systemd unit starting mpd on startup.
Code:
# $HOME/.config/systemd/user/default.target.wants/mpd.service
[Unit]
Description=Music Player Daemon
Documentation=man:mpd(1) man:mpd.conf(5)
After=network.target sound.target
[Service]
Type=notify
ExecStart=/usr/bin/mpd --systemd
LimitRTPRIO=40
LimitRTTIME=infinity
LimitMEMLOCK=64M
ProtectSystem=yes
NoNewPrivileges=yes
ProtectKernelTunables=yes
ProtectControlGroups=yes
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINK
RestrictNamespaces=yes
[Install]
WantedBy=default.target
So I somehow have to stop this service just before shutdown. I admit I am not an expert on systemd, I have tried this:
Code:
# $HOME/.config/systemd/user/stop_mpd.service[Unit]
Description=Stop mpd before shutdown
DefaultDependencies=no
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=systemctl --user stop mpd.service
TimeoutStartSec=0
[Install]
WantedBy=shutdown.target
But somehow it always fails:
Code:
Mar 20 21:31:25 thinkpad systemd[1]: Failed to start Stop mpd before shutdown.
░░ Subject: A start job for unit stop_mpd.service has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit stop_mpd.service has finished with a failure.
░░
░░ The job identifier is 3883 and the job result is failed.
and anyway stop_mpd.service runs only after the error "Failed to deactivate: Device or resource busy".
So how would you write a user systemd service which gets run just before shutdown and which stops mpd.service? Or can one even specify that within mpd.service and not bother with stop_mpd.service?
Thank you!