Difference between revisions of "Enable SSH Without Opening the Apple TV"

From AwkwardTV
Jump to: navigation, search
(Alternative approach)
Line 1: Line 1:
 
==Parts Needed==
 
==Parts Needed==
 
*External USB drive
 
*External USB drive
*<tt>partition.img</tt>, <tt>recovery.img</tt>, and <tt>efi.img</tt> from an Apple TV drive. (These images are explained and can be created using the steps found in [[Prepare a Hard Drive]].)
+
*boot.efi from appletv
 +
*licensed copy of os x for intel
 +
*usb hub w/ external power
  
 +
==Instructions==
 +
<font color=red>THE METHOD DESCRIBED BELOW ASSUMES THE USB DRIVE OR IPOD YOU ARE INSTALLING TO IS EMPTY AND HAS NO DATA THAT YOU CARE ABOUT</font>
  
==Alternative approach==
+
1. Install full osx onto the ipod, using semthex's kernel and instructions detailed here: [http://www.appletvhacks.net/2007/04/01/mac-os-x-running-on-apple-tv/ http://www.appletvhacks.net/2007/04/01/mac-os-x-running-on-apple-tv/]
Currently this approach won't work because the kernel 'cuts off its own head' - it boots, but it has no kext for a USB external storage device, so the kernel is loaded by the EFI but can't proceed any further.
 
  
Another possibility is to attempt to get it to boot the hacked OSX install. The Apple TV will currently boot a usb external restore partition with the rather lovely type <tt>5265636F-7665-11AA-AA11-00306543ECAC</tt> from a usb drive.  Unfortunately, OSX won't read this to be able to install anything to it. Moreover, the current restore.img taken from the appleTV hard disk is a little too small for an OSX install.  So while we can create a large partition of type 5254... using gpt, how can we read write that as a HFS+ drive to install onto it?  Alternatively, can we change the type of a working partition to 5254...
+
2. Modify the AppleFileSystemDriver<br>
 +
