Mount a Remote Drive via SMBFS

From AwkwardTV
Revision as of 02:46, 19 June 2007 by Alexis (talk | contribs) (Manual connection ok, but startup connection fails - Problem Solved: Provided solution)
Jump to: navigation, search

This section deals with possible solutions to handle mounting of SMBFS ('Windows shares') on the ATV.

Users familiar with OS X kernel extension will know from experience that a stock 10.4.7 or 10.4.8 smbfs.kext will not load/link against the ATV kernel. This means that SMB shares cannot be enabled simply by copying the smbfs.kext from a Mac onto the AppleTV. Instead, a separate smbfs mounter program will have to be installed.

There are a number to choose from - Sharity 3, DAVE, etc.

Sharity Light

Download

  • This procedure requires you to work with the command line in Terminal.
  • You can either compile sharity yourself, or download a pre-compiled binary.
  • You will need Developer Tools installed on an Intel Mac in order to compile sharity yourself. If you'd rather avoid compiling from source (or have a PPC Mac, linux box, etc.) use the pre-compiled binary option below.


Precompiled binary option

Compiling sharity from source yourself

  • Make sure the server you're about to mount exists in the /etc/hosts file on your AppleTV.
  • On your Mac, download v1.3 @ http://www.obdev.at/products/sharity-light/index.html
  • Sharity will download as a .tar archive. You can unpack it by clicking on the archive and OS X will unpack the archive for you.
  • Unpack the archive (this has been tested on an Intel 10.4.8 system) and edit the Makefile.
  • The Makefile comes set to compile for NextStep/OpenStep rather than OS X.
  • So you need to switch the Makefile to compile for OS X by commenting out the NextStep section (i.e. putting a # symbol at the beginning of each line of the NextStep section
  • # Uncomment the OS X section by removing the # symbols at the beginning of the CFLAGS, THE_CC and RPC_WARNFLAGS lines of the Makefile section for MacOSX.
  • You will need to do some tapdancing to compile Sharity. Run make. It will bomb out--don't worry. cd to nfs, run make, cd .., run make, and test ./shlight
  • You will now have a compiled binary, shlight

Installation

  • sftp, scp or use fugu to transfer shlight from your computer to the AppleTV. You will want to transfer the binary first to your ATV frontrow home directory: /Users/frontrow/
  • After transferring the binary to the AppleTV, SSH into the ATV
  • First make sure your AppleTV drive is mounted read/write.
  • From SSH type: sudo mv shlight /usr/sbin (or /usr/bin)
  • You will be asked for a password. The password is frontrow by default.
  • Then type: sudo chmod +x /usr/sbin/shlight

Mounting your drives as frontrow:

  • Sharity is a userland application. It is not built into the operating system and rather must be placed into running status by you from ssh, or through the use of a script should you wish to automatically mount designated drives upon startup
  • To mount your share, run shlight from the command line. Following the shlight command indicate the share first (use SMB // notation for the server name, followed by the share name) and the sharepoint the SMB share will be mounted to on your AppleTV second. Unlike appleshare or NFS mounting on the AppleTV you do not need to create a mount point using mkdir--sharity will provide the mount point you indicate.

For example:

/usr/sbin/shlight //server/Share /Users/frontrow/Movies/MountedShare

  • Some SMB servers will require you to specify a username and password in the command-line. The username and password needed are those from the account sharing the directory you want to mount. For example:

/usr/sbin/shlight //server/Share /Users/frontrow/Movies/MountedShare -U username -P password

This format is particularly useful in a script. You can automate the mount by placing the above command in the /etc/rc.local file on the AppleTV.

  • Or you can just run:
/usr/sbin/shlight //server/Share /Users/frontrow/Movies/MountedShare -U username
if you don't mind being asked for a password


After mounting your share:

  • Fire up ATVFiles and browse your content
  • Tested for about 12 hours with a variety of clips ranging in size 600Mb-4Gb, bitrates 500Kbps-4.5Mbit, and codecs supported by Perian. No issues yet.
  • Also tested on a linux box running ubuntu Feisty Fawn.

Troubleshooting Sharity

Failing to connect to a server by either IP or NetBIOS name

Installed it, I'm able to mount other machines' SMB shares, just not my fileserver's for some reason...

From the ATV:

bash-2.05b# ping x.x.x.x
PING x.x.x.x (x.x.x.x): 56 data bytes
64 bytes from x.x.x.x: icmp_seq=0 ttl=128 time=1.199 ms
64 bytes from x.x.x.x: icmp_seq=1 ttl=128 time=0.476 ms
64 bytes from x.x.x.x: icmp_seq=2 ttl=128 time=0.327 ms
64 bytes from x.x.x.x: icmp_seq=3 ttl=128 time=0.737 ms
64 bytes from x.x.x.x: icmp_seq=4 ttl=128 time=0.625 ms
^C
--- x.x.x.x ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.327/0.673/1.199/0.297 ms
bash-2.05b# shlight //x.x.x.x/movies ~/Movies
x.x.x.x: unknown host

Happens as root or as frontrow...

ProfessaFresh 22:35, 27 April 2007 (CEST)

Solution

I had the same issue. Fixed it by altering the hosts file. It seems that shlight doesn't work with IPs and if you haven't got DNS working properly, it fails. Adding the IP + Hostname to /etc/hosts means that both the IP and the hostname respond. dobedobedoh 21:37, 27 April 2007 (GMT)

thanks dobedobedoh, that worked

ProfessaFresh 22:51, 27 April 2007 (CEST)


Thanks for this hack! It works perfectly! oorosh

Fails to open files

In a setup with shlight and Vista (in a domain) it seems you need to specify -W [domain name]. It connects and shows the files (you can browse), but fails to open. the shlight responds with:

nfs server shlight-163: not responding nfs server shlight-163: not responding

and can only be killed. The apple tv interface keeps waiting for the files become available. Which doesn't because of input/output error and can only be satisfied with a sudo reboot.

--Battler 17:29, 12 June 2007 (CEST) I have the same problem with a Windows 2003 File server thats in a domain. Sow I thought just add the domain name. with the -W command. The error message that I have is; Workgroup/Domain too long (max 15): dns.dnsnameof20charcts.com How can I solve this problem without actualy changing the domain name.


Fails to open files, cont'd

I have the same problem as above, although I have not been able to verify the error message as I can't seem to get debugging working. shlight works great when mounting from a Ubuntu/Samba share, but can only browse when mounting a Vista share and crashes when I try to open a file. Any help would be greatly appreciated.

Benjaminfox 08:46, 19 June 2007 (CEST)

Kernel: smb_receive_raw: Invalid packet 0x83

Kernel: smb_receive_raw: Invalid packet 0x83
Kernel: smb_receive: receive error: -5
Kernel: smb_proc_connect: Failed to send SESSION REQUEST.
error connecting to server: [5] Input/output error

This error may be seen if the hosts file has been set up improperly. Make sure the hosts file and the windows system name are identical, otherwise use the "-c" and "-s" options to shlight.


Manual connection ok, but startup connection fails - Problem solved

connecting my Windows XP machine via Terminal works great:

/usr/sbin/shlight //192.168.xx.yy/Video /Users/frontrow/Movies/Filme -U frank -P xxx

I added this command to my rc.local to have the connection right on startup, but unfortunately this does not establish a connection to my server. I have to do it manually every time I start up the ATV - which then always works great. rc.local is located th the etc directory. I also added IP and host name to my hosts file with no result.

Where's my mistake?

JeanLuc7 12:31, 12 May 2007 (CEST)

I've the same problem...

Galphanet 16:16, 22 May 2007 (CEST)

Me too! /etc/rc.local does not seem to work automatically. Manually executing /etc/rc.local works. Is /etc/rc supposed to call rc.local? Should /etc/rc be executable because on my system it isn't. I tried making /etc/rc executable and then running it but it gave me an error about an unbound variable on line 18.

Gcleaves 13:00, 6 June 2007 (GMT+1)

Your problems all stem from the same source: The Ethernet (or 802.11n) interface isn't up and configured when you try to mount, because it uses DHCP, and it hasn't acquired an address yet.
I've written a LaunchDaemon item that handles this for AFP and NFS, but the problem is identical. Here's an excerpt from the script that does the important part:

until ( ifconfig en0 ; ifconfig en1 ) 2>/dev/null | grep -q 'inet ' ; do
  echo "waiting 1 second for network interfaces..."   # You can delete this line
  sleep 1
done

But there's still one more detail to address: The first packet out will be dropped (I didn't bother to figure out why, it didn't seem worth the trouble). There are several approaches to that problem. Since I wanted to never have to think about it again, my mounter just does the first mount twice (if the first attempt succeeds, the second fails harmlessly, so it can run even after system boot time). But if you know your environment, you could simply ping your home router once. Or just hit the broadcast address:

ping -c1 192.168.1.255   # Your network addresses may be different!

For most people, simply combining the two code excerpts above into rc.local, before the mount_afp or shlight command, should do the trick. But I encourage you to make your own LaunchDaemon, it's not hard to learn.

The other option would be to use the automounter. I'd have tried that first, except the puzzle of why things weren't working was really irritating me...

And to answer other questions, no, /etc/rc* don't have to be executable. And yes, rc does call it. --Alexis June 18 2007

Commercial SMB Clients (Ex. DAVE)

Not tested for obvious reasons.