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.
This is a well known bug : https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/211631?comments=all
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 http://www.howtoforge.com/accessing_windows_or_samba_shares_using_autofs
Create /etc/auto.cifs with these file contents :
(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 :
Finally, restart autofs with this line (or a reboot would work, of course) :
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.192.168.1.10 or whatever.
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 namedS01smb_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.
I had the same problem with a Win2003 server samba share and following this guide fixed the problem.