How Can I Force Unmount a Network Device on Mac?

49,781

Solution 1

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.

Solution 2

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.

Share:
49,781

Related videos on Youtube

bgee
Author by

bgee

I'm a practical developer who's happy to work at any level of the stack using a variety of different technologies and languages, always eager to learn the best practices of each to produce idiomatic and correct solutions.

Updated on September 17, 2022

Comments

  • bgee
    bgee almost 2 years

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

  • bgee
    bgee almost 15 years
    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!
  • X-Istence
    X-Istence almost 15 years
    Yes, it is inconvenient, bugs have been filed with Apple and hopefully the matter is resolved in Snow Leopard.
  • bgee
    bgee almost 15 years
    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.
  • X-Istence
    X-Istence almost 15 years
    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.
  • bgee
    bgee almost 15 years
    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.
  • bgee
    bgee almost 15 years
    In fact, take a look at this. Someone else is having the exact same problem: superuser.com/questions/7996/…