Enable Samba Server

Hello guys,
 

In case you couldn’t get aTV Flash (black) Beta5 or newer for some reason, you could try another way (annoying actually) to enable SMB server on your AppleTV using Terminal of the Mac in order to stream your content wirelessly over the network into the ATV & have fun with it :wink:

 

The Topic Source has been taken from here:
http://wiki.awkwardtv.org/wiki/Enable_SAMBA_server 

The codes are more tidy in there so you might wanna check it out !!

 


Contents

 

Introduction

SAMBA is an ethernet based service which allows an AppleTV to share files and printers.

This how-to bases on the AwkwardTV forum SMB in reverse.

Prerequisites

This method bases on the installation via SSH. Following this method, the extracting and editing commands will work directly on the AppleTV.

Installation

The installation bases on the MacPorts project and its Samba package. The idea is to install a SAMBA service on an Intel Mac and copy it to the AppleTV. Luckily, you won’t have to do this yourself, as the result is downloadable.

  • Copy it to your AppleTV via scp or Fugu to /Users/frontrow/Documents/.
  • Login and assume higher privileges (if prompted for password, enter the password for frontrow ):
ssh frontrow@AppleTV.local
sudo -s
  • OPTIONAL STEP: If you don't have much space in the '/' file system you may want to do this
mkdir /mnt/opt
ln -s /mnt/opt /opt
  • Extract it:
tar -xvjpf /Users/frontrow/Documents/samba3_macports_bin.tar.bz2 -C /

Note: the above only works if you have installed bunzip2 on your AppleTV. If not, then extract it using bunzip2 on your Mac and then copy the tar file to the AppleTV. In this case, eliminate the “j” from the tar command string – it should be “tar -xvpf …”

If you just untar the file, make sure you have changed to “/opt” folder.

Configuration

Configuration file

The server configuration is found in /opt/local/etc/samba3/smb.conf.

Edit it:

cp /opt/local/etc/samba3/smb.conf.sample /opt/local/etc/samba3/smb.conf
nano -w /opt/local/etc/samba3/smb.conf

Note: if you have not installed nano on your AppleTV this will not work. In this case, edit the file on your Mac and then transfer it to the AppleTV.

Editing the configuration can be a tedious process. The simplest thing to do is to modify the proper part in order to have:

[homes]
 comment = Home Directories
 browseable = yes
 writable = yes

By default these modifications will enable to you mount only your “frontrow” homefolder. If you would like to be able to mount let’s say your USB drive, you need to add something like this in the bottom of the file:

 [USB]
  comment = USB Drive
  path = /Volumes/USB Drive name
  valid users = frontrow
  public = no
  writable = yes
  printable = no

Password

The SAMBA passwords are different from the user login ones. Give the user frontrow a password:

sudo /opt/local/bin/smbpasswd -a frontrow

Change Service File Permissions

sudo chown root:wheel /opt/local/sbin/smbd
sudo chmod 4555 /opt/local/sbin/smbd
sudo chown root:wheel /opt/local/sbin/nmbd
sudo chmod 4555 /opt/local/sbin/nmbd

Service

The service is now ready to be started:

/opt/local/sbin/smbd -c /opt/local/etc/samba3/smb.conf
/opt/local/sbin/nmbd -c /opt/local/etc/samba3/smb.conf

Test if from your Mac’s Finder menu: Go -> Connect to Server… (Cmd-K), give the server address smb://AppleTV.local and follow the indications.

The chosen directories are mounted on /Volumes/. You can unmount them from there, either from the Finder or from the Terminal.

Automatic loading at boot

All three of the following options accomplish the same thing in different ways.

Using launchd

Automatically loading the Samba service at boot can be done by launchd by defining two LaunchDaemons.

  • Login to the AppleTV and navigate to the user startup items location:
ssh frontrow@AppleTV.local
sudo -s
  • Create a file /System/Library/LaunchDaemons/org.samba.smbd.plist with the following contents:
