AFP & SMB Remount Failures

I have a few scripts that mount afp and smb shares and copy files over. I usually leave these mounted as per the LAN Admin’s responsible for these shares.

From time to time, for whatever reason, the connection is closed, leaving the mount point in /volumes and no way to reconnect.

If I try manually, cmd-k, I get:

The Finder could not complete the operation because some data in “smb://blah blah blah” or “afp://” could not be read or written.

If I try to remove, rename, or look at the mount point funny in any way, I get a “Socket not connected” error.

The only fix is to reboot - and I simply refuse to add logic into my scripts to reboot the machine every time this happens.

Found nothing over at Apple, a few threads the usual fixit forums, but no answers.

eMac Running OS X 10.3.9
Remote Shares are Windows servers on our corporate network
I do not have this issue with any of my Panther or Tiger servers.

Does anyone have a solution for reconnecting without rebooting? Or, some insight into what is happening?

Thanks!

You might try turning off Built-in Ethernet 1 (en0) and turning it back on a few seconds later, or even changing your location setting away and back. I think that might force a “realignment”. You might even try renewing your DHCP lease if you have one. Anything to make TCP/IP set up its stack again.

BTW: I deleted the duplicate post.

Hi Adam, thanks for the swift response.

The station has a dedicated IP, but I like your other ideas.

Since I can’t simulate this situation, the next time it happens, I’ll try turning en0 off and back on.

After a quick search, I found out how to do that via command line. Here it is, for anyone that may need it:

do shell script "ifconfig en0 down" password "password" with administrator privileges
do shell script "ifconfig en0 up" password "password" with administrator privileges

I’ll post the results once I get a chance to check this out. Thanks again!

Model: PowerBook G4 17"
Browser: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.7) Gecko/20060911 Camino/1.0.3
Operating System: Mac OS X (10.3.9)

Well, it took some time, but it finally happened again. My eMac dropped an afp mount and refused to reconnect automatically.

So, I tried manually - cmd-k and got the same error I mentioned above.

To verify, I slid over to another eMac on the same network and was able to mount the same server no problem.

So, I was excited - I got to finally try Adam’s idea, and the code I posted above.

Unfortunately, it did not work. I tried it a bunch of different times, waiting in between “down” and “up” and even manually turned ethernet off and unplugged the connection. It just refuses to reconnect without a reboot, and that mount point refuses to be touched.

Back to square one.

How are you trying to remove the mount point?

Including, but not limited to:

Telling the Finder to eject the disk
rm’ing /volumes/sharename
unmount
Clicking the eject button (especially fun to watch the spinning beach ball)
Renaming the mount point
Scolding the mount point

The cmd line options all return “socket is not connected”.

Using the Finder results in the “some data at afp://… could not be written”

I have also had some weirdness before with mounting a volume with AppleScript. Sometimes it doesn’t show up and if I cmd-K it shows greyed out like it is already mounted.

I usually try mounting it again with Applescript (not manually with cmd-K) and it mounts (sometimes after more than one). Have you tried that yet? If it works you can add a couple copies of the mount command to make sure it gets it.

tell application "Finder"
	if not (exists "MyVolumeName") then
		try
			mount volume "smb://userName:password@address.com/MyVolumeName"
		end try
	end if
	if not (exists "MyVolumeName") then
		try
			mount volume "smb://userName:password@address.com/MyVolumeName"
		end try
	end if
	if not (exists "MyVolumeName") then
		try
			mount volume "smb://userName:password@address.com/MyVolumeName"
		end try
	end if
end tell

Model: G5 Tower (not Intel) - Script Editor ver 2.1.1
AppleScript: Tiger
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Hi Matt,

Thanks for the swift reply, but that is the exact code that is failing to re-mount. I am using applescript to mount already, this is an entirely automated station.

The problem is the connection is dropped and I am unable to work with the server in question and re-mount (via applescript or otherwise) fails because the mount point is still found in /volumes, like a pushy house guest refusing to leave.

Again, this never happens with any of my Mac servers - this same station is logged in to 3-4 shares at any given time - all flavors and only Windows servers drop me.

Other fun facts
The mount point is still located in /volumes but refuses to go anywhere

As long as the mount point remains - I am unable to log back on unless I reboot

I cannot reboot (actually, I don’t want this robot to be rebooting willy nilly)

The Finder alerts me to the disconnection (which is what baffles me - why wouldn’t the mount point be removed?)

silly question perhaps, but when trying a rm are you using a -f flag? when trying to rm or umount are you using sudo? have you checked during this time to see if any procces are hanging?

Not silly at all. I shouldn’t have left that for speculation.

Yes, I am using the proper rm flags as well as administrator privs.

I have yet to inspect the processes when that happens - I’d do it right now but I had to reboot to get the process flowing again.

And, since this doesn’t happen on a regular schedule, I’m not sure when I’ll be able to check that. I will the next time that happens though. Perhaps I’ll ping Apple support too since this is more of a networking issue. Just figured someone out here had encountered the same thing.

Once again, I’ve found myself in a situation nobody else in the world has apparently ever been in. Hey, it happens.
:smiley: