Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I added a Windows network drive (accessed using WiFi) in my fstab about a month ago:

//Server/Location/foo/bar /media/myNetworkDrive/ cifs auto,iocharset=utf8,uid=umang,credentials=/root/.cifscredentials,file_mode=0775,dir_mode=0775 0 0

and it works perfectly well, except it takes about a full minute for the system to shutdown. I have tried the solutions posted on the help wiki, the team wiki and on this blog. One of them worked for a few shutdowns but then the system went back to taking a minute to shutdown again.

EDIT: I'd like a working working around for this problem. Currently, I have a script that unmounts (password required for super-user priviledges) and then shuts down the computer, but I'd like to be able to shutdown the usual way and have it shutdown as fast.

share|improve this question
In my case, it is writing to the file system stalling that causes the problem. Check if the same is true in your case. – Reinier Post Nov 15 '15 at 17:55
I no longer have this set up, so I don't need to fix it (and cannot check if your solution works either). Thanks, anyway. – Umang Nov 16 '15 at 18:35

This is a well known bug :

It's one of those thankfully-rare, but nonetheless embarrassing, high impact, over-two-years-old bugs that negatively impact Ubuntu's sheen.

It should only affect WIFI connections, but I don't see any detail about that in your question. If you're experiencing this over a wired connection then something else is in play here.

Until Network Manager is fixed (it shuts down wifi connections too quickly - before any of the init scripts are triggered), the only feasible workaround I could find is to use AutoFS.

Paraphrased from

sudo apt-get install autofs

Create /etc/auto.cifs with these file contents :

# $Id$
# This file must be executable to work! chmod 755!
# Note: create a cred file for each windows/Samba-Server in your network
#       which requires password authentification.  The file should contain
#       exactly two lines:
#          username=user
#          password=*****
#       Please don't use blank spaces to separate the equal sign from the
#       user account name or password.
# Note: Use cifs instead of smbfs:
for P in /bin /sbin /usr/bin /usr/sbin
        if [ -x $P/smbclient ]
[ -x $SMBCLIENT ] || exit 1
if [ -e "$credfile" ]
        smbclientopts="-A "$credfile
$SMBCLIENT $smbclientopts -gL $key 2>/dev/null \
   | awk -v key="$key" -v opts="$mountopts" -F'|' -- '
        BEGIN   { ORS=""; first=1 }
    /Disk/  { if (first) { print opts; first=0 };
          gsub(/ /, "\\ ", $2);
          sub(/\$/, "\\$", $2);
          print " \\\n\t /" $2, "://" key "/" $2 }
        END     { if (!first) print "\n"; else exit 1 }

(edit the mountops line to reflect your real user name)

Make it exectuable with sudo chmod 755 /etc/auto.cifs

Then add this line to your /etc/auto.master, at the bottom :

/smb /etc/auto.cifs --timeout=60 --ghost

Finally, restart autofs with this line (or a reboot would work, of course) :

sudo service autofs restart

And you should then be able to open nautilus to /smb/server/share (or ls -l /smb/Server/Share)

Shutdown, suspend, hibernate should all be seamless.

If you use passwords to connect to your shares, you have to add another file in /etc/ for each server you connect to, with username and password specified. Do a "man autofs" for more detail on that, but here's the gist :

You need one credentials file for each password-protected share that you're connecting to. In your case, your server is called "Server", so create the relevant file with gksudo gedit /etc/auto.smb.Server. Then put this into that file :


(obviously editing the fields as required).

Then you'll need to make sure that this file is only readable by root with sudo chmod 600 /etc/auto.smb.Server.

Then restart autofs as above and try browsing /smb/Server - you should see a list of your shares.

If you connect using an IP address, you'll need to repeat this process for /etc/auto.smb. or whatever.

share|improve this answer
Thanks for your answer. I've updated my question and mentioned WiFi there. I will not and cannot access that network for a couple weeks. I shall try your solution and accept/comment on this answer when I can. – Umang Dec 14 '10 at 6:10
I wasn't able to do it exactly the way you suggested, but when I did something similar to it still takes quite a while to shutdown/restart. – Umang Jan 14 '11 at 4:15
That's disappointing. Autofs shouldn't trigger this bug at all. I have three samba shares specified, I use one of those every minute of every day, but my shutdown is near-instant (certainly never longer than 10 seconds). How's your suspend/resume (if you use it)? – Scaine Jan 14 '11 at 8:58
Suspend/resume is fine, but IIRC it was never troublesome when I had my share in fstab. BTW, I removed the share from my fstab when I started using autofs. I was supposed to do that, right? – Umang Jan 17 '11 at 16:15
Yep - autofs doesn't use /etc/fstab at all. Did you specify the timeout option? If you don't, I think you might still get the CIFS VFS errors. – Scaine Jan 17 '11 at 16:48

You should use the guide which shows you how to make an unmount shutdown script and make sure that it's still switch on. Upgrades or updates could theoretically have knocked it off it's perch. Check that your script is in /etc/rc0.d and that it's named S01smb_umount or similar so it runs as the first order of business.

Otherwise you may end up with it unmounting the samba drive normally (waiting, waiting) and then running your script. Which would do nothing.

share|improve this answer
I've got the following link: /etc/rc0.d/ -> ../init.d/ This does not help though. – Umang Nov 13 '10 at 6:26
Is K15 enough? Shouldn't it be S01? Have you tried? – Martin Owens -doctormo- Nov 13 '10 at 7:02
Sorry for my late reply, but I've got /etc/rc0.d/ -> /etc/init.d/ and /etc/rc6.d/ -> /etc/init.d/ and have removed the K15 ones. Still facing this problem, after three restarts. – Umang Nov 20 '10 at 17:22
Then I don't know, it needs attention from an upstart developer on the platform team, please report bug. – Martin Owens -doctormo- Nov 20 '10 at 21:23

I had the same problem with a Win2003 server samba share and following this guide fixed the problem.

share|improve this answer

Your Answer


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.