Pages

Thursday, June 14, 2012

Samba on OSX Lion Server

I bumped into problems mounting SMB shares from OSX Lion Server using a Linux based media device I have hooked up in the living room.

The problem is that Apple decided to get rid of SMB (Due to licensing I read) and write their own. It doesn't work properly with a number of linux based set top devices, and mine just happens to be one of them.

No worries! We'll fix this up quick and in a hurry!

First thing I did, nano /etc/services and find entries for 137,138,139 and 445. Modify them to be 19137, 19138, 19139 and 19445. This way, if file sharing accidently gets turned on in the Sharing Preferences, you won't have conflicting services trying to run on the same port.

--

netbios-ns      19137/udp     # NETBIOS Name Service    
netbios-ns      19137/tcp     # NETBIOS Name Service    
netbios-dgm     19138/udp     # NETBIOS Datagram Service
netbios-dgm     19138/tcp     # NETBIOS Datagram Service
netbios-ssn     19139/udp     # NETBIOS Session Service
netbios-ssn     19139/tcp     # NETBIOS Session Service
microsoft-ds    19445/udp     # Microsoft-DS
microsoft-ds    19445/tcp     # Microsoft-DS

--


Next, I installed homebrew. I've tried macports before and had luck, but there is a problem with samba on OSX when it's ran by users that are a part of more than 16 groups (root is unfortunately).

From https://github.com/mxcl/homebrew/wiki/installation

--

/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"

--

You have to run this as a normal user!

After that was done, I ran these commands to update and install samba.

brew update
brew doctor
brew install autogen
brew install https://raw.github.com/angerman/homebrew/patch-1/Library/Formula/samba.rb.


After samba was installed, I placed the following files in /Library/LaunchDaemons/

org.samba.smbd.plist

--
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>org.samba.smbd</string>
        <key>OnDemand</key>
        <false/>
        <key>ProgramArguments</key>
        <array>
            <string>/usr/local/Cellar/samba/3.6.3/sbin/smbd</string>
            <string>-F</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>ServiceDescription</key>
        <string>samba</string>
    </dict>
</plist>
--

org.samba.nmbd.plist

--
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>org.samba.nmbd</string>
        <key>OnDemand</key>
        <false/>
        <key>ProgramArguments</key>
        <array>
            <string>/usr/local/Cellar/samba/3.6.3/sbin/nmbd</string>
            <string>-F</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>ServiceDescription</key>
        <string>netbios</string>
    </dict>
</plist>

--

I restarted for good measure, but I don't know that it was required. When the server came back up, I was able to modify /usr/local/Cellar/samba/3.6.3/etc/smb.conf to my liking, and killall -9 smbd.

Connecting over SMB:// to the server shows my entries, and everything is just dandy... Thank you homebrew!

No comments:

Post a Comment