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

Edit

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
share|improve this question
    
Here someone said in 2008: "it is a very old and well known problem". It is 2017 and I still suffer from this issue. Did anyone find a working solution? – SkyRaT Apr 22 '17 at 12:56

Add the _netdev mount option to the remote filesystems in /etc/fstab. After a systemctl daemon-reload this should make your network mounts dependencies of the remote-fs.target; check it with systemctl list-dependencies remote-fs.target. Such filesystems are unmounted before network is brought down.

share|improve this answer
1  
I have this in my fstab already, see edit above. The drives also show up in the dependencies list. However if I shutdown without manually unmounting the drives, it takes ~2 mintues or so. If I unmount the drives manually before shutting down, the PC turns down nearly instantly.... – pandita Aug 30 '15 at 20:12
    
Interesting. You could try following the official debug instructions. – Ferenc Wágner Sep 14 '15 at 11:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.