Ubuntu – File sharing between Ubuntu VM and Windows 7

cifsfile-sharingmountsambavirtualization

I've got Ubuntu 12.04 running as Guest in a virtualized VMware Workstation 9 session on a Windows 7 host. The Windows machine shares a folder with the Ubuntu machine via CIFS and the Ubuntu machine mounts the shared folder automatically on startup thanks to this line in /etc/fstab file:

//<remotehost>/<sharename> <localsharepath> cifs soft,uid=1000,username=<remoteusername>,password=<remotepassword> 0 0

File sharing through the mount works fine until there is a need to resume the Ubuntu virtual machine after it was paused or to restore it from a snapshot. This typically happens after the Windows host machine was restarted or started after a nightly shutdown.

After Ubuntu is resumed, the folder that contains the mount of the shared folder does not list any items. The Nautilus window just hangs for a long time completely empty with "Loading…" in its bottom right corner, despite of the fact that there are lots of other folders and files in that folder to show.

Restarting the Ubuntu machine does help but it isn't practical: Ubuntu takes forever to shut down, it just hangs on one of those final command line screens desperately waiting for something (when the mount is accessible, there is no such problem). For now, the only option is to power off Ubuntu brutally and then power it back on in order to be able to access the mount, which, of course, is not practical either.

My guess is that when some CIFS/Samba communication parameters get changed (after Windows is restarted) the restored image of the Ubuntu virtual machine somehow fails to catch up.

Even with VMware Tools installed on the Ubuntu machine, the VMware's shared folder feature, which could serve as an alternative, doesn't work for Ubuntu 12 (and many other Linux distros). But even if it did, CIFS/Samba sharing would still be required for file sharing with other virtual machines.

Best Answer

I recommend to use autofs instead of a static fstab entry. See: https://help.ubuntu.com/community/Autofs

Related Question