Mount a Remote Drive via AFP under 1.1

From AwkwardTV

Jump to: navigation, search

This section explains how to mount a remote drive with AFP under release 1.1. See Mount a Remote Drive via AFP for the simpler 1.0 solution.

Contents

mount_afp (using AppleShare kernel extension from Intel Mac)

As of release 1.1, Apple TV does not contain mount_afp and the afp filesystem kernel extensions as 1.0 did, or OS X does for mounting AFP shares. But thanks to the great work of Turbo, it's now possible to load kernel extension from Intel Macs.

DISCLAIMER

This process would not be available without the hard work of Turbo. Please donate on his site. http://0xfeedbeef.com/appletv/ I just copied and adjusted Dmd's great documentation on Mount a Remote Drive via SMBFS - he deserves all the credit for the text.

This guide here is based on Turbos guide and Enable USB Storage, where the kextloader originally has been developed for. Look at Enable Kext Loading for a general guide about .kext loading.

ONLY FILES FROM TIGER WILL WORK, LEOPARD FILES WILL NOT! 10.4.x IS A NECESSITY


Requirements

Copy files to Apple TV

Since you have to write files to your Apple TV disk, you have to Mount ReadWrite.

From Intel Mac

Copy the following files to your Apple TV (to the same location):

/System/Library/Filesystems/AppleShare
/sbin/mount_afp

From Combo Update

If you don't have an Intel Mac with OS 10.4.7 - 10.4.9, download the Combo Update and open it, right-click the included .pkg file and click "Show package contents". Then extract the file Contents/Archive.pax.gz. For me this did not work using Finder, so I copied Archive.pax.gz into a directory on my desktop (e.g. $HOME/Desktop/Update) and ran the following command in this directory to extract the contents:

pax -r -z -f Archive.pax.gz

Now copy the following included files to your Apple TV:

  • copy System/Library/Filesystems/AppleShare (directory) to /System/Library/Filesystems on Apple TV
  • copy sbin/mount_afp to /sbin on Apple TV

(Stenar): I downloaded the Combo Update and successfully copied over the /AppleShare directory, but when I went to copy over the sbin/mount_afp executable, it did not exist. Perhaps, Apple knew we were using it to enable AFP mounting on AppleTV and removed it? I also tried the 10.4.7 and 10.4.8 Combo Updates with no luck.

(zbisch): I ran into a similar problem and could not find mount_afp in the combo updates. However, my install recovery cds for my intel mac had the file in /sbin/ (Hidden directory on the CD). Hope this helps.

(boy412): I ended up pulling it from a X.4.7 Server install DVD. All of my Intel Mac restore discs are 10.4.10 or later. Shame on Apple for removing it from the combo update!

(tester): The mount_afp has been pulled from the combo because of a Security Update 2007-004, which was integrated into Security Update 2007-005 which you can download instead.

Create symbolic link in /System/Library/Filesystems

  • Create a symbolic link from AppleShare/afpfs.kext to afpfs.fs in /System/Library/Filesystems on Apple TV
 cd /System/Library/Filesystems
 sudo ln -s AppleShare/afpfs.kext afpfs.fs

Ensure your owner and permissions are correct

sudo chmod -R 755 /System/Library/Filesystems/AppleShare
sudo chmod +x /sbin/mount_afp
sudo chown -R root:wheel /System/Library/Filesystems/AppleShare
sudo chown root:wheel /sbin/mount_afp


Additionally I had to do a

sudo chmod +s /System/Library/Filesystems/AppleShare/afpLoad

Without this I could not mount the filesystem under a different user. This is also the standard setting in MacOS

(dwarfland:) you also need to install "/System/Library/Frameworks/AppleShareClientCore.framework", required by AppleShare.

Turbo's Excellent Kext Enabler

Follow Turbo's instructions accurately(!) to create the /mach and /mach.sym files, a reboot is required. Execute the following commands on your Apple TV:

sudo mount -uw /
sudo touch /.readwrite
sudo sync

Next, reboot the Apple TV. When it comes back up, you'll have 2 new files /mach and /mach.sym (if you don't, something went wrong!). Now you can make it read-only again:

sudo rm /.readwrite
sudo sync
sudo mount -ur /

Now you have to make the kernel load your .kexts, which it does not yet. Download Turbo's excellent kextloader (turbo_kext_enabler.bin) from http://0xfeedbeef.com/appletv/ and copy it to your Apple TV. After that you have to make it executable and run it:

chmod +x turbo_kext_enabler.bin
sudo ./turbo_kext_enabler.bin

Now you can load any kernel extensions! This has been reported to work with Apple TV 1.0 as well as 1.1.

Mount a Share manually

Now you can mount any AFP share:

mkdir /path/to/your/share
sudo mount_afp "afp://<Username>:<Password>@<IP-Address>/<Share>" /path/to/your/share

Mount at System Start

To make this mount and the .kext loading persistent across reboots, you can create a /etc/rc.local which can looks like that:

#!/bin/sh
/your/path/to/turbo_kext_enabler.bin

until ( ifconfig en0 ; ifconfig en1 ) 2>/dev/null | grep -q 'inet ' ; do
  sleep 2
done
ping -c2 <Router/Gateway IP>   # Ping twice for the first packet 
sudo -u frontrow mount_afp "afp://<Username>:<Password>@<IP-Address>/<Share>" /path/to/your/share


Look at the comments to Sharity Light for some more ideas and common pitfalls using this method.

A better solution would be to create a StartupItem or using launchd (which is the recommended way for OS 10.4.x). The important thing is to wait with mounting the share, until the network interface has an IP address and is connected to the network. That's why a loop is used in the script above.

Personal tools