Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
It is my believe this is more of a problem related to the Virtual software you are using and on what host you are using it. Can you add what virtualization software you are using? –  Luis Alvarado Jan 30 '13 at 15:36
    
Have you tried remounting the share? Like: umount <localsharepath>; mount -a. –  Pavel A Feb 1 '13 at 13:08
    
@PavelA Yes. It keeps saying "device is busy". –  Desmond Hume Feb 1 '13 at 14:11
    
(1) Is there some daemon software (dababase, etc) using files in the share? (2) Any error message from syslog? –  John Siu Feb 4 '13 at 1:02
    
@JohnSiu (1) No such daemon software whatsoever, nothing is locking any of the files in the share. (2) The only type of syslog entry I found is CIFS VFS: Server <remotehost> has not responded in 300 seconds. Reconnecting.... Anyone with access to a PC and with a trial version of VMware Workstation can easily replicate the problem. There is even no need to restart Windows in order to put it in a realistic context. Just restarting the Windows service called "Server", which is responsible for file sharing off Windows, while Ubuntu is paused will do the trick. –  Desmond Hume Feb 4 '13 at 9:51
add comment

3 Answers

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

share|improve this answer
    
After several tests, I have to say that the problem doesn't go away with autofs. Yes, it unmounts the share automatically after a specific time and if the Ubuntu machine gets paused or snapshot after the share gets auto-unmounted then it's all fine with the mount after the Ubuntu machine is resumed. But if Ubuntu is paused before the share gets auto-unmounted, it enters the very same collection of problems upon resuming. And if I set the number of auto-unmount seconds to some small value, say, 10 seconds, the Nautilus windows start to close spontaneously when browsing the shared files. –  Desmond Hume Feb 3 '13 at 19:19
add comment

1. unoubt -f

This is not a solution nor work around, but a procedure (an annoying one).

After VM resume, do not try to view the share drive with Nautilus or any program. Do not do ls to it. Any kind of access will trigger a 5min timeout and make the share busy. Just do the umount -f before anything.

    umount -f <localsharepath>

-f Force unmount (in case of an unreachable server).

As long as the share is not busy, this will unmount the share immediately without triggering the 5min cifs timeout.

This is definitely not ideal, but it does not require rebooting and the share can be mount again right away.

2. Change smbfs to cifs with defaults

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

It is official that smbfs is not being maintained anymore

smbfs has not been maintained in the last few years. Instead, development has been focused on another implementation of the CIFS protocol in the kernel. See the CIFS VFS for more information.

Base on comment of this blog (cannot find more authoritative reference)

stintel Friday 9 May 2008 : Another nice thing about CIFS is that it should survive a network outage or even a reboot of the system you are mounting a share from

3. Disable Opportunistic Locking and Lookup Caching (No effect in reducing the 5min connection timeout)

echo '0' > /proc/fs/cifs/OplockEnabled
echo '0' > /proc/fs/cifs/LookupCacheEnabled

4. Check Open File (Not applicable base on comment)

After Ubuntu VM resume, check if any user/process is using any file/directory in share folder

lsof | grep '<localsharepath>'

If any user/process is using files/directory in < localsharepath >, you will get device busy(This is regardless of how it is mount, local or remote).

share|improve this answer
    
Changed smbfs to cifs and rebooted the Ubuntu machine. The problems still persist. Retried multiple times, no improvement. –  Desmond Hume Feb 2 '13 at 10:04
    
Are you able to unmount the share with cifs? –  John Siu Feb 2 '13 at 18:14
    
Same thing as with smbfs, it says "device is busy". –  Desmond Hume Feb 2 '13 at 18:36
    
Is that mount point being share out by samba? Stop samba before unmount. –  John Siu Feb 2 '13 at 19:11
    
No, that mount point is only shared in, not out. The Ubuntu machine is never a file sharing server, only a client. –  Desmond Hume Feb 2 '13 at 19:23
show 9 more comments

If you share files between host and guest frequently, use FTP or SFTP, or even revision control software like Git. They are more stable and useful comparing to those mount-things.

If not, install VMTools on guest Ubuntu. Then you can drag and drop files between host and guest.

share|improve this answer
add comment

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.