Nezil

Lion and SMB Shares, a Fix!

Recommended Posts

New Method Posted Further Down the Thread; This First Post is Missing One Important Part

 

I'm posting a new thread here because it probably relates to all Lion users, but just to be clear, I'm using 5.0beta10.

 

The Issue:

Several people have noticed that it's not possible to use the SMB server shortcut in the Finder Sidebar in OS X Lion. It's still possible to connect by using Go -> Connect to Server, or by typing Cmd+K and the inputting your server's address, but this isn't ideal, and you're left with a pretty useless icon in your sidebar.

 

The Diagnosis:

I've been able to track the problem down to the fact that Avahi (The bonjour service on unRAID) is advertising the SMB server as running on port 139. There's nothing wrong with this, and unRAID's SMB server is indeed running on port 139, but Lion seems to want believe that the server is actually running on port 445.

 

From some reading on the internet, it seems that port 139 was the original port used by Microsoft in the days of Windows NT for file sharing, when NetBIOS over TCP/IP was also being used. Newer versions of Windows (2000 onwards) apparently use port 445 instead, though all operating systems will fall back to 139 if 445 doesn't work.

 

The Solution:

Avahi uses XML files stored in

/etc/avahi/services

to know what to advertise, a line in the

smb.service

file lists the port number as 139. If this is changed to 445, even though the service isn't, Lion will connect perfectly.

 

My smb.service file now looks like this:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<service-group>
   <name replace-wildcards="yes">%h-SMB</name>
   <service>
       <type>_smb._tcp</type>
<port>445</port>
   </service>
   <service>
        <type>_device-info._tcp</type>
        <port>0</port>
        <txt-record>model=Xserve</txt-record>
   </service>
</service-group>

 

Surviving Reboots:

You can make the changes to this file each time you boot up, or you could copy it first to somewhere on your flash disk, make the changes there, and then add a line to your go script, to copy the file back to the original location each time you boot.

 

The Caveat:

This solution seems to work fine for me, but as with anything with a new OS like Lion, Apple may change something in the next release that breaks this.

 

-- Edit: This change does not affect a Snow Leopard machine's ability to connect to the share, and shouldn't affect Windows either, as they don't use Bonjour by default.

 

Good luck!

Share this post


Link to post
Share on other sites

Do you need to restart AVAHI after making this change? I just updated the file, and I still can't connect to my "-SMB" share.

 

Share this post


Link to post
Share on other sites

Do you need to restart AVAHI after making this change? I just updated the file, and I still can't connect to my "-SMB" share.

 

Exactly the same problem here. Changed the port no to 445 in smb.service, copied it to /boot/config/ and added the following command to go script (cp /boot/config/smb.service /etc/avahi/services/smb.service), rebooted, to no avail. I cannot connect via the sidebar, "Connect to server" is the only way at the moment.

 

This is definitely an unRaid problem, since I have another Buffalo router serving a SMB service and I can connect to it via sidebar using Lion as earlier.

Share this post


Link to post
Share on other sites

I think you would need to do something like this in your go script.

 


