Apple TV - Recover from nothing Take 2

Ok, so I have updated this for Take 2 and Leopard. This is more of a rought draft, but it worked well for me. Please comment if I have missed any steps since I am writing this after the fact. One big change from the original article us you can let Disk Utility do some of the work for you now. Also, I just skipped the restore partition to keep it simple since that was the source of many problems.

Connect your Apple TV drive in Leopard. Remember disk1 may not be the name of your drive.

From the terminal: Wipe out and re-create the partition structure
sudo diskutil unmountDisk /dev/disk1
sudo gpt destroy /dev/disk1
sudo gpt create /dev/disk1

Create the OSBoot Partition
sudo gpt add -b 888872 -i 3 -s 1843200 -t hfs /dev/disk1
diskutil unmountDisk /dev/disk1
sudo diskutil eraseVolume "Journaled HFS+" OSBoot /dev/disk1s3
diskutil unmountDisk /dev/disk1

Create the Media Partition
Go to Disk Utility and format the Media partition - Name it Media and use the rest of the free space on your drive.
diskutil unmountDisk /dev/disk1

Restore the OS image to the drive
Download it here:
http://mesu.apple.com/data/OS/061-3561.20080212.ScoH6/2Z694-5274-109.dmg
to your desktop.

sudo dd if=/Users/username/Desktop/OS.dmg of=/dev/disk1s3 bs=1m

Now Bless the boot file
Notice how the OSBoot we are blessing is OSBoot 1 because it is on Disk 1.

bless --folder="/Volumes/OSBoot 1/System/Library/CoreServices" --file="/Volumes/OSBoot 1/System/Library/CoreServices/boot.efi" --setBoot

Now pray and let me know if you are successful or not so we can make this article more useful.

--ORIGINAL ARTICLE IS BELOW

I titled this appropriately after destroying all data on my AppleTV and learning the hard way how to rebuild the drive with no backup or spare AppleTV. The process does not take very long, but I had a hard time finding all of the info in one place and I don't know anyone else currently that owns an AppleTV that I can borrow.

Assumptions / Caveats:
1. My guide assumes that you will remove the drive from your AppleTV. However, this could be done without removing the drive by booting from a USB drive with OSX (Sorry, you'll have to search for this elsewhere).

2. You will need to download the Apple OS 1.1.dmg file (The latest at the time I am writing this) which contains the OSBoot data. Luckily, Apple provides this file at http://mesu.apple.com/data/OS/061-2988.20070620.bHy75/2Z694-5248-45.dmg. You can also use version 1.0 if you happen to have that DMG image, I have verified it works as well.

3. You will need an Intel Mac and a USB cable or external enclosure to connect the AppleTV drive to you computer. I used an old 40gb IBM TravelStar hard drive in my test.

4. I don't know if this is crucial, but to be safe I downloaded an app called Spotless that lets you turn Spotlight off termporarily while doing this.

5. I did not restore the recovery data, therefore my guide lacks this step, although the partition is there. From my readings, it looks like you can do this by renaming the DMG you downloaded from apple above to OS.DMG and copy it to the recovery partition / reset its permissions to 777 after you finish this guide by using a patchstick, or possibly even do it right after you create the partition. I don't know and I hope someone will post this in the comments. However, this guide should get you back to factory state and a working AppleTV otherwise.

6. When you are in the terminal, you should be running as root, or you need to add sudo in front of the below commands.

Instructions:
Follow the instrctions on removing your AppleTV drive (if you need to). Basically, peel the rubber off the bottom and remove the 4 case screws and the 4 drive screws with a torx screwdriver ($6 - Lowes).

1. Connect the drive to your Intel Mac with your USB connector.
2. We need to know which drive it is, so open up the terminal and type:


diskutil /list

Pay attention to which disk is your usb disk. On my Intel mac, my internal hdd was disk0, so my USB was disk1. Throughout this document, be sure to substitute your correct disk id or you may blow away your hard drive.

3. Now we will completely destroy anything on the drive to start with a blank slate. When the finder asks you to initialize the disk, just choose ignore.

diskutil unmountDisk /dev/disk1
gpt destroy /dev/disk1
gpt create /dev/disk1

4. Next, we need to add the OSBoot partition with the following command and then unmount it.

gpt add -b 888872 -i 3 -s 1843200 -t hfs /dev/disk1
diskutil unmountDisk /dev/disk1


5. Now, we need to determine how much space is on your hard drive for your Media partition. Look at the line directly above Sec GPT table. This is the starting number and size of the partition. Don't get these wrong.

gpt show /dev/disk1
diskutil unmountDisk /dev/disk1

6. substitute the words START and SIZE with the numbers you got from step 5.

gpt add -b START -i 4 -s SIZE -t hfs /dev/disk1

7. Now we are going to prepare the OSBoot and Media Partitions.


diskutil eraseVolume "Journaled HFS+" OSBoot /dev/disk1s3
diskutil eraseVolume "Journaled HFS+" Media /dev/disk1s4
diskutil unmountDisk /dev/disk1

8. Next, we will copy the image you downloaded from Apple to the OSBoot partition 3. This will take a few minutes to copy. You could also do this from the disk utility by choosing restore and dragging the OSBoot partition into the destination box. However you choose to do it, make sure it is done before proceeding. You can't mess around with the partitions once you create the EFI and boot partitions because Disk Utility will mess the order up.


dd if=/Users/beauford/Desktop/
2Z694-5248-45.dmg of=/dev/disk1s3 bs=1m
diskutil unmountDisk /dev/disk1

9. Now we need to create the EFI parition and the Restore partition.

gpt add -b 40 -i 1 -s 69632 -t efi /dev/disk1
diskutil unmountDisk /dev/disk1
gpt add -b 69672 -i 2 -s 819200 -t 5265636F-7665-11AA-AA11-00306543ECAC /dev/disk1


10. Finally, we need to bless the drive so that the AppleTV can boot it (This is one big line).

bless --folder=/Volumes/OSBoot/System/Library/CoreServices --file=/Volumes/OSBoot/System/Library/CoreServices/boot.efi --setBoot

diskutil unmountDisk /dev/disk1

11. Unmount the disk and put it back in your AppleTV and boot up.


Credits / References

The guide I wrote is from many hours of searching other sites, newsgroups, etc.. I want to offer credit to the following sites specifically:

awkwardTV
Prepare a hard drive article: http://wiki.awkwardtv.org/wiki/Prepare_a_Hard_Drive
Info about the recovery partition: http://forum.awkwardtv.org/viewtopic.php?f=13&t=839

Cisco & Friends (English Version) -  How to create a USB Patchstick: http://www.cerof.net/2007/10/19/piccola-guida-alla-creazione-di-un-patchstick/#more-99

MacRumors Forums - http://forums.macrumors.com/showthread.php?t=320839

AppleTV Hacks
Hack the AppleTV without opening the case
http://www.appletvhacks.net/2007/04/03/hack-the-apple-tv-without-opening-the-case

Removing the drive - http://blog.makezine.com/archive/2007/03/violating_my_apple_tv_war.html



Read and post comments | Send to a friend

Comments

  1. I keep getting "gpt add: /dev/disk1: error: entry at index 1 is not free" at step #9 any ideas why?

    ReplyDelete
  2. I actually am having trouble with several parts of this tutorial. At step 7, I can get the first step to work but the second gives "Disk Utility ToolUsage:

    ReplyDelete
  3. After you get to step 7, please post the result of your partition status by running:gpt show /dev/disk1We should be able to figure something out from that. Make sure the disk is unmounting prior to this and that you used the correct numbers in step 6. You should probably make sure spotlight is disabled as well.

    ReplyDelete
  4. Ok first off... this will NOT work in Leopard! I have much more success not that I have run this in Tiger however I still am having a few problems first I want to make sure that step 10 should be executed like this...sudo bless --folder=/Volumes/OSBoot/System/Library/CoreServices --file=/Volumes/OSBoot/System/Library/CoreServices/boot.efi --setBoot(all on one line) if so I receive in response,No mount point for /Volumes/OSBoot/System/Library/CoreServicesCan't determine mount point of '/Volumes/OSBoot/System/Library/CoreServices' and ''Any ideas what this could mean?

    ReplyDelete
  5. Thanks for all your hard work in putting together this great article. I am also having the same problem as chris.Thanks in advanceASHman

    ReplyDelete
  6. I hope we didn't scare you off, I just hope to get a better idea of how you got these steps to work on you system... any help would be greatly appreciated...

    ReplyDelete
  7. Apparently the OSBoot partition disappears when doing step 9. Does anyone have an idea why?/Marcus

    ReplyDelete
  8. Thank you all for your comments. I am going to go back through, except this time using the Take2 image and doing this on Leopard. I will update this as I proceeed.

    ReplyDelete
  9. Any update on Take 2 and Leopard? My ATV bit the dust (flashing question mark) when I tried to run the Take 2 upgrade, and now I'm just trying to restore it from nothing but I have Leopard. What needs to be done differently?

    ReplyDelete
  10. Well, I've been at this for hours and have gotten nowhere. The real problems (doing this with Leopard) start in step #7. When I run eraseVolume, diskutility for some reason starts moving partitions around. The OSBoot and Media partitions you've created at s3 and s4 get moved to s2 and s3. It also creates its own EFI partition at s1. The rest of the guide, even if I adjust for the new partition numbers and try to stick the recovery partition out in s4, just won't work. The OSBoot loses it's label at some point and I'm so tired that I'm starting to lose track of what I have/haven't done. Hopefully someone can offer some pointers really soon...I miss my Apple TV already!!

    ReplyDelete
  11. I posted a draft update to the original article that will hopefully help out a bit for doing this on Leopard and using the Take 2 image.

    ReplyDelete
  12. Ok I think I'm close, few questions... 1."sudo dd if=/Users/username/Desktop/OS.dmg of=/dev/disk1s3 bs=1m"

    ReplyDelete
  13. Chris,1. Yes, sorry I renamed my dmg to OS.dmg.2. This is all one line. You may want to double check that OSBoot 1 is correct for your AppleTV drive, but also check that the disk is mounted at the time you do this. I think I said to unmount it after doing the Media partition, but forgot to mention you need to mount it again.

    ReplyDelete
  14. Ok I also renamed the .dmg so that must have executed correctly, on my system it is disk 1 so it should be OSBoot 1 as well correct? and as far as formatting the media partition, it should be journaled? I also thought it shoud be mounted so i unplugged the external drive and then tried to bless it but no dice, but to mount correctly would I issue "diskutil mountDisk /dev/disk1" right after "sudo dd if=/Users/username/Desktop/OS.dmg of=/dev/disk1s3 bs=1m" ? thanks again for all your help!

    ReplyDelete
  15. That sounds right, but you should be ok if you can just unplug / plug the drive back in and the OSBoot and Media partitions should both mount to the desktop. When (if) they do, see if you can click through the finder and see the System/Library/CoreServices/boot.efi file on your OSBoot partition.Also, in the terminal, if you type "cd /Volumes" and then do an "ls" you should see the "MAC" volume (your Intel Mac) and the other Volumes of which OSBoot 1 is in the list for me, maybe something else for you.

    ReplyDelete
  16. Ok I'm still having a problem, when is a good time to find you online to be able to chat with you?

    ReplyDelete
  17. Beau, followed your tips here and all work except when you copy over the OS.dmg. Changes partition name from OSBoot to disk1s2 and will not mount. Any suggestions?

    ReplyDelete
  18. I found a good resource that has aided me in a complete factory restore where everything works, including the recovery partition. It's not the best organized article, but it does work if you follow it precisely.http://code.google.com/p/atv-bootloader/wiki/ATVBackup

    ReplyDelete

Post a Comment

Popular posts from this blog

Convert a LiveCycle Form back to an Acrobat Form

Converting a MySQL database to SQLite on a Mac