<b>Very special thanks to [http://0xfeedbeef.com/appletv/ Turbo] for this patch, without him I might still be trying to get the boot to complete</b><br>
  
So I'm stuck, but this seems to me a promising approach to getting it to boot to the termnal from an external drive.
+
Add:
 
+
<code>
I've tried booting with the semthex kernel prelinked but it froze waiting for the usb disk -wasn't sure if it had seen the external drive - it should have as it had my OSX boot kernel extentions.
+
<pre>
 
+
&lt;dict&gt;
==The Steps==
+
        &lt;key&gt;Content Hint&lt;/key&gt;
<font color=red>FIRST ATTEMPT DID NOT WORK. CHANGING A FEW THINGS AND WILL TRY AGAIN</font>
+
        &lt;string&gt;5265636F-7665-11AA-AA11-00306543ECAC&lt;/string&gt;
 +
        &lt;key&gt;Leaf&lt;/key&gt;
 +
        &lt;true/&gt;
 +
&lt;/dict&gt;
 +
&lt;dict&gt; 
 +
        &lt;key&gt;Content Hint&lt;/key&gt;
 +
        &lt;string&gt;Apple_Recovery&lt;/string&gt;
 +
        &lt;key&gt;Leaf&lt;/key&gt;
 +
        &lt;true/&gt;
 +
&lt;/dict&gt;
 +
</pre>
 +
</code>
 +
into: /System/Library/Extensions/AppleFileSystemDriver.kext/Contents/Info.plist in the IOPropertyMatch array section<br>
 +
<br>
 +
If you skip this step then OSX wont boot and will complain that it is waiting for the root device<br>
 +
<br>
 +
Now we are going to change the partition info to that of a recovery system
 +
(THIS PART VARIES ON EACH SYSTEM)
 +
<br>
 +
2. sudo gpt show /dev/disk1<br>
 +
You should get results such as:
 +
<pre>
 +
      start      size  index  contents
 +
          0          1        PMBR
 +
          1          1        Pri GPT header
 +
          2        32        Pri GPT table
 +
        34          6       
 +
        40    409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
 +
    409640  116538416      2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
 +
  116948056    262151       
 +
  117210207        32        Sec GPT table
 +
  117210239          1        Sec GPT header
 +
</pre>  
  
<br>We are going to modify the repair image and the OS that it installs when you factory reset your Apple TV.
+
index 1 is the EFI partition<br>
 +
index 2 is the osx installation<br>
  
# Mount <tt>recovery.img</tt> on your Intel-based Mac.
+
now do this to set it up to work as recovery partition<br>
# Convert the existing OS.img on the Recovery volume to one that is writable.
+
<font color=red>THIS ASSUMES /dev/disk1 is your external drive you can break your system if it isnt<br></font>
 
<pre>
 
<pre>
hdiutil convert -format UDRW -o RW.dmg /Volumes/Recovery/OS.dmg
+
gpt remove -i 2 /dev/disk1
 
</pre>
 
</pre>
#Mount the new <tt>RW.img</tt>
+
Then take the numbers from above and plug them in respectively, for me the start point is 409640 and the size is 116538416<br>
#Copy <tt>sshd</tt> and the <tt>ssh.plist</tt> file onto the new OSBoot you created.
 
 
<pre>
 
<pre>
cp /System/Library/LaunchDaemons/ssh.plist /Volumes/OSBoot/System/Library/LaunchDaemons/ssh.plist
+
gpt add -b 409640 -i 2 -s 116538416 -t 5265636F-7665-11AA-AA11-00306543ECAC /dev/disk1
cp /usr/sbin/sshd /Volumes/OSBoot/usr/sbin/sshd
 
 
</pre>
 
</pre>
#Convert the new <tt>RW.img</tt> back into a read-only compressed image.
+
Now unmount the drive and connect it to the appletv, and boot up with menu and -<br>
<pre>
+
Make whatever changes you want, you will want to use a USB hub so you can hookup a keyboard as well
hdiutil convert -format UDZO -o NEWOS.dmg RW.dmg
+
 
</pre>
+
==References==
#Copy the <tt>NEWOS.dmg</tt> image onto the repair image
+
*[http://0xfeedbeef.com/appletv/usbboot http://0xfeedbeef.com/appletv/usbboot]
<pre>
+
*[http://phoem.com/appletv-without-open.html http://phoem.com/appletv-without-open.html]
cp NEWOS.dmg /Volumes/Recovery/OS.dmg
 
</pre>
 
#Unmount the recovery image by either ejecting it in the Finder or using <tt>diskutil unmount</tt>.
 
#Now we are going to setup the external drive:
 
<pre>
 
dd if=partition.img of=/dev/disk# bs=1024k count=100
 
dd if=efi.img of=/dev/disk#s1
 
dd if=recovery.img of=/dev/disk#s2
 
</pre>
 
#Plug in the USB drive to the Apple TV after its booted
 
#Press menu and - (minus) on the remote
 
#Then run factory restore
 

Revision as of 00:02, 5 April 2007

Parts Needed

  • External USB drive
  • boot.efi from appletv
  • licensed copy of os x for intel
  • usb hub w/ external power

Instructions

THE METHOD DESCRIBED BELOW ASSUMES THE USB DRIVE OR IPOD YOU ARE INSTALLING TO IS EMPTY AND HAS NO DATA THAT YOU CARE ABOUT

1. Install full osx onto the ipod, using semthex's kernel and instructions detailed here: http://www.appletvhacks.net/2007/04/01/mac-os-x-running-on-apple-tv/

2. Modify the AppleFileSystemDriver
Very special thanks to Turbo for this patch, without him I might still be trying to get the boot to complete

Add:

<dict>
        <key>Content Hint</key>
        <string>5265636F-7665-11AA-AA11-00306543ECAC</string>
        <key>Leaf</key>
        <true/> 
</dict> 
<dict>  
        <key>Content Hint</key>
        <string>Apple_Recovery</string>
        <key>Leaf</key>
        <true/> 
</dict> 

into: /System/Library/Extensions/AppleFileSystemDriver.kext/Contents/Info.plist in the IOPropertyMatch array section

If you skip this step then OSX wont boot and will complain that it is waiting for the root device

Now we are going to change the partition info to that of a recovery system (THIS PART VARIES ON EACH SYSTEM)
2. sudo gpt show /dev/disk1
You should get results such as:

      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
     409640  116538416      2  GPT part - 48465300-0000-11AA-AA11-00306543ECAC
  116948056     262151         
  117210207         32         Sec GPT table
  117210239          1         Sec GPT header

index 1 is the EFI partition
index 2 is the osx installation

now do this to set it up to work as recovery partition
THIS ASSUMES /dev/disk1 is your external drive you can break your system if it isnt

gpt remove -i 2 /dev/disk1

Then take the numbers from above and plug them in respectively, for me the start point is 409640 and the size is 116538416

gpt add -b 409640 -i 2 -s 116538416 -t 5265636F-7665-11AA-AA11-00306543ECAC /dev/disk1

Now unmount the drive and connect it to the appletv, and boot up with menu and -
Make whatever changes you want, you will want to use a USB hub so you can hookup a keyboard as well

References