How Can I Force Unmount a Network Device on Mac?

Posted on

QUESTION :

Hey guys, I currently do CMD + K in Finder to connect to my Windows computer to be able to browse and use its network shares (i.e. smb://MyPC). It works fine, but sometimes when I click on it, maybe after having the MacBook go to sleep, it sits there loading and it stays that way, it doesn’t show the list of shares anymore. What I want to do is obviously unmount the ‘computer’ (I know I didn’t mount the computer, but how else can I say it) so that I can re-connect using the same method. I click on the eject button on the left, but then it says that:

A disk on “MyPC” is in use and could not be ejected.

Try quitting applications and try again.

The only way I have managed to get this to work again is by restarting my MacBook, but that should not be necessary. I already tried disconnecting my internet (Turning Airport Off, then back on) but it does not do anything. I’m wondering if perhaps there is a terminal command or something I can do to force this to be off.

And no, I am not running anything that is using anything from the network shares, unless for some reason, an application I was using earlier and quit did not ‘give the handle back’, and I doubt this is the case, but if it is, is there also a terminal command to see if any program is accessing/using any file/folder at a certain path?

Hope I can get this fixed, I would appreciate any help. Gotta go and restart my MacBook now ๐Ÿ™

ANSWER :

I’ve been having this problem for a while now also, but the force unmount turned out to work when applied to the other dead network mount (I had two network mounted that had wedged themselves somehow). I’m not sure if this is just due to a change in the OS at some point (I’m on 10.6.4 atm.), and the unmount command required the full path (as in sudo umount -f /Volumes/Share) because it could not resolve the path properly otherwise and would get stuck anyway.

Once the wedged mount was removed the finder restarted finally (I’d killed it without it restarting properly), and the other mount was removable at that point too (I had another terminal hung trying to unmount that drive so I’m not sure which happened first).

In my case I couldn’t reboot without the reboot cycle getting wedged also forcing me to use the powerbutton to turn the machine off.

This solution comes from a blog post, which also contained the steps needed to diagnose which volume to unmount first.

So the steps to solve the issue would
be:

  1. Run โ€œlsofโ€ in terminal
  2. See about what smb mounts it complaints
  3. sudo umount -f [any_failing_smb_mount]

Where lsof tells you which drives to try unmounting from the errors,

lsof: WARNING: can't stat() smbfs file system /Volumes/[smb2]
     Output information may be incomplete.
     assuming "dev=2d000005" from mount table

Hope this helps somewhat… even if it is somewhat after you ran into the problem.

Open up Terminal, then use mount to find the volume you want to force unmount, then use:

sudo umount -f /Volumes/{mount}

If you disconnect from the network, you have to wait a little bit while Finder sits around and then finally gets notified the connection was dropped, at which point it will ask you if you want to disconnect from the service.

Leave a Reply

Your email address will not be published.