Enable USB Storage on 1.x

From AwkwardTV

Jump to: navigation, search

This guide is for Apple TV 1.x, for 2.x (Take 2) see Enable USB Storage on 2.x


Contents

DISCLAIMER

This process would not be available without the hard work of Turbo and he deserves all the credit for this accomplishment. Please donate on his site. http://0xfeedbeef.com/appletv/


Requirements

Patch the Kernel

Using Turbo's instructions, you need to patch your mach_kernel.prelink file. Please be careful doing this, and make sure that you're using a clean version of the mach_kernel.prelink otherwise you'll brick your ATV and you'll have to do a factory restore and start again.

There are two sets of USB patches on Turbo's page. If you haven't updated your ATV to 1.1 (or, if you've followed the Safe Update instructions), you need to use the one under the heading USB easy patch (2007-03-30 00:43).

If you have run the Software Update to 1.1, then it appears you need to use the patch under the heading USB easy patch for 1.1 kernel(2007-07-15 19:13).

It is, obviously, important to use the right patch, or you'll brick your ATV.

To be totally clear about this: Using patch for 1.1 kernel(2007-07-15 19:13)
-rw-r--r-- 1 mps mps 966 2007-09-25 28:05 turbo-11-usb-and-watchdog-20070623.bsdiff


# ls -l /mach_kernel.prelink
-rw-r--r-- 1 frontrow frontrow 6306364 Mar 15 2007 mach_kernel.prelink (original 1.0)
MD5 (/mach_kernel.prelink) = a195f9e6b0b4899a2917e5c20602ca1e


# ls -l /mach_kernel.prelink
-rw-r--r-- 1 frontrow frontrow 6143072 Mar 15 2007 mach_kernel.prelink (updated 1.1)
MD5 (/mach_kernel.prelink) = 30d1ac6466807bb8ca872f404f6a88ba


# ls -l /mach_kernel.prelink
-rw-r--r-- 1 frontrow frontrow 6143071 Mar 15 2007 mach_kernel.prelink (turbo-ized 1.1)
MD5 (/mach_kernel.prelink) = 311f50ae644bc16967b7c0ac91cefaae

If you md5 the patched file and it says 20c42872dd04ebc52bc2d106b421ae8d (size 6143071), then you patched the wrong (1.0) prelink file and you will brick, so stop now and re-patch starting with 1.1.

If you are just enabling USB for keyboard and mouse support, this is all you need to do.

Copy files to AppleTV

Copy IOUSBMassStorageClass.kext, IOStorageFamily.kext, and IOSCSIArchitectureModelFamily.kext from your Mac or combo update to /System/Library/Extensions/ on the AppleTV.


Ensure your owner and permissions are correct

sudo chmod -R 755 /System/Library/Extensions/IOUSBMassStorageClass.kext
sudo chmod -R 755 /System/Library/Extensions/IOStorageFamily.kext
sudo chmod -R 755 /System/Library/Extensions/IOSCSIArchitectureModelFamily.kext
sudo chown -R root:wheel /System/Library/Extensions/IOUSBMassStorageClass.kext
sudo chown -R root:wheel /System/Library/Extensions/IOStorageFamily.kext
sudo chown -R root:wheel /System/Library/Extensions/IOSCSIArchitectureModelFamily.kext


Turbo's Excellent Kext Enabler

Follow Turbo's instructions to create the /mach and /mach.sym files, a reboot is required. The instructions are on Turbo's page under the heading Enable kext loading on the AppleTV (2007-07-24 19:43).

Then run Turbo's kext enabler:

sudo turbo_kext_enabler.bin
If you're getting an error here, you might need to chmod 755 the bin file (by typing
chmod 755 turbo_kext_enabler.bin
at your ATV shell prompt).

Load your kexts

sudo kextload /System/Library/Extensions/IOUSBMassStorageClass.kext

This will load IOUSBMassStorageClass.kext in addition to its dependencies IOStorageFamily.kext and IOSCSIArchitectureModelFamily.kext.

To make this persistent, you can add something like this to your /etc/rc.local:

/your/path/to/turbo_kext_enabler.bin
kextload /System/Library/Extensions/IOUSBMassStorageClass.kext
You can confirm that the kext is working properly by checking running
diskutil list
and you should see your disk(s) following disk0.

Note, if you add the above lines to your rc.local file, the drive won't mount on bootup all the time. After boot, remove the drive, give it a second, and then plug it back in and it will automount immediately. See below under Epilogue.



Extra info for AppleTV Software 1.1

Having already done the 1.1 safe update, I had to grab the mach_kernel.prelink from the 1.1 update img, apply turbo's mach_kernel patch for USB, and then load that in before I could get my hard drive to mount. Exact steps I took:

1) Get http://mesu.apple.com/data/OS/061-2988.20070620.bHy75/2Z694-5248-45.dmg
2) Grab the mach_kernel.prelink file from the mounted image
3) Grab the bsdiff file from: http://0xfeedbeef.com/appletv/turbo-11-usb-and-watchdog-20070623.bsdiff
4) Apply the bsdiff file:

bspatch mach_kernel.prelink mach_kernel.patched turbo-11-usb-and-watchdog-20070623.bsdiff

5) Check the md5 hash for the new kernel (it should be 311f50ae644bc16967b7c0ac91cefaae)

md5 mach_kernel.patched

6) Rename the mach_kernel.patched file to mach_kernel.prelink and then copy it to your AppleTV.
7) Copy the mach_kernel.prelink file you've uploaded to the root directory (sudo mv mach_kernel.prelink /) 8) Reboot your AppleTV.

Then apply the turbo_kext_enabler, and do the kextload. Your drive should now be mounted.

(Comment: The Safe Update doesn't require the use of the 1.1 kernel - these instructions should probably only be followed if you've run the Software Update to 1.1 and haven't applied any hacks etc) (Comment 2: While its true that the Safe Update didn't require this new kernel, I did the Safe Update, and using the new kernel+turbo's USB kernel patch was the only way I could get my USB drives to mount. Note that I had originally posted this in the Talk section, someone else posted it over here. In no way was I saying or implying that this was required, I was only stating how I got things to work.) - kupan787

Epilogue

Now when you plug in a USB disk, your drive's partitions will be mounted at /Volumes/. If your disk was plugged in from the beginning the process or has been rebooted you will need to unplug it and plug it back in and the drive will mount at /Volumes/.

        • this is not neccesary see the following section
In order to make the disk mount at boot, you'll need to make a StartupItem or LaunchAgent to load the partition to an existing directory, such as this command:
mount /dev/diskXsY /Volumes/diskname
where X is the disk number, Y is the partition number, and diskname is an empty directory.

Automatically mount external disks on startup

To mount external disks automatically to /Volumes/... run the following command. It only needs to be run once and no need to add anything to the startup sequence.

sudo defaults write \
/Library/Preferences/SystemConfiguration/autodiskmount \
AutomountDisksWithoutUserLogin -bool true

Filesystem Compatibility

Be sure you have the correct owner and permissions as above for these kexts as well.

Name Works? Requires Notes
HFS, HFS+YesNo additional files
FAT32YesYou will need to copy and kextload msdosfs.kext for it to work.If you are using 1.1 full update, you will need /System/Library/Filesystems/msdos.fs in the same folder on your AppleTV.
NTFS - read-onlyYesYou will need to copy and kextload ntfs.kext to mount, but you will be unable to modify the filesystem.If you are using 1.1 full update, you will need /System/Library/Filesystems/ntfs.fs in the same folder on your AppleTV.
NTFS - read-writeYesIn addition to the ntfs.kext above, you will need MacFUSE Core Installer Package 0.4.0 and NTFS-3G Package copied to the AppleTV. You can then run:
sudo installer -pkg MacFUSE Core.pkg -target /
sudo installer -pkg NTFS-3G.pkg -target /
then mount your disk by using a command similar to this:
mkdir /Volumes/ntfs 
ntfs-3g /dev/disk1s1 /Volumes/ntfs
If you are using 1.1 full update, you will need /System/Library/Filesystems/ntfs.fs in the same folder on your AppleTV.

Also, in limited testing, seemed very sluggish.


Move iTunes media to USB Drive

To have iTunes and ATV show the available space of the mounted drive, simply copy the complete contents of the Media directory of the original drive to the mounted drive and create a symbolic link to it. The Media dir on the original drive will no longer be used.

      cp -R /mnt/Media/* /mnt/Scratch/Volumes/<name of usb drive> 
      sudo mv /mnt/Media /mnt/Media.org
      sudo ln -s /mnt/Scratch/Volumes/<name of usb drive> /mnt/Media 

Please use the Talk page, the forum, or the irc channel for problems.

Personal tools