Enable USB Storage on 1.x

From AwkwardTV
Revision as of 19:22, 28 August 2007 by AK2007 (talk | contribs) (Load your kexts)
Jump to: navigation, search

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.


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.


Automatically mount external disks on startup

To mount external disks automatically to /Volumes/... run the following command

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

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/.

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.


Filesystem Compatibility

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

Name Works? Requires Notes
HFS, HFS+ Yes No additional files
FAT32 Yes You 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-only Yes You 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-write Yes In 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.


Bugs - or Just a Lack of Features

Currently, iTunes cannot recognize any addition space available as the drive is mounted separately and the AppleTV will not factor it into it's total space available. It is however, possible to use the additional space with symbolic links from the ~/Movies directory generally utilized by plugin authors. If anyone has fixes, please post them here.


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