Apple TV repair
Backup
I wish I had a backup of my drive before the Apple TV went screwy, but I made a backup of the screwy state anyway. Here's how:
I unplugged the device, then I removed the hard drive. I skipped the hair-dryer step, which was a mistake. iFixit has guides for disassembling the machine: http://www.ifixit.com/Device/Apple_TV_1st_Generation
(Before I attached the drive, I should have turned off Spotlight, so it wouldn't add search folders to two of the volumes).
I attached the drive, via USB <> PATA adapter, to my Mac. I unmounted the volumes on the drives using Disk Utility, which I kept open so that I could repeatedly unmount the drives easily while I worked.
I used gpt to view a snapshot of the partitions as they were. But first I found the name of the disk from Disk Utility by clicking on the drive and getting "Information." Your disk may be in a different slot of the /dev/disk# numbering order:
gpt show /dev/disk1
Then I used dd to copy the entire drive as an image on my hard drive—make sure you have enough room, the ATV drive is at least 40GB. I put it in my Temp folder which I ordered Time Machine to ignore, so it doesn't bother backing up so huge a file.
sudo dd if=/dev/disk1 bs=1m of=~/Temp/appletv-orig.dd
You can press control-T during the execution of dd to see the progress. It took me about two hours to copy this way.
- to be continued
New hard drive
I've tried many different methods to copy what's on the old drive to the new drive. At the very least, supposedly, I need the partitions, with data in the recovery partition copied exactly. With that, "Factory Restore" should put everything back in order.
I've tried online methods:
http://www.engadget.com/2007/03/23/how-to-upgrade-the-drive-in-your-apple-tv/3 . This method balked at the re-addition of the fourth partition after removing it.
Using a G5
Next to try: http://guides.macrumors.com/Apple_TV_250GB_Hard_Drive_Upgrade . I should try it on my G5.
Rebuilding GPT
- Attach the original ATV disk to a Mac.
- Open Terminal
- Find out which disk is the ATV disk. After executing the following command, look for the disk that has volumes called OSBoot and Media. use the number of that disk as _DISK_NUMBER_ in the following instructions. As you're working, make sure to keep track of which disk is which with this command, they can change if you swap/eject them.
diskutil list
- Get the original disk's partition table's exact measurements. First you have to eject or unmount because gpt is prevented from working on the disk when it is mounted.
diskutil eject disk_DISK_NUMBER_ #For example diskutil eject disk8 gpt show disk_DISK_NUMBER_
- Copy from the image, made with dd, of the complete, original ATV drive.
dd if=/path/to/ATV-image-filename of=/dev/disk_DISK_NUMBER_
- Remove partitions 1-4 from the partition table.
gpt remove -i 4 disk_DISK_NUMBER_ diskutil eject disk_DISK_NUMBER_ gpt remove -i 3 disk_DISK_NUMBER_ diskutil eject disk_DISK_NUMBER_ gpt remove -i 2 disk_DISK_NUMBER_ diskutil eject disk_DISK_NUMBER_ gpt remove -i 1 disk_DISK_NUMBER_
- Use gpt add to replace partitions 1-3 with exact copies of the original partition measurements from gpt show, earlier. The -b switch means beginning, so use the number from the right side of the original table, the starting block for this partition. The -s switch means size, so use the number from the size column of the original table. The -t switch means type, so use the type string from the original table.
diskutil eject disk_DISK_NUMBER_ gpt add -b _STARTING_BLOCK_PARTITION_1_ -i 1 -s _PARTITION_SIZE_1_ -t _PARTITION_TYPE_1_ diskutil eject disk_DISK_NUMBER_ gpt add -b _STARTING_BLOCK_PARTITION_2_ -i 2 -s _PARTITION_SIZE_2_ -t _PARTITION_TYPE_2_ diskutil eject disk_DISK_NUMBER_ gpt add -b _STARTING_BLOCK_PARTITION_3_ -i 3 -s _PARTITION_SIZE_3_ -t _PARTITION_TYPE_3_
- Determine the leftover space for partition 4.
diskutil eject disk_DISK_NUMBER_ gpt show disk_DISK_NUMBER_
- Add a partition 4 that fills the rest of the space. Use the numbers from the empty space following partition 3 from gpt show's results.
diskutil eject disk_DISK_NUMBER_ gpt add -b _STARTING_BLOCK_PARTITION_4_ -i 4 -s _PARTITION_SIZE_4_ -t _PARTITION_TYPE_4_
- Use Disk Utility to repair the 4th partition, Media. It will see that the Volume Header's size (old size) doesn't match the partition table size (new size).
- Remove .Spotlight-V100 from Media and OSBoot if they're there. Maybe single-user mode would be best so that automatic interlopers like Spotlight don't mess with our disks.
The first time I tried all this, when I put the new drive in my ATV, it started with the factory original OS, then went into an endless loop of restarts that didn't allow me to get to Factory Reset. The screen would alternate between the startup apple symbol, then the menu, but the menu showed only for a second.
References
http://www.engadget.com/2007/03/23/how-to-upgrade-the-drive-in-your-apple-tv/