I have trouble with this as well. Same symptoms. Slow shutdown if network drives are mounted, but unavailable. In my case, it's a Samba share, and sometimes I turn off the computer hosting the Samba shares first.
I had a script that I set up with init.d to run when I shutdown the PC that provides the mounted network shares. It worked in 18.1, but for some reason it stopped in 18.2. I don't know enough to fix it.
I'll post the script and maybe someone smarter than me can fix it, or provide a better answer on how to accomplish the same task.
I put this in /etc/init.d with a filename UnmountSambaFromZBOXShutdown and made it executable.
Code: Select all
#!/bin/bash
### BEGIN INIT INFO
# Provides: UnmountSambaFromZBOXShutdown
# Required-Start: network
# Required-Stop:
# Should-Start:
# Default-Start: 5
# Default-Stop:
# Short-Description: Unmounts ZBOX samba share on shutdown
# Description: Checks if PC is accessible and unmounts the shared and laptop folder if it is
### END INIT INFO
#address of local IP - zbox
localaddressmain=192.168.1.73
sharedFolder=/media/zbox/Shared
laptopFolder=/media/zbox/laptop
ping -c 1 $localaddressmain 2>/dev/null 1>/dev/null
if [ "$?" = 0 ]
then
ssh -i /home/rick/.ssh/id_rsa rick@$localaddressmain sudo /bin/umount -f $sharedFolder
ssh -i /home/rick/.ssh/id_rsa rick@$localaddressmain sudo /bin/umount -f $laptopFolder
#else
# echo "host not found"
fi
Basically, what it does is when the computer hosting the network share shuts down, it pings my main PC, if it is found, it uses ssh to unmount the two shared folders.
To provide the permission to run umount without a password, in sudoers, I added: rick ALL = NOPASSWD: /sbin/mount.cifs, /bin/umount
Then I symlinked the script to the reboot and shutdown rc folders:
ln -s /etc/init.d/UnmountSambaFromZBOXShutdown /etc/rc0.d/K01UnmountSambaFromZBOXShutdown
ln -s /etc/init.d/UnmountSambaFromZBOXShutdown /etc/rc6.d/K01UnmountSambaFromZBOXShutdown
There's probably a much smarter way of doing this.