Networkmanager: dispatcher.d/pre-down.d is not executed on shutdown anymore

Others where having the same problem.

It looks like there was a change in Network Manager which no longer closes the connection on shutdown of Network Manager. I was able to add a systemd service to be executed when the network goes offline.

I created a file /etc/systemd/system/networkdown.service with the content:

[Unit]
Wants=network-online.target
After=network.target network-online.target

[Service]
Type=oneshot
ExecStart=/bin/true
ExecStop=/bin/umount /media/media
RemainAfterExit=yes

This seems to work.


This answer worked well for me. But... I had to add an [Install] block at the bottom of the above unit file.

[Unit]
Wants=network-online.target
After=network.target network-online.target

[Service]
Type=oneshot
ExecStart=/bin/true
ExecStop=/bin/umount /media/media
RemainAfterExit=yes

[Install]
WantedBy=suspend.target