Systemd mount fails at shutdown if drive has been accessed (I think) - samba server was responsible

I figured it out.

It was samba server that did not shut down correctly.

This is the situation:
I have a bunch of scb:s doing stuff on my network. I usually do a backup from one or 2 of them every day to this exact drive. I totally forgot that after the smb automount is activated by systemd on the smb:s, it stays open, and I have a retry timeout on those, so if I only reboot, manjaro is TOO DAMN FAST (god damn it manjaro) so the connection is recreated, so next reboot it would fail again.

If i establish connection from my scb by just ls:ing the mounted directory:

$ sudo lsof -e /run/user/1000/doc /media/fil-fitt
COMMAND    PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
smbd[192. 1142 bedna  cwd    DIR   0,59      206 4664 /media/fil-fitt/divprogs/Raspberry Pi

$ sudo fuser -uvm /media/fil-fitt
                     USER        PID ACCESS COMMAND
/media/fil-fitt:     root     kernel mount (root)/media/fil-fitt
                     bedna      1142 ..c.. (bedna)smbd[192.168.1.

And If I reboot or shutdown like this, I get the error.

Solution:
Created my own systemd service by copying existing in /usr/lib/systemd/system/smb.service (why is it called smb.service and not smbd.service btw???) and adding my mount unit to After and adding PartOf= containg the same mount:

$ sudo nano /etc/systemd/system/smb.service
-----------------------------
[Unit]
Description=Samba SMB Daemon
Documentation=man:smbd(8) man:samba(7) man:smb.conf(5)
Wants=network-online.target
After=network.target network-online.target nmb.service winbind.service media-fil\\x2dfitt.mount
PartOf=media-fil\\x2dfitt.mount

[Service]
Type=notify
PIDFile=/run/smbd.pid
LimitNOFILE=16384
EnvironmentFile=-/etc/conf.d/samba
ExecStart=/usr/bin/smbd --foreground --no-process-group $SMBDOPTIONS
ExecReload=/bin/kill -HUP $MAINPID
LimitCORE=infinity


[Install]
WantedBy=multi-user.target

sudo systemctl daemon-reload && sudo systemctl enable smb.service && sudo systemctl restart smb.service

Reboot and no errors. :slight_smile: