I had a thread about this earlier and the sollution I “found” was to create my own systemd service where I used PartOf to bind it to the systemd mount unit.
That no longer works and I finally figuered out exactly why it happens sometimes and sometimes not. Because of the order of how things are done at shutdown/reboot.
I have now removed the systemd unit and is relying on the default installed one at /usr/lib/systemd/system/smb.service
My samba server is only sharing things from one partition, and that partition is mounted with systemd.
So I sometimes see this in the shudown log.
$ sudo journalctl -b -1 --no-pager | grep -ie smbd -e fil-fitt
--------------- cut for unnecessary info ----------------
Dec 29 12:39:31 bednaManjaro systemd[1]: Unmounting File drive (fil-fitt)...
Dec 29 12:39:31 bednaManjaro smbd[1045]: [2023/12/29 12:39:31.631014, 0] ../../source3/smbd/smb2_service.c:117(chdir_current_service)
Dec 29 12:39:31 bednaManjaro smbd[1045]: chdir_current_service: vfs_ChDir(/media/fil-fitt/divprogs/Raspberry Pi) failed: No such file or directory. Current token: uid=1000, gid=1000, 10 groups: 1000 998 991 3 50 90 98 117 962 1001
--------------- cut for unnecessary info ----------------
Witch makes sense since the partition is already unmounted.
So my question is: How do I force smb.service to exit BEFORE the partition media-fil\\x2dfitt.mount gets umounted?
Note that when two units with an ordering dependency between them are shut down, the inverse of the start-up order is applied. i.e. if a unit is configured with After= on another unit, the former is stopped before the latter if both are shut down.
I HAD After=network.target network-online.target nmb.service winbind.service media-fil\\x2dfitt.mount in the smb.service I had active before so it is strange that it did not work. Maybe the PartOf made it wrong.
I opted to keep the default smb.service file and added: Before=smb.service to my mount unit instead and it now works as intended.
Thanks! <3