Difference between revisions of "Apple TV repair"
(One intermediate revision by the same user not shown) | |||
Line 115: | Line 115: | ||
====Using an image from another ATV==== | ====Using an image from another ATV==== | ||
− | Before I tried [[Replacing corrupted recovery OS with one from Apple]], I was desperate, so I downloaded an image of somebody else's ATV, the first 2GB of a 2.0.2 system, and copied it onto my hd. It started with a curious linux penguin splash screen, then I did a factory restore. Although it copied only the first 2 GB, it still had a partition table that thought the disk ended at 40GB, so the Media capacity is only 32GB. I removed the Media partition (4) and replaced it with one that fit the empty space. Then I (too hastily) put the drive in the ATV. No matter what I did, factory reset to running diagnostics, the ATV still showed only 32GB capacity. | + | Before I tried [[#Replacing corrupted recovery OS with one from Apple]], I was desperate, so I downloaded an image of somebody else's ATV, the first 2GB of a 2.0.2 system, and copied it onto my hd. It started with a curious linux penguin splash screen, then I did a factory restore. Although it copied only the first 2 GB, it still had a partition table that thought the disk ended at 40GB, so the Media capacity is only 32GB. I removed the Media partition (4) and replaced it with one that fit the empty space. Then I (too hastily) put the drive in the ATV. No matter what I did, factory reset to running diagnostics, the ATV still showed only 32GB capacity. |
I removed the drive, and did what I neglected to do the first time, after resizing the partition with gpt—Make a new volume, journaled HFS+, that fills the partition: | I removed the drive, and did what I neglected to do the first time, after resizing the partition with gpt—Make a new volume, journaled HFS+, that fills the partition: | ||
Line 138: | Line 138: | ||
I might replace the OS.dmg in my old recovery volume with one from the other ATV, assuming this other recovery OS.dmg is not corrupted like the first. | I might replace the OS.dmg in my old recovery volume with one from the other ATV, assuming this other recovery OS.dmg is not corrupted like the first. | ||
+ | |||
+ | Solder a power switch onto the cord, so I don't have to unplug, with accompanying spark, to shut down/start up. | ||
==References== | ==References== |
Latest revision as of 20:03, 30 October 2011
Contents
Structure of an Apple TV hard disk.
Apple TV, 1st generation, is an Intel mac running a special version of OS 10.4. The hard disk uses a GUID partition table (GPT), with four partitions:
- EFI
- The firmware updates when necessary.
- Apple Recovery
- The factory fresh version of the OS, used in Factory Restore.
- OSBoot
- The system software.
- Media
- The media.
This is what the whole disk looks like: Original ATV disk:
start size index contents 0 1 PMBR 1 1 Pri GPT header 2 32 Pri GPT table 34 6 40 69632 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B 69672 819200 2 GPT part - 5265636F-7665-11AA-AA11-00306543ECAC 888872 1843200 3 GPT part - 48465300-0000-11AA-AA11-00306543ECAC 2732072 75408048 4 GPT part - 48465300-0000-11AA-AA11-00306543ECAC 78140120 7 78140127 32 Sec GPT table 78140159 1 Sec GPT header
#: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *40.0 GB disk2 1: EFI 35.7 MB disk2s1 2: Apple_Recovery 419.4 MB disk2s2 3: Apple_HFS OSBoot 943.7 MB disk2s3 4: Apple_HFS Media 38.6 GB disk2s4
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.
I used Disk Utility to make images of OSBoot and Media, the two partitions that are HFS+ format. This way I can restore either to a larger partition easily.
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. Please note that many of these methods are experimental, have not worked. I found out late that perhaps the problem was a corrupted factory restore image, but that doesn't mean that was the only problem with these methods.
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. Holding MENU and - on the remote restarted, but then, after long flashing amber light, the ATV put some text on the screen indicating an input/output error. Twice.
So I took the disk out and connected it to my G5, and copied the recovery volume back onto the disk.
dd if=/path/to/recoverypartition of=/dev/disk_DISK_NUMBER_ bs=1m
Then I returned it to the ATV, and powered up, while holding MENU and - on the remote. Flashing yellow, Apple symbol...Minutes later, language selection. Resolution selection, then a menu of startup choices (restart, diagnostics, factory restore). This time I went straight to Factory Restore. ATV restarted, flashed yellow for several seconds. Then language selection, resolution selection. I plugged in the ethernet..."Connecting to network..." Apple symbol. Splash screen. "Connect to iTunes" keeps flashing on for two seconds alternating with the Apple symbol. It's not showing up in my iTunes screen on my computer. I click the menu button on the remote and now it's back to alternating between the frontrow menu and the Apple symbol. Redoing factory restore by holding MENU and - on the remote. Restore process completed again. This time I'm going to try it in 720p, just for fun. It showed up in iTunes just for a second, then went back to that alternating Apple logo, each time changing the iTunes pairing code. AAARGH!
I have some suspicions. Either OSBoot has something bad on it that survives the factory restore; or the EFI partition is not properly representing the disk, and this is confusing; or the Media volume has something confusing on it.
I try restarting and running diagnostics three times, then restart. Same problems.
New suspicion: I am working with a copy of the messy original drive. Maybe I should make a copy of its repaired self, since I repaired it in the middle of this process.
I might also try duplicating the OSBoot partition also onto the new disk, and asking gpt to recover itself.
Another suspicion (Maybe there should be a section for these): I created some of the volumes as a user, not the root. This seems far-fetched.
Replacing corrupted recovery OS with one from Apple
When you normally update the Apple TV software, the ATV gets a disk image from Apple that contains the updated OS. According to the guide at http://code.google.com/p/atv-bootloader/wiki/ATVBackup you can replace the image normally used for Factory Restore, on the recovery drive, with this image of the updated OS. Then asking for a factory restore will introduce this as the default OS.
- Get the image from Apple: http://mesu.apple.com/data/OS/061-7495.20100210.TAVfr/2Z694-6013-013.dmg
- Temporarily change the partition type of the recovery partition on the new disk to hfs+ (no journaling).
- Mount that partition.
- Mount the image downloaded from Apple.
- Replace OS.dmg in the recovery volume with our OS.dmg from the download from Apple.
- Change the recovery partition back to recovery format.
- Put the drive back in the ATV.
Using an image from another ATV
Before I tried #Replacing corrupted recovery OS with one from Apple, I was desperate, so I downloaded an image of somebody else's ATV, the first 2GB of a 2.0.2 system, and copied it onto my hd. It started with a curious linux penguin splash screen, then I did a factory restore. Although it copied only the first 2 GB, it still had a partition table that thought the disk ended at 40GB, so the Media capacity is only 32GB. I removed the Media partition (4) and replaced it with one that fit the empty space. Then I (too hastily) put the drive in the ATV. No matter what I did, factory reset to running diagnostics, the ATV still showed only 32GB capacity.
I removed the drive, and did what I neglected to do the first time, after resizing the partition with gpt—Make a new volume, journaled HFS+, that fills the partition:
newfs_hfs -J -v Media /dev/disk_DISK_NUMBER_4 #For example /dev/disk1s4
Put it back in—YAY—This is the first time I've seen "Capacity 144.75 GB" on my About page. Caveat:This destroys the Media volume, which contains data that syncs with iTunes. That means that iTunes will not recognize this as your old ATV, and you'll need to set it up again.
Now to see if I can update...Si yo puedo.
Retrieving the old settings, so iTunes thinks this is the same ATV
If you make a new Media volume, or use someone else's then your iTunes will not recognize this as the same ATV, and you will have to remake all your sync settings. If you've made complicated settings for podcasts, or have a system that is keeping track of what you've already watched, you'll regret this.
I propose using Disk Utility's restoration to restore the data from my old Media volume to the new one:
- Make an image of the Media volume on the old drive using Disk Utility.
- (optional)Make a copy of that image since the next step is going to alter the image, and you might want the raw image for some reason.
- Scan the image for restore in Disk Utility.
- Restore the image to the Media volume on the new drive. This won't work, because asr, the program that does the restoring, messes with the partitions, making the EFI partition much larger.
Proposal 2, make a new filesystem Media on partition 4, then rsync the files from the old disk to the new, or use carbon copy cloner.
To do list
I would like to try to replace the OS.dmg in the recovery volume with the most recent OS. That way, after a factory restore, there'd be no updating to do.
I might replace the OS.dmg in my old recovery volume with one from the other ATV, assuming this other recovery OS.dmg is not corrupted like the first.
Solder a power switch onto the cord, so I don't have to unplug, with accompanying spark, to shut down/start up.
References
This guide is not too complicated, and it worked for me, just not from my corrupted original drive, but from an image of somebody else's first 2GB: http://guides.macrumors.com/Apple_TV_250GB_Hard_Drive_Upgrade
This guide is more informative:http://wiki.awkwardtv.org/wiki/Prepare_a_Hard_Drive#Optional:_Hacking_the_Recovery_Image
Squeeee! Pictures! But this guide seems fixated on those Spotlight files, maybe because they can get quite large:http://www.engadget.com/2007/03/23/how-to-upgrade-the-drive-in-your-apple-tv/
More pictures:http://www.macworld.com/article/57079/2007/03/appletvharddrive.html
- dd
- The disk duplicator utility is excellent for copying data from and to disks verbatim. You should unmount disks before use so that the disk isn't changed in the middle of a copy. Use a large blocksize to speed copies, with the -bs switch, e.g. "bs=1m". The blocksize, in bytes, changes how much is copied into memory, which buffers reads and writes. The larger the buffer, the faster large transfers. bs can take numbers and popular suffixes, like k and m. The actual blocks on the disks are probably 512b, but that has no relation to dd's settings.
- Remote
- This iOS app controls iTunes and ATV libraries, recently through Home Sharing. Read about how to pair your iOS device with ATV at the Apple guide:http://support.apple.com/kb/HT1947