My shutdown takes quite a long time (I'm on Debian 8.1) and I found out that it can be fixed by unmounting the network drive before shutting down the system. Apparently the network gets disconnected before all the drives are unmounted.
To do this automatically I tried to create a systemd service but it doesn't work, i.e. it doesn't seem to do the unmount in time and the shutdown process still takes quite long. My approach is inspired by the answers to this questions as well as some browsing of the systemd.service man pages...
[unit] description=Unmount network drives on shutdown Before=shutdown.target reboot.target halt.target network.target [Service] type=oneshot RemainAfterExit=true ExecStart=/bin/true ExecStop=/bin/sh umount /media/networkdrive1 /media/networkdrive2 [Install] WantedBy=multi-user.target
The network drives are mounted in /etc/fstab with the following lines:
//192.168.1.5/networkdrive1 /media/nw1 cifs _netdev,uid=myuser,credentials=/home/myuser/.credfile //192.168.1.5/networkdrive2 /media/nw2 cifs _netdev,uid=myuser,credentials=/home/myuser/.credfile