Raise the fooBar Rotating Header Image

Getting rid of a hanging network share in MacOS X

I originally posted this on the macrumors.com forum, so I’ll copy/paste the relevant parts over here.

ICEBreaker wrote:

Hi troubleshooters,

I wonder if you could help me troubleshoot a problem I have with my shared network volume. I have my iMac and PC connected to each other through the ethernet. The iMac is set to read/write the shared network volumes on my PC. The Finder is used to set up the SMB connection. Everything works fine. Mac applications are able to read and write files to the PC.

However, after a day or so (during which the PC has been kept on, while the Mac has slept) problems occur.

[...]
Attempts to read/write to the directory results in the following error message:

Sorry, the operation could not be completed because unexpected
error occurred.
(Error code - 1407)

Attempts to eject the shared volume results in the following error message:

A disk on 'pcxp' is in use and could not be ejected.
Try quitting applications and try again.

In terminal, I attempt to identify the open files:

lsof | egrep 'pcxp'

and get the following result:

lsof: WARNING: can't stat() smbfs file system /Volumes/Share
      Output information may be incomplete.
      assuming "dev=2f00000a" from mount table
Dock     96534 user [...] 896612 /Users/user/Shortcuts/pcxp

I try to kill the dock’s connection to the open file:

kill -9 96534

The dock is relaunched but the problem remains, this time with a new process number 97642.

When I try to restart my iMac, the desktop will close, and only my wallpaper remains. There, it will remain hung until I do a cold boot.

Can anyone figure out what is wrong. It’s pretty annoying to have to reboot my Mac daily.

Thanks a lot for your help!
JC

And here’s my reply:

LMAO, I was about to reply having the same issue. Then, while trying to reproduce the steps I took, I figured out the solution :-D

So I *had* exactly the same problem here between my Mac Pro and my XP PC. Same usage pattern (PC stays on, Mac sleeps every night). Fortunately, I only *had* this issue once in about two weeks, but it *was* annoying as hell!!

Some additional info I can provide on the issue’s behavior:

First off, I had 3 smb filesystems mounted when it happened. Let’s call them [smb1], [smb2] and [smb3] here. So I did the following:

  • At first,
    ls -al /Volumes

    -> yields only the local mounts, no smb mounts whatsoever.

  • Next, running
    sudo umount /Volumes/[smb1]

    -> HANGS, yes it blocks the terminal, tried to kill -9 the umount process without any success!!

  • At this point, even a simple
    ls -al /Volumes

    -> also HANGS the terminal.

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

I was right about to give up, post this answer and hard reset the machine again when I tried the following:

sudo umount -f /Volumes/[smb2]

All of a sudden, the finder flashed a window (had no chance to see what it was) and the previously hanging ls and umount processes were gone! The finder GUI listed the smb shares on the remote server again and everything seems fine again!

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]

Be aware though, that unmounting a filesystem using the force flag may produce unexpected results, but I guess it’s better than hard resetting the Mac and thus hitting the HDDs every day ;-)

Greetings,
Mike

One Comment

  1. Nojoy says:

    doesn’t work

Leave a Reply