How Can I Force Unmount a Network Device on Mac?

7

2

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 :(

Jorge Israel Peña

Posted 2009-07-22T06:15:47.613

Reputation: 1 297

Answers

6

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.

Krysole

Posted 2009-07-22T06:15:47.613

Reputation: 76

14

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.

X-Istence

Posted 2009-07-22T06:15:47.613

Reputation: 489

Thanks for the high brow way of saying RTFM. I do know how to read manual pages, and typically an -f switch does mean force in pretty much any program. It just hung there, why? I have no idea, and I don't know what would qualify as 'funny going on', and therefore wouldn't know if anything like that would be going on. – Jorge Israel Peña – 2009-07-24T06:00:58.127

In fact, take a look at this. Someone else is having the exact same problem: http://superuser.com/questions/7996/os-x-keeps-losing-my-linux-samba-shares

– Jorge Israel Peña – 2009-07-24T06:03:04.690

This means that I have to manually unmount every share that's on my computer, but I wonder if this would fix the problem of when I click on the computer on the left pane in Finder, that's when it doesn't show the shares, if you get what I mean. It just keeps doing 'loading...'. I guess I'll try doing the disconnect from the network and wait, but that is extremely inconvenient. I'll try your method next time this happens, and if I can conclude that it works, I'll mark your answer as the correct one. Thanks! – Jorge Israel Peña – 2009-07-22T18:49:08.080

Yes, it is inconvenient, bugs have been filed with Apple and hopefully the matter is resolved in Snow Leopard. – X-Istence – 2009-07-23T04:24:54.520

Thanks again for the answer, but this isn't working. After I type the password in, it just hangs there. I even opened a new tab to do it again to a different volume, and it still doesn't work, it just hangs there after I input the command. I can't even ls the /Volumes directory after having tried the umount command. – Jorge Israel Peña – 2009-07-23T06:03:27.843

When you are in terminal, type man umount, then scroll down just a little bit you will see that the -f flag means forcibly unmount the file system.

If it is hanging, then you have sufficiently wedged the system in such a way that it is stuck there. Make sure you have the latest updates applied and that nothing funny is going on. umount -f has always worked perfectly for me. – X-Istence – 2009-07-23T08:48:03.873