<?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>/opt/local/sbin/smbd</string>
			<string>-c</string>
			<string>/opt/local/etc/samba3/smb.conf</string>
		</array>
		<key>RunAtLoad</key>
		<true/>
		<key>ServiceDescription</key>
		<string>samba</string>
	</dict>
</plist>
  • Then create a file /System/Library/LaunchDaemons/org.samba.nmbd.plist with the following contents:
<?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>/opt/local/sbin/nmbd</string>
			<string>-c</string>
			<string>/opt/local/etc/samba3/smb.conf</string>
		</array>
		<key>RunAtLoad</key>
		<true/>
		<key>ServiceDescription</key>
		<string>samba</string>
	</dict>
</plist>

Unmount the Samba shares, restart the AppleTV and try mounting them again.

Using rc.local

Automatically loading the Samba service at boot can be done with the help of /etc/rc.local. Create or edit the file and add the commands from the following listing:

# rc.local

# For AppleTV 2.0.1 (2.0.0?) you may need to uncomment the following line to remount hard disk read/write
# mount -uw /

# start the SAMBA service
/opt/local/sbin/smbd -c /opt/local/etc/samba3/smb.conf
/opt/local/sbin/nmbd -c /opt/local/etc/samba3/smb.conf

Unmount the Samba shares, restart the AppleTV and try mounting them again.

Defining a startup item

Let’s define a Shares startup item:

  • Login to the AppleTV and navigate to the user startup items location:
ssh frontrow@AppleTV.local
sudo -s
cd /Library/StartupItems/
  • Create the folder defining the startup item and go inside it:
mkdir Shares
cd Shares
  • Create the Shares startup item script (the name must match the directory):
#!/bin/sh

##
# Share control
##

. /etc/rc.common
samba_path='/opt/local'
service_name='Network Shares'

StartService ()
{
    echo "Starting $service_name"
    $samba_path/sbin/smbd -c $samba_path/etc/samba3/smb.conf
    $samba_path/sbin/nmbd -c $samba_path/etc/samba3/smb.conf
}

StopService ()
{
    echo "Stopping $service_name"
}

RestartService ()
{
    StopService
    sleep 2s
    StartService
}

RunService "$1"
  • Grant read,execute permission to Shares :
sudo chmod 555 Shares
  • Create the StartupParameters.plist definition:
{
  Description     = "Network Shares";
  Provides        = ("Network Shares");
  Requires        = ("Disks");
}

Unmount the Samba shares, restart the AppleTV and try mounting them again :wink:

 

Good Luck everyone :slight_smile:

Salaam

So this will allow me to watch my stored movies (media), that are saved on my ATV1 or ATV2 once it is running on my Apple TV?  This will work to do that?  

Any other Apple TV in my local network can see these files?

What of a remote network?  can I see these files remotely?

 

If u enable smb server on your atv1 or atv2, you’ll be able to stream ur media over the network wirelessly to the atv & finally watch them with ease!!

BUT, since Firecore released a new version of their software (aTV Flash -black- beta5) which supports enabling smb protocol on the atv2 exclusively, u don’t need to use my method unless u wanna enable smb on the old atv (First generation 2007)!!

Good Luck Buddy :wink:

When entering and executing the following line in the terminal

/opt/local/sbin/smbd -c /opt/local/etc/samba3/smb.conf

I get an error of "abort trap" everytime.  So because of this samba never loads.

Line  /opt/local/sbin/nmbd -c /opt/local/etc/samba3/smb.conf  runs fine with no errors back.

Has anyone encountered this, or know how to resolve this?  I tried replacing the smb.conf file with the backup, rebooted appletv, etc.  Still cannot get samba loaded and working.

Everything else in the instructions works, just the line above as I stated.

 

Well I figured this out for myself.  At least in my case I got it working.  I went back and looked at the file in location /opt/local/sbin/smbd.  Guess the smdb file got corrupt at some point.  So I copied the original file back from samba3_macports_bin.tar.bz2 location.  Followed with the rest of the steps, now I have this working.  Now I just have to test it with mounting the smb share from my Apple TV 2.  Currently I have it mounted on my win7 pc.