For simplicity, I tend to stream from my media server to my TVs and computers using Samba shares. Samba shares implement the standard CIFS file-sharing protocol, are accessible from every major operating system, and work just fine with most media front-ends (for example: XBMC, Boxee, Windows Media Center, and my WD TV LIVE set-top box).
Create Folder Tree to Share
First, create the folder tree you wish to use for most of the file operations on the server. I created, under my home directory, a dl folder for downloads, and a media folder for all types of media.
I created subfolders under “dl” for Transmission to use for torrents that are downloading, seeding, complete (that is, seeding is complete), and a watch folder for incoming torrent files. I created subfolders under “media” for different types of content the HTPC front-ends expect to see. I share the entire home folder for general file maintenance, and the media folder, separately, as a read-only share for guests (the HTPCs.
- dl
- complete
- downloading
- seeding
- watch
- media
- movies
- music
- photos
- tv
$ mkdir -p ~/dl/complete
$ mkdir ~/dl/downloading
$ mkdir ~/dl/seeding
$ mkdir ~/dl/watch
$ mkdir -p ~/media/movies
$ mkdir ~/media/music
$ mkdir ~/media/photos
$ mkdir ~/media/tv
Install Samba
Ubuntu Server’s installer offers you the option of installing Samba. If you did not elect to do so, it is simple to invoke the exact same install process from the command line. It happens that apt-get isn’t the command you use here. Instead, you use tasksel, which is meant to install groups of software packages based on tasks (such as file sharing, in this case).
$ tasksel install samba-server
Configure Samba
To use Samba shares, you need to configure the daemon. The default configuration file is verbosely documented, so most of the work you will do in this file involves commenting out various lines.
You will have to edit the Samba configuration file to create file shares and alter the configuration.
$ sudo nano /etc/samba/smb.conf
First, lock down Samba to your local network, because it is not considered good security practice to run Samba over the Internet. Under the “[global]” section, add a line to allow only hosts on your network, which is most likely defined as “192.168.1.0/24” or “10.0.0.0/8”.
hosts allow = 192.168.1.0/24
If you are concerned about streaming performance, you can also add/edit the socket_options parameter, under the “[global]” section, to read as follows. These settings are meant to lower latency and to set large send and receive buffers.
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536
To define the home folder share, add the following section to the bottom of the file. (You could also uncomment and edit lines in the “[homes]” section.) This will set up folders for all users on your server, locked down by their username/password.
[homes]
comment = Home Directories
valid users = %S
read only = No
create mask = 0775
directory mask = 0775
browseable = No
Finally, set up a simple, read-only share for the “media” folder.
[media]
comment = Media Server
path = /home/mjdescy/media
guest ok = Yes
Save the configuration file, and reload the daemon.
$ sudo service smbd restart
Wrap-Up
After setting up Samba and restarting the daemon, you will be able to connect to the shares as if they were Windows file shares. The “media” share can be used without a specific account. The “homes” shares will be named after each login user name on the system. On my network, I can use my server’s hostname to connect to the shares. If that does not work for you, try using the server’s IP address.