# Set Avahi to only advertise SMB with correct hostname and Lion compatibility
avahi-daemon -k
rm /etc/avahi/services/*
cp /boot/addons/smb.service /etc/avahi/services/
avahi-daemon -D

 

My smb.service looks like so

 

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<service-group>
   <name replace-wildcards="yes">%h</name>
   <service>
       <type>_smb._tcp</type>
<port>445</port>
   </service>
   <service>
        <type>_device-info._tcp</type>
        <port>0</port>
        <txt-record>model=Xserve</txt-record>
   </service>
</service-group>

Share this post


Link to post
Share on other sites

I could use both AFP and SMB at the same time ONLY by doing the following:

Remove the "smb.service" file using the go script and reboot. You will see only AFP service in the sidebar and connect to it as usual. Then use "Command+K" to connect to any SMB share in unRaid, after which you will see the unRaid with its IP number in the sidebar with an eject sign beside it. Thereafter all your shares will be available as usual. I could not make any other suggested options work. 

Share this post


Link to post
Share on other sites

Hmm.... looks like many of you are still having issues.

 

I'll do some more digging, maybe my suggestion didn't fix it after all! Apologies if so.

Share this post


Link to post
Share on other sites

OK, apologies for missing something in my first post.

 

I've done a bit more digging, and it seems that when I fixed this myself the first time, a change I'd made to the

/etc/samba/smb.conf

file was persisting, and clouding my judgement.

 

It seems that the problem stems from the following facts

 

  • OS X Lion does indeed expect SMB shares to be on port 445.
  • The 'Connect to server' dialog will try both ports, resulting in a connection
  • Bonjour advertised services that advertise SMB on port 139 just won't connect (maybe because Lion believes that this is a legacy connection port) even if the service is in fact running on that port

 

To fix the problem, the SMB service must be:

 

  • Identified in Bonjour as being on port 445
  • Actually running on port 445 & 139 (Which is the default for Samba, but not default for unRAID - Not sure why?)

 

I have fixed this by editing the

/etc/avahi/services/smb.service

file as follows:

 

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<service-group>
   <name replace-wildcards="yes">%h-SMB</name>
   <service>
       <type>_smb._tcp</type>
       <port>445</port>
   </service>
   <service>
        <type>_device-info._tcp</type>
        <port>0</port>
        <txt-record>model=Xserve</txt-record>
   </service>
</service-group>

 

And the

/etc/samba/smb.conf

file like this:

 

[global]
# configurable identification
include = /etc/samba/smb-names.conf

# log stuff only to syslog
log level = 0
syslog = 0
syslog only = Yes

# we don't do printers
show add printer wizard = No
       disable spoolss = Yes
load printers = No
printing = bsd
printcap name = /dev/null

# misc.
smb ports = 445 139
unix extensions = No
wide links = Yes
use sendfile = Yes
aio read size = 0
aio write size = 0

# hook for user-defined samba config
include = /boot/config/smb-extra.conf

# auto-configured shares
include = /etc/samba/smb-shares.conf

       # Hide Mac Created Files
       hide files = /Network Trash Folder/Temporary Items/

 

Avahi detects the change as soon as you edit the file, and updates it's broadcasts. Samba however didn't seem to update to the change until I stopped, and then re-started the array.

 

This time, I've tried rebooting unRAID and re-applying the changes, as well as rebooting Lion and Snow Leopard... This time, my fix does seem to work.

Share this post


Link to post
Share on other sites

Nezil: When I make the changes you have mentioned in your last note, I can indeed use the sidebar as was the situation before Lion. However, I cannot survive a reboot. Even if I "remove" any available "smb.service" from the path and copy a saved copy from another directory to the /etc/avahi/services path using the GO script, I end up with a smb.service with old port number 139 instead of 445. I don't understand why this happens -perhaps as a default is it copied from another backup directory?

 

Edit: when one copies "smb.service" from another directory (e.g. /boot), a backup file of the original called "smb.service-" is also created in the same path causing problems.

Share this post


Link to post
Share on other sites

I turned off port 445 a long time ago because Samba was generating numerous syslog messages when being accessed by WinXP (complaining about port 445 - can't remember now exactly what was happening).  Anyway, I'll turn that back on and retest.

Share this post


Link to post
Share on other sites

I could use both AFP and SMB at the same time ONLY by doing the following:

Remove the "smb.service" file using the go script and reboot. You will see only AFP service in the sidebar and connect to it as usual. Then use "Command+K" to connect to any SMB share in unRaid, after which you will see the unRaid with its IP number in the sidebar with an eject sign beside it. Thereafter all your shares will be available as usual. I could not make any other suggested options work.  

After following the instructions to the letter I still have the same issues as aht961.

The error I get when selecting 'Tower-SMB' from the sidebar is:

There was a problem connecting to the server “Tower-SMB”.
This file server will not allow any additional users to log on. Try to connect again later.

Selecting 'Tower' from the sidebar just shows me my AFP share (Time Machine).

Connecting to 'smb://tower' manually via Connect to Server works of course, but that's not the point.

 

Perhaps the reason some of us have no joy whilst others experience success is because of the difference in our AFP & SMB setup?

My shares:

 - Time Machine (AFP only, Security: Private)

 - Media (SMB only, Security: Private)

 - Downloads (SMB only, Security: Private)

 

Share this post


Link to post
Share on other sites

Nezil: When I make the changes you have mentioned in your last note, I can indeed use the sidebar as was the situation before Lion. However, I cannot survive a reboot. Even if I "remove" any available "smb.service" from the path and copy a saved copy from another directory to the /etc/avahi/services path using the GO script, I end up with a smb.service with old port number 139 instead of 445. I don't understand why this happens -perhaps as a default is it copied from another backup directory?

 

Edit: when one copies "smb.service" from another directory (e.g. /boot), a backup file of the original called "smb.service-" is also created in the same path causing problems.

 

Ok, I have sorted it out by doing the following:

1. Create/Edit "smb.service" and "smb.conf" files as Nezil has mentioned.

2. Copy these two files as well as "afp.service" (at /etc/avahi/services/) to your flash drive (e.g. /boot/config/...)

3. Add the following lines to the beginning of your GO script

 

# remove the possible avahi services (smb.service and afp.service) if there are any

rm /etc/avahi/services/*

 

# remove the older smb.conf file

rm /etc/samba/smb.conf

 

# copy both files from your flash disk (or cache drive - change the path to match your directory)

cp /boot/config/smb.service /etc/avahi/services/smb.service

cp /boot/config/smb.conf /etc/samba/smb.conf

 

4. Add this line to the end of your GO file

 

#copy back the afp.service

cp /boot/config/afp.service /etc/avahi/services/afp.service

 

5. Stop the array and Reboot

 

Now you can use both AFP (tower) as well as SMB (tower-SMB) via the slidebar in Lion.

 

ps: This hack will not be needed any more when Tom will make the necessary amendments to the new coming version.

 

 

 

Share this post


Link to post
Share on other sites

Ok, I have sorted it out by doing the following...

Holy smokes - thanks aht961 for the details - now it works for me too.

For some reason the placement of those lines in the go script made the difference.

 

Any idea why?

Share this post


Link to post
Share on other sites

Hmm...I don't even seem to have either an AVAHI or SAMBA folder....This is why my sidebar has SKYNET and SKYNET - SMB on the side, correct?

Share this post


Link to post
Share on other sites

Ok, I have sorted it out by doing the following:

1. Create/Edit "smb.service" and "smb.conf" files as Nezil has mentioned.

2. Copy these two files as well as "afp.service" (at /etc/avahi/services/) to your flash drive (e.g. /boot/config/...)

3. Add the following lines to the beginning of your GO script

 

# remove the possible avahi services (smb.service and afp.service) if there are any

rm /etc/avahi/services/*

 

# remove the older smb.conf file

rm /etc/samba/smb.conf

 

# copy both files from your flash disk (or cache drive - change the path to match your directory)

cp /boot/config/smb.service /etc/avahi/services/smb.service

cp /boot/config/smb.conf /etc/samba/smb.conf

 

4. Add this line to the end of your GO file

 

#copy back the afp.service

cp /boot/config/afp.service /etc/avahi/services/afp.service

 

5. Stop the array and Reboot

 

Now you can use both AFP (tower) as well as SMB (tower-SMB) via the slidebar in Lion.

 

ps: This hack will not be needed any more when Tom will make the necessary amendments to the new coming version.

 

 

This is obsolete. With the release of 5v12, the problem does not exist any more so you can remove these lines from your GO script if you have added them earlier.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Copyright © 2005-2017 Lime Technology, Inc. unRAID® is a registered trademark of Lime Technology, Inc.