Enable SAMBA server

From AwkwardTV
Revision as of 12:42, 8 December 2008 by Fcorthay (talk | contribs) (Defining a startup item)
Jump to: navigation, search


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

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


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


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/.
  • Extract it:
ssh frontrow@AppleTV.local
sudo -s
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 ....."


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:

 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:

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


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


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

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):

# Share control

. /etc/rc.common
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 ()
    sleep 2s

RunService "$1"
  • 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.