Well it’s been a nightmare few days with the upgrade to Lion GM breaking Samba sharing. For me NFS isnt really an option, it’s clunky, and my network is full of old windows machines, not to mention the XBMC’s on the Apple TV 2, Ipad 2, iPhone and the old Xboxs. i needed a fix for Samba, and this came in the form of installing Samba 3 on Lion via Macports and setting up the smb.conf file manually to share my media.
This text is partly my own work and partly complied from other tutorials.
You will need a copy of Lion GM installed on your mac, along with a copy of xcode 4.1 (available from a lot of places, legitimate or otherwise). You will then also install first macports and then samba 3 via terminal, but most of this stuff is copy & paste. Finally, I’d install a copy of Textwrangler for mac. It will let you edit files in its text editor without using the command line, which is much easier, and will let you unlock & authenticate to save/open files anywhere in the filesystem.
First, install Xcode 4.1 (DP7 or GM is needed currently).
Second, install MacPorts from SVN using these directions taken from macports site
Check out MacPorts source
In Terminal, one line at a time
sudo mkdir -p /opt/mports
sudo cd /opt/mports
sudo svn checkout http://svn.macports.org/repository/macports/trunk
Build and Install MacPorts
MacPorts uses autoconf and makefiles for installation. These commands will build and install MacPorts to /opt/local. I ran all these with the sudo command before them to avoid permissions problems
sudo cd /opt/mports/trunk/base
sudo ./configure --enable-readline
sudo make
sudo make install
sudo make distclean
Open /opt/local/etc/macports/sources.conf in a text editor. The last line which should look like this:
rsync://rsync.macports.org/release/ports/
Change it to point to the working copy you checked out:
file:///opt/mports/trunk/dports
Now MacPorts will look for portfiles in the working copy.
After installing MacPorts, you may need to add it to your PATH, so go ahead and run in terminal:
export PATH=$PATH:/opt/local/bin
and then
sudo port -d sync
This will make sure that it is added to your path, and you shouldn’t have to specify full paths to binaries. The second command tells macports to download the latest versions of the portfiles (instructions for macports on installing a program)
Once everything with macports is finished setting up, open up a terminal window and type
sudo port install samba3
It’ll automatically install samba 3 and all of its dependencies.
Now to edit the configuration! It’s pretty straight forward if you read through the config file located at /opt/local/etc/samba3/smb.conf (it’s callend smb.conf.sample, just remove the .sample from the filename and open with textwrangler).
Your shares should look something like this (you can have as many as you like):
[Downloads]
comment = Downloads
path = /Users/jodsclass/Downloads
available = yes
guest ok = yes
create mask = 644
directory mask = 755
read only = no
[Movies]
comment = Movies
path = /Volumes/MyBook/Movies
available = yes
guest ok = yes
create mask = 644
directory mask = 755
read only = no
[TV]
comment = TV
path = /Volumes/MyBook/TV Shows
available = yes
guest ok = yes
create mask = 644
directory mask = 755
read only = no
Also, remember to change your workgroup name to match the rest of the machines on your network, mine are all on workgroup so mine looks like
# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
workgroup = WORKGROUP
And the name of my mac is imac so my server string is
# server string is the equivalent of the NT Description field
server string = imac
(that way SMB shares can be accessed at smb://imac instead of using IP based). You can leave the rest of the config file commented out.
All that’s left now is to do
sudo /opt/local/sbin/smbd -D && sudo /opt/local/sbin/nmbd -D
(I’m using full paths so we dont accidentally start up the apple supplied smb server ) and samba will be up and running. The only downside I’ve found is that you do need to remember to start samba every time you reboot (the “sudo /opt/local/sbin/smbd -D && sudo /opt/local/sbin/nmbd -D” commands).
You can use the following launchagent to start the samba server everytime your machine restarts.
Download mine here and put it in /Library/LaunchAgents, and it should automatically start up samba for you.
Now in XBMC just add your samba shares as follows.
smb://imac (or whatever your machine is called in the server string above)
NOTE: Please remember to turn off SMB sharing in settings>sharing>File Sharing as the built in OSX Lion SMB implementation will clash with the one you installed via Macports
If you found this post helpful why not help out my business and buy some geek badges from our site
At the time this was written Lion was still in developer preview. Macports was not available for the developer build so needed to be installed & compiled via terminal.
You probably havnet added the executables to your paths. It is better to install it the way I’ve done it. Also opt/local/bin is where we decided to install macports via terminal, does the executable in your .dmg use a different folder? Follow the commands in this tutorial and you should be able to get it to work. Over 4000 people have contacted me to state it works this way so it’s very do’able.
I changed the path to be: file:///opt/local/share/macports
Now it’s partly working, but when I do the sudo port install samba3 command I now get:
Warning: No default port source specified in /opt/local/etc/macports/sources.conf, using last source as default
Warning: port definitions are more than two weeks old, consider using selfupdate
Error: Port samba3 not found
Any ideas?
John… A big big THANKS !! All is ok. Thanks you !!
Thanks for the excellent tutorial, John. I successfully got it running this weekend. For the record, I used the MacPorts 2 Lion .dmg file and did not build from the source and XCode. Given that, I don’t know if XCode is truly necessary (unless MacPorts requires it). My only remaining issue is that launchd doesn’t auto-start Samba with your samba3.plist file (edited for my machine name) and is producing console respawning messages every 10 seconds…I’ll figure that out later. Samba is running fine, though. I can’t thank you enough. My LG BD690 sees and streams from the SMB shares just like before Lion.
can someone post an example of smb.config ?
where i post username , ip e password of my MAC ??
@Andy —
I set a samba password using:
macdaddy:bin jeff$ sudo /opt/local/bin/smbpasswd -a user
It will ask for a password, and from then on you should be able to use it or at least it worked for me for a username that matched my username.
I keep getting this error when trying to install Macports…help..
“svn: OPTIONS of ‘http://svn.macports.org/repository/macports/trunk’: could not connect to server (http://svn.macports.org)”
One key element in getting this to work is to add the user using SMBPASSWD -a *****
If you don’t do this u will not be able to connect from Windows 7, because it’s just giving you a error message (Wrong password).
The only way to get the SMBPASSWD to work is to type the full pathway.
Open Terminal and type
sudo /opt/local/bin/smbpasswd -a YOURUSERNAME
You should use your real OS X Lion Username. Press Enter, You will then be need to set the password. after you are done it all worked like a charm!
Thanxs alot!
Thanks for this. The primary purpose for this workaround was for access without username & password authentication allowing XBMC to connect via SMB. Nice tip though.
Pingback: [no Bug] OS X Lion SMB to Windows BUG - MediaPortal Forum
now it’s all ok…..work but dont work the “launch agent”…..i have a Mac Pro ….not Imac…..how to modify the file ?
THANK YOU VERY MUCH !!! IT WORKS PERFECTLY !!!
how to add password in the .plist file ??
I followed all the steps listed and created my shares, however my mac still does not show up in XBMC when I got to Add Source>Windows Network (SMB). My older mac running leopard is there but my macbook with Lion still doesn’t display. Any ideas?
I installed MacPorts from the Lion DMG. Everything went well. But now when I enter in the “sudo port install samba3″ command, I get this error:
Warning: No default port source specified in /opt/local/etc/macports/sources.conf, using last source as default
Warning: port definitions are more than two weeks old, consider using selfupdate
Error: Port samba3 not found
To report a bug, see
Any ideas?
@Perry F et al – Make sure you open a support ticket with Apple and tell them what you think – they CAN fix this in future versions, but they have to hear about the problem. It does NOT cost to open a ticket – you have the option to select “I just purchased an operating system”.
You need to add the SMB share manually in XBMC. Click add a share, select SMB as the type and then use the IP address of your Lion mac, or the machine name you setup in smb.conf in the address field. Then when you click OK it will add it asa source.
You’re missing two parts of the macports install process, this is why I like to install via terminal. Firstly you need to add the source to your macports files
“Open /opt/local/etc/macports/sources.conf in a text editor. The last line which should look like this:
rsync://rsync.macports.org/release/ports/
Change it to point to the working copy you checked out:
file:///opt/mports/trunk/dports
and then you need to sync macports with this in terminal
sudo port -d sync
This will update your repository list & list of all sources in your macports, and allow you to install samba 3. Essentially its a file telling macports where to find all the source files online.
I’ve had nothing but success. Thanks so much for this.
Very interesting but I have a slightly different problem. I am trying to connect to a Humax Foxsat HDR (a PVR box running Linux). Samba is installed on the Humax and since upgrading to Lion I can no longer connect using SMB. The Humax is on the same wireless network as my MacBook. Under 10.6 I could see the Humax as a shared device and watch my recorded programmes using VLC.
I have installed Samba 3 as above but how do I use Samba 3 instead of Apple’s crazy implementation ??? I am still getting the same error with Lion as I did before installing Samba 3…
Finally got it working through a combination of automated install and manual Terminal magic. This is so much better than the UPNP software I had to use this last month that froze for like 2 minutes every time I rewound or fast-forwarded anything I was watching.
Thanks very much for this tip!
Somehow nmbd fails to start up:
bind failed on port 137 socket_addr = 0.0.0.0.
Error = Address already in use
smbd seems to work fine though; can connect to it by using IP number. Any idea what can be wrong?
Danny
Pingback: Problem z udostepnianiem plikow przez SMB
I’ve done all the steps and have entered my IP address into XBMC on my Apple TV 2. I can connect to my MacBook PRO but no folders are showing up!
I’ve edited samba to be like this, but nothing shows up. Am i missing something?
;[New!]
; comment = New!
; path = /Users/Lionel/Movies/New!
; available = yes
; guest ok = yes
; create mask = 644
; directory mask = 755
; read only = no
;[Movies]
; comment = Movies
; path = /Users/Lionel/Movies/
; available = yes
; guest ok = yes
; create mask = 644
; directory mask = 755
; read only = no
;[Giant]
; comment = Giant
; path = /Users/Lionel/Movies/Entertainment
; available = yes
; guest ok = yes
; create mask = 644
; directory mask = 755
; read only = no
;[Downloads]
; comment = Giant
; path = /Users/Lionel/Downloads
; available = yes
; guest ok = yes
; create mask = 644
; directory mask = 755
; read only = no
Hi Lionel
For a start you need to remove all the semi colons at the start of each line of your shares, they are used to comment lines out and you don’t want any lines of your shares commented out. This is why your shares aren’t showing up. Secondly I wouldn’t use the ! I your share name as this may cause issues. Thirdly the name in the square bracket should really match the name in the comment. You have named 2 shares Giant in your comments.
Hi John,
thanks for your quick response. It works now except for my external HDD (Giant) that i’m trying to get to show up.
The error message i get id “Error 2: share not available”
Could you take a look to see if there’s something wrong with this code?
[Giant]
comment = Giant
path = /Lionel’s Macbook Pro/Giant/Entertainment
available = yes
guest ok = yes
create mask = 644
directory mask = 755
read only = no
Btw, the HDD is formatted in exfat. that shouldn’t have a problem being recognized right? Thanks for your help
thanks very much for this ! my apple tv is useful again !
yay !
Hi John,
I did everything you’ve said, but without success. Everything seemed to work in Terminal, and I used TextWrangler to edit the config files, renamed it etc. Started up the service, but I don’t get any response, my XBMC (on my ATV2) isn’t seeing the share I’ve made;
[Data]
comment = Data
path = /Volumes/Data
available = yes
guest ok = yes
create mask = 644
directory mask = 755
read only = no
How can I see if the SMB server is actually running?! I can’t find it running in the tasks list in OSX?!?!
Thanks for your help!
Greetz from Holland,
Jeroen
Do I need to rename or otherwise edit the plist file to get samba3 to automatically run at restarts?
I’m on a Mac mini –
SMB:
NetBIOSName: MAC-MINI
Workgroup: HOME
http://www.johnlarge.co.uk/com.imac.samba3.plist
Hi Lionel,
you should properly escape your path as you have some spaces in it. That should fix it. Or just rename /Lionel’s Macbook Pro/Giant/Entertainment to something like “LionelsMacbookPro/Giant/Entertainment”
Mirko
Hi John,
I just want to say, the way you have helped so many people and continue to do so by sharing your expertise with this blog is really cool.
I can see that you wrote the guide before certain things became easier to install.
Just in summary, my experience has been:
1. Xcode was easy to install from the App store
2. Macports installation was easy from the package installer from the website
3. I went straight to installing Samba3 successfully via terminal using your line:
sudo port install samba3
4. Everything works fine except for the Launchagent
5. I’ve tried various workarounds, even using Lingon as a recent observer commented but I’m wondering whether the problem is I need to type in my password at some point, which is also why I wonder Roger asked on the 26th July?
Can anyone else confirm for me my suspicion that it is a password issue, I need to somehow get the plist file to supply my password as I do when I run the line in Terminal?
If so, is there any way of automating this? I’ve already tried removing the password altogether, and of forcing myself to login with a password when i reboot (rather than using the automatic login). I’ve also tried changing the config from user to server and inserting a server password, but all to no avail.
Many thanks again for the solution you’ve provided. For now, of course the set up works perfectly for me as long as I manually load samba as you warned us.
[iMac 2.66Ghz Intel Core 2 Duo running Lion, several external HDD via FW800 - now all fully accessible by my Beyonwiz DP-P2]
HI John have a question…how is the correct setup for share to multiples device ? actually have just correctly configured Nintendo Wii IP of Wii is 192.168.1.5 …. have assigned @ my notebook this static IP : 192.168.1.8…but …..
Hi there,
thanks for all you help, I’m getting an error message after typing the following command in to terminal:
sudo cd /opt/mports/trunk/base
the message i get is:
/usr/bin/cd: line 4: cd: /opt/mports/trunk/base: No such file or directory
any thoughts? The macports commands seemed to work and there was plenty of installs going on.
Thanks
Thanks Mirko and John for all your help! I can now get all my files (even from my external HDD) to show.
Only challenge remaining now is i need to manually key in the command each time i restart my mac. I can’t seem to get the launchagent plist file to run each time i restart my mac.
Any thoughts? I have even renamed my mac to “imac” to suit your file but it still doesn’t work
Work finally with the following changes, not sure if this is the proper way but it’s working for me. Please comment.
1) Instead of /Library/LaunchAgents, put the plist file in /Library/LaunchDaemons.
2) Remove com.apple.netbiosd.plist in /System/Library/LaunchDaemons as it blocks the port required for the nmbd to be launched.
One more change, instead of getting the command “sudo /opt/local/sbin/smbd -D && sudo /opt/local/sbin/nmbd -D” as in one plist. I have to separate them into two plist files, that’s the only way I can make it work. Let me know if there’s any other way.
sudo /opt/local/sbin/smbd -D
sudo /opt/local/sbin/nmbd -D
Also, for the KeepAlive key, it’s better to set it to false or else the command will be called every 10 seconds.
Hi John
Followed your instructions worked ok.
Except when I tried to turn off Lion’s SMB the user will not uncheck so Lion is still using its SMB not samba3 I have just installed. Any idea on how to get around this ?
Thank you
Stuart
I have installed samba3 hoping to get my Boxee to connect..but when i put in the address (smb://imac) it says “Connection Refused”. could there be some permission problem here??
On Lion Client it seems you need to put your .plist (launchagent) in /User/LaunchDaemons then it worked perfectly.
Many thanks!
Hi,
Thx a LOT for this post! It really helped! BUT: I have problems using the “server string” from smb.conf. I only get “Connection refused” when typing “smb://macmini”. It works with IP address though. I can of course use IP, but it would have been great to get server string working also. Can someone point me in the right direction?
Thx,
Morten
Great guide! thx!
I have the same issue as others. I have smbd running, but in nmbd log file I have this error:
mbd version 3.2.15 started.
Copyright Andrew Tridgell and the Samba Team 1992-2009
[2011/08/01 17:55:21, 0] lib/util_sock.c:open_socket_in(1336)
bind failed on port 137 socket_addr = 0.0.0.0.
Error = Address already in use
I have smb sharing disabled in lion settings, still have AFP sharing on.
Anyone have an idea what the issue might be? System is early 2008 mac pro.
Can someone explain why I got this?:
“sudo: ./configure: command not found”
the most advanced operating system of the world
I’m also running into the password issue for the Launch Agent. I’ve tried piping my password in as such:
echo | sudo -S /opt/local/sbin/smbd -D && sudo -S /opt/local/sbin/nmbd -D
That didn’t work. I also tried modifying my sudoers file to let my username use sudo without a password. No luck there either. I’d really love it if someone smarter than me came up with a solution. I’m shit when it comes to command line wizardry.
That was supposed to say:
echo “password” | sudo -S /opt/local/sbin/smbd -D && sudo -S /opt/local/sbin/nmbd -D
I didn’t realize it would strip angle brackets.
Hi
John, I have the same issue than David:
with nmbd:
bind failed on port 137 socket_addr = 0.0.0.0.
Error = Address already in use
I don’t know how I can disable Lion smb. I go to settings and I have all share options disabled.
I have this error all the time:
sudo mount_smbfs //192.168.1.1/DiscosUSB /Users/pedro/Volumes/livebox/
mount_smbfs: server connection failed: Unknown error: -5996
I’ve got the same problem as A Jones on July 31, 2011 at 3:47 pm:
“I’m getting an error message after typing the following command in to terminal:
sudo cd /opt/mports/trunk/base
the message i get is:
/usr/bin/cd: line 4: cd: /opt/mports/trunk/base: No such file or directory.
”
What am I doing wrong?
thanks for your help,
Koen
Having the same issue as David and Pedro
[2011/08/06 00:34:23, 0] lib/util_sock.c:open_socket_in(1336)
bind failed on port 137 socket_addr = 0.0.0.0.
Error = Address already in use