AppleTV: How to force a Factory Restore via SSH

Posted February 27th, 2010 in Tech by Scott Forbes

Allegedly it’s now super easy to install Boxee on your AppleTV — I say “allegedly” because I spent a couple of hours yesterday recovering from a failed install, which left my AppleTV with no video, no menus, and no Boxee. The box just looped through displaying the Apple logo, followed by a blank screen, followed by “No Signal,” followed by a blank screen, indefinitely.

I tried holding down Menu and Minus on the remote, to reboot the AppleTV and bring up the diagnostic menu, to no avail: Nothing would come up on the screen. (I also tried blindly pressing “Down, Down, OK” on the remote, in the hopes that I just couldn’t see the diagnostic menu, but that didn’t work either.) I could SSH into the AppleTV, so at least that part of the Boxee install succeeded — and the AppleTV was showing up and syncing in iTunes, so I wasn’t stuck in a loop of rebooting over and over.

I wasted a lot of time Googling for solutions — which, to be fair, provided some useful information about the AppleTV’s disk partitions, how it does a Factory Restore, etc., but also provided a lot of outdated info. Several pages began with “first, download this disk image from mesu.apple.com” and then linked to an image that’s no longer there; others provided useful instructions on how to backup your AppleTV disk, which would have been good advice to follow before trying to install Boxee, but didn’t help with recovery.

So, for posterity, here’s how I forced my AppleTV to re-load its factory settings when all I had was the ability to SSH into the box. (I should emphasize here: There are much, much easier ways to restore factory defaults on an AppleTV if you can navigate the menus, or if holding down Menu and Minus on the remote successfully reboots the box into diagnostic mode. What I’m about to describe here is a process for deliberately breaking the operating system on the AppleTV’s OSBoot partition, which forces the box into recovery mode; this is not for the faint of heart, I’m not responsible for what happens to your AppleTV if you try it, and heaven help you if you run these commands on your Mac.)

The AppleTV’s hard drive is partitioned into four volumes: EFI, Recovery, OSBoot and Media. The AppleTV boots to the EFI partition first, which in turn tries to mount OSBoot and launch the operating system. In my scenario OSBoot is mounting and booting successfully, but something has corrupted the AppleTV Finder (or some other mission-critical app) and so we can’t get to the menus.

The solution here is to render the OSBoot partition unbootable, which causes the EFI partition to go into recovery mode and offer up the Factory Restore option from its own menus. While there are many exciting ways to render an operating system unbootable, I went with a simple one: Renaming mach.sym (and, for good measure, mach_kernel.prelink) so the OS couldn’t find its kernel.

So, here’s what I did to achieve a factory restore of my AppleTV from the Terminal prompt. Text that I typed is in italics.

YourMac:~ you$ ssh frontrow@appletv.local
frontrow@appletv.local's password: frontrow
Last login: Fri Feb 26 22:55:22 2010
-bash-2.05b$ sudo mv /mach.sym /bad.mach.sym
Password: frontrow
-bash-2.05b$ sudo mv /mach_kernel.prelink /bad.mach_kernel.prelink
-bash-2.05b$ sudo shutdown -r now

The shutdown command reboots the AppleTV and logs you out; when the box comes back up you won’t be able to SSH into it anymore, but (at least in my case) it came up with the “select your language” menu, followed by a menu that contained the factory restore option. (For what it’s worth, I also had to unplug and re-plug the HDMI cable to get my AppleTV fully working again.) After the factory restore I had to do the usual steps to get the AppleTV back on my wireless network, connected to iTunes, etc., but once all was said and done my AppleTV is back to normal.

I might have another run at installing Boxee, but I think I’ll give it a week or two; honestly, if Viacom got their act together and allowed me to subscribe to Comedy Central via iTunes — or even just allowed me to buy a season of The Daily Show for less than the cost of basic cable — I wouldn’t bother. Anyhow, if I do try again I’ll at least have these last-ditch instructions for doing a factory restore written down.