|
BuildingPatchstick
Build a basic PatchstickWe have extracted boot.efi and partitioned a USB pen drive with a recovery and second hfsplus partitions using the above links. This guide assumes that the recovery partition is mounted at "/media/Recovery" and the second partition is mounted at "/media/Patchstick". Download recovery.tar.gz and copy it to the recovery partition # download recovery files wget http://atv-bootloader.googlecode.com/files/recovery-0.6.tar.gz sudo tar -xzf recovery-0.6.tar.gz sudo cp -arp recovery/* /media/Recovery/ Don't forget to copy boot.efi to the recovery partition sudo cp -ap boot.efi /media/Recovery Now make a simple patchstick script to test functionality. There is an existing sample patchstick.sh in recovery.tar.gz and we are just moving to the second partition where we will place all the other bits. You could just keep everything on the recovery partition (make it larger if you do this) but this keeps booting and patching separate. mv /media/Recovery/patchstick.sh /media/Patchstick/ edit com.apple.Boot.plist and change the following line <string>atv-boot=auto video=vesafb</string> to <string>atv-boot=patchstick video=vesafb</string> Now sync and unmount both partitions sync umount /media/Recovery umount /media/Patchstick Pull the USB pen drive and place into the USB port on the AppleTV and reboot/power on. You might have to use the IR remote and press "menu" and "-" buttons down during power on to force a USB recovery boot. You should see the tux/atv logo, then Linux kernel boot and then finally this is a patchstick stript If you have a USB keyboard attached, you can login (user=root password=root) and poke around. The USB pen drive will be at "/dev/sdb" and the internal ata drive is at "/dev/sda". example patchstick.shFill in "patchstick.sh" with the patchstick function you want to perform. Here's an example of a sshd install contributed by James Abeler of Apple Core, LLC. Thanks James, for being the first prove this method of patching the AppleTV OS. This script assumes that you have created a directory "ssh" on the "Patchstick" partition of the USB flash drive and populate it with the required files. #!/bin/bash exec 2>/dev/console exec 1>/dev/console echo echo " --- aTV Flash 2.0.1 Upgrade ---" echo " * mounting OSBoot partition" mkdir /mnt/OSBoot fsck.hfsplus /dev/sda3 mount -t hfsplus -o rw,force /dev/sda3 /mnt/OSBoot #echo " * mounting stuff partition r/o" mkdir /mnt/stuff fsck.hfsplus /dev/sdb2 mount -t hfsplus -r /dev/sdb2 /mnt/stuff echo " * keeping the OSBoot partition r/w for plugins" touch /mnt/OSBoot/.readwrite if [ -f /mnt/rootfs/stuff/ssh/sshd ] && [ -f /mnt/rootfs/stuff/ssh/ssh.plist ]; then echo -n " * Installing SSH daemon... " cp /mnt/rootfs/stuff/ssh/sshd /mnt/OSBoot/usr/sbin/sshd cp /mnt/rootfs/stuff/ssh/ssh /mnt/OSBoot/usr/bin/ssh cp /mnt/rootfs/stuff/ssh/ssh-add /mnt/OSBoot/usr/bin/ssh-add cp /mnt/rootfs/stuff/ssh/ssh-agent /mnt/OSBoot/usr/bin/ssh-agent cp /mnt/rootfs/stuff/ssh/ssh-keygen /mnt/OSBoot/usr/bin/ssh-keygen cp /mnt/rootfs/stuff/ssh/ssh-keyscan /mnt/OSBoot/usr/bin/ssh-keyscan cp /mnt/rootfs/stuff/ssh/scp /mnt/OSBoot/usr/bin/scp cp /mnt/rootfs/stuff/ssh/sftp-server /mnt/OSBoot/usr/libexec/sftp-server cp /mnt/rootfs/stuff/ssh/ssh-keysign /mnt/OSBoot/usr/libexec/ssh-keysign cp /mnt/rootfs/stuff/ssh/sshd-keygen-wrapper /mnt/OSBoot/usr/libexec/sshd-keygen-wrapper cp /mnt/rootfs/stuff/ssh/ssh.plist /mnt/OSBoot/System/Library/LaunchDaemons/ssh.plist chmod 755 /mnt/OSBoot/usr/sbin/sshd chmod 755 /mnt/OSBoot/usr/bin/ssh chmod 755 /mnt/OSBoot/usr/bin/ssh-add chmod 755 /mnt/OSBoot/usr/bin/ssh-agent chmod 755 /mnt/OSBoot/usr/bin/ssh-keygen chmod 755 /mnt/OSBoot/usr/bin/ssh-keyscan chmod 755 /mnt/OSBoot/usr/bin/scp chmod 755 /mnt/OSBoot/usr/libexec/sftp-server chmod 4755 /mnt/OSBoot/usr/libexec/ssh-keysign chmod 755 /mnt/OSBoot/usr/libexec/sshd-keygen-wrapper chmod 755 /mnt/OSBoot/System/Library/LaunchDaemons/ssh.plist # echo " Adding Kerberos..." # cp -p -R /System/Library/Frameworks/OSXFrames/Kerberos.framework /OSBoot/System/Library/Frameworks/OSXFrames/ # sed -i"" -e 's;^exec;DYLD_FRAMEWORK_PATH="/System/Library/Frameworks/OSXFrames" exec;' /OSBoot/usr/libexec/sshd-keygen-wrapper echo " done." else echo " SSH files not found." fi #-------------------------------------------------------------------------- sync &>/dev/null umount /mnt/OSBoot echo " all done!" echo echo " The aTV Flash software has been successfully installed. You may now remove the flash drive and restart your Apple TV." echo " Thanks from AppleCoreLLC.com" echo " :-)" sleep 100000 Here's an another example of installing "sshd". Nothing is auto mounted so you will need to mount any disk partitions manually. This also assumes that you have created a directory "ssh" on the "Patchstick" partition of the USB flash drive and populate it with the required files. #!/bin/bash # On Linux, bash is located at "/bin/bash" not "/sbin/bash" # make some mount points mkdir /stuff /OSBoot # mount the USB flash drive "Patchstick" partition mount /dev/sdb2 /stuff # always "fsck.hfsplus -f" hfsplus journaled partitions first fsck.hfsplus -f /dev/sda3 # mount "OSBoot" forcing it read/write mount -t hfsplus -o rw,force /dev/sda3 /OSBoot # patchstick scripts under Linux look the same as under OSX # it's just bash after all. # install ssh # (c) 2007 macTijn at awkwardtv dot org if [ -f /stuff/ssh/sshd ] && [ -f /stuff/ssh/ssh.plist ]; then echo -n " * Installing SSH daemon... " cp /stuff/ssh/sshd /OSBoot/usr/sbin/sshd cp /stuff/ssh/ssh /OSBoot/usr/bin/ssh cp /stuff/ssh/ssh-add /OSBoot/usr/bin/ssh-add cp /stuff/ssh/ssh-agent /OSBoot/usr/bin/ssh-agent cp /stuff/ssh/ssh-keygen /OSBoot/usr/bin/ssh-keygen cp /stuff/ssh/ssh-keyscan /OSBoot/usr/bin/ssh-keyscan cp /stuff/ssh/scp /OSBoot/usr/bin/scp cp /stuff/ssh/sftp-server /OSBoot/usr/libexec/sftp-server cp /stuff/ssh/ssh-keysign /OSBoot/usr/libexec/ssh-keysign cp /stuff/ssh/sshd-keygen-wrapper /OSBoot/usr/libexec/sshd-keygen-wrapper cp /stuff/ssh/ssh.plist /OSBoot/System/Library/LaunchDaemons/ssh.plist chmod 755 /OSBoot/usr/sbin/sshd chmod 755 /OSBoot/usr/bin/ssh chmod 755 /OSBoot/usr/bin/ssh-add chmod 755 /OSBoot/usr/bin/ssh-agent chmod 755 /OSBoot/usr/bin/ssh-keygen chmod 755 /OSBoot/usr/bin/ssh-keyscan chmod 755 /OSBoot/usr/bin/scp chmod 755 /OSBoot/usr/libexec/sftp-server chmod 4755 /OSBoot/usr/libexec/ssh-keysign chmod 755 /OSBoot/usr/libexec/sshd-keygen-wrapper chmod 755 /OSBoot/System/Library/LaunchDaemons/ssh.plist echo " Done." fi |
Very nice, everything worked like a charm. One issue in my case (but may be I did something wrong, I am fairly new to all this, sorry). When my AppleTV boots on the patchstick, this is the display I get at the end:
atv-boot=patchstick -- searching for patchstick.sh chmod: /mnt/rootfs/patchstick.sh: Read-only file system /etc/init.d/rcS: line 75: [sdb2/patchstick.sh: not found atv-boot=auto/manual/patchstick failed -- starting telnetd
If I then manually run (from a telnet session) "/usr/sbin/find_run_script.sh patchstick.sh" this is working just fine (it finds the script and executes it). Any ideas?
The current internal script will try to "chmod +x" the patchstick.sh script so it can be executed. If the partition was not cleanly unmounted then it will get mounted read only thus causing an error as the chmod will fail. It's a quirk with hfsplus filesystems and Linux and one should always fsck.hfsplus the partition before mounting.
This is fixed with a pending new version but I'm not ready to post it yet.
Understood. Thanks for the answer. It did not stop me anyway, I now have a patchstick with LiveXBMC installed and everything works just fine except the AppleTV remote that I did not manage to make it work (yet). All that thanks to your really great instructions. Thanks a bunch, greatly appreciated.
Thanks for the great boot loader instructions. I have a question about the boot process. How does the system "know" to run /dev/sdb2/patchstick.sh? From the comment above by tcherel /etc/init.d/rcS is trying to call sdb2/patchstick.sh and not finding it (I saw the same behaviour, so I telnetted in and ran it by hand). I cannot find this call to sdb2/patchstick.sh in the recovery archive that I downloaded. Thanks again, Dan
In Comment by tcherel, Jul 04, 2008, the important clue is "Read-only file system /etc/init.d/rcS: line 75". It could not run sdb2/patchstick.sh as it needed to change the file execute flags, can't on a Read-only file system. Need to look at the source in svn to see the search and call to patchstick.sh
I'm getting up to the point where it says:
searching for patchstick.sh
This is even if I use the dummy patchstick.sh in the Patchstick partition.
From looking at the source, I was wondering if it might be an issue with this from rcS:
if patchstick.sh -eq 0 ?; then
fiBut since others don't appear to be having this issue could it be something else?
Thanks!
Hi Scott, joining the foray here. I get almost the same issue as tcherel in the first post, but without the read only. After the starting telnetd message, it says started discover.... discover.... discover.... failing Then boms out without an ip address so I cannot tenet either.
I fan fsck.hfsplus on both partitions and no errors. Also patchstick.sh has the correct permissions.
I'm pretty new at this, being a windows user, Unix and Apple command structure is all a little new to me, so it may be something assumed that I'm missing.
Any help would be appreciated.
discover.... discover.... discover.... could that be because you are wifi and not wired?
Oops! A classic case of mouth in gear before brain in operation. Thanks Scott.
Hi,
I'm having the same problem. I've tried 3 different usb sticks and I either get the "0: unknown operand" error or the "can't find patchstick.sh" error
Any ideas?