You are not logged in.
Hi guys!
I'm a very newbie in ARCH Linux world. ![]()
I want to build a media player. I managed to install the basic system. I also installed and configured the MPD, but when I restart the machine, the MPD will not start and the error is that it will not see the mounted NAS drives. If I restart it manually, that's all right.
Is there any way to have the MPD start only when the drives are already plugged in?
Thanks!
Last edited by ambrits (2020-08-16 12:34:18)
Offline
Is there any way to have the MPD start only when the drives are already plugged in?
Are you starting mpd as a systemd servide? There are ways to start a service only after a certain condition is met, see the wiki on systemd services.
If not with systemd, a simple delay will do, maybe in a shell script:
sleep 5;mpdor, more elegantly:
until mount|grep NAS (insert actual identifier here); do sleep 1; done; mpdOffline
ambrits wrote:Is there any way to have the MPD start only when the drives are already plugged in?
Are you starting mpd as a systemd servide?
Yes. This is the service file. I modified the bold part, but nothing changed.
[Unit]
Description=Music Player Daemon
Documentation=man:mpd(1) man:mpd.conf(5)
Requires=mnt-MPDDB.automount
After=mnt-MPDDB.automount network.target sound.target mnt-MPDDB.mount
[Service]
User=mpd
Type=notify
ExecStart=/usr/bin/mpd --no-daemon
#ExecStart=/usr/bin/mpdstart
# Enable this setting to ask systemd to watch over MPD, see
# systemd.service(5). This is disabled by default because it causes
# periodic wakeups which are unnecessary if MPD is not playing.
WatchdogSec=120
# allow MPD to use real-time priority 50
LimitRTPRIO=50
LimitRTTIME=infinity
# disallow writing to /usr, /bin, /sbin, ...
ProtectSystem=yes
# more paranoid security settings
NoNewPrivileges=yes
ProtectKernelTunables=yes
ProtectControlGroups=yes
ProtectKernelModules=yes
# AF_NETLINK is required by libsmbclient, or it will exit() .. *sigh*
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINK
RestrictNamespaces=yes
Offline
I'm not sure if "Requires" and "After" don't cancek each other out here; I believe "After" is the one that actually waits 'til the device is mounted. Better check the ArchWiki...
Have you checked whether these systemd units complete succesfully?
Why is there so much other stuff in "After"? Shouldn't 1 be enough?
Offline
I'm not sure if "Requires" and "After" don't cancek each other out here; I believe "After" is the one that actually waits 'til the device is mounted. Better check the ArchWiki...
Have you checked whether these systemd units complete succesfully?
Why is there so much other stuff in "After"? Shouldn't 1 be enough?
Since it didn't work in any way, I tried to make it work somehow. But nothing helped. After all, it improved by setting the IP address to static.
Offline
After all, it improved by setting the IP address to static.
Meaning the problem was in a completely different place than where we were looking.
You might want to elaborate how you mount the NAS with a static IP (frankly I have no idea how one would do it with a dynamic IP) and then mark this thread SOLVED by editing the first post.
Offline
ambrits wrote:After all, it improved by setting the IP address to static.
Meaning the problem was in a completely different place than where we were looking.
You might want to elaborate how you mount the NAS with a static IP (frankly I have no idea how one would do it with a dynamic IP) and then mark this thread SOLVED by editing the first post.
not the NAS, but ARCH Linux got a static IP address
Offline
not the NAS, but ARCH Linux got a static IP address
I think with the static IP the network just comes up faster (it does not need to wait to get an IP address from the DHCP server), and now it is fast enough to start before MPD. Still it is a race condition.
Systemd documentation suggests using network-online.target instead of network.target: https://www.freedesktop.org/wiki/Softwa … orkTarget/ - maybe this is what you need to do.
You can also try using autofs instead of the systemd mount.
Last edited by luscinius (2020-08-17 20:08:31)
Offline
ambrits wrote:not the NAS, but ARCH Linux got a static IP address
I think with the static IP the network just comes up faster (it does not need to wait to get an IP address from the DHCP server), and now it is fast enough to start before MPD. Still it is a race condition.
Systemd documentation suggests using network-online.target instead of network.target: https://www.freedesktop.org/wiki/Softwa … orkTarget/ - maybe this is what you need to do.
You can also try using autofs instead of the systemd mount.
Yes, I tried these too, but it didn't work. The error during MPD startup was that it could not find the attached folders. Although it was set, it did not wait for the attachment. It has been working since static IP was turned on.
Offline