{"id":847,"date":"2012-05-29T16:31:34","date_gmt":"2012-05-29T08:31:34","guid":{"rendered":"http:\/\/www.computersolutions.cn\/blog\/?p=847"},"modified":"2012-05-29T16:31:34","modified_gmt":"2012-05-29T08:31:34","slug":"how-to-fix-an-apple-tv-gen-1-with-a-broken-hard-drive-from-scratch","status":"publish","type":"post","link":"https:\/\/www.computersolutions.cn\/blog\/2012\/05\/how-to-fix-an-apple-tv-gen-1-with-a-broken-hard-drive-from-scratch\/","title":{"rendered":"How to fix an Apple TV Gen 1 with a broken Hard Drive (from scratch)"},"content":{"rendered":"<p>One of my clients had a non-working AppleTV Gen 1 edition (the white not quite Mac Mini one).<br \/>\nThe Hard disk had died, so we needed to get a new OS on there.<\/p>\n<p>While there are plenty of write-ups about upgrading them, I couldn&#8217;t find any clear instructions on starting from scratch.  The closest I found was at the OpenElec forums within their upgrade script, so I used their drive partitioning as a baseline, then worked out how to go from there.<\/p>\n<p>After a few hours of trial and error last night and today, I finally got to the point where I had a working drive, and could replicate the repair process from scratch.  <\/p>\n<p>Without further ado, here&#8217;s my instructions:<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>How to create a new working Apple TV Storage device for replacing an internal drive.<\/p>\n<p>You&#8217;ll need:<\/p>\n<p>1) atv_restore.tar.gz &#8211; chewitt.openelec.tv\/atv_restore.tar.gz<br \/>\n2) atv_recovery.tar.gz &#8211; chewitt.openelec.tv\/atv_recovery.tar.gz<br \/>\n3) OpenElec files for ATV &#8211; releases.openelec.tv\/OpenELEC-ATV.i386-1.95.4.tar.bz2<br \/>\n4) A new storage device of some kind. 4G is enough, so CF or DOM or similar is suitable.<br \/>\n5) Ability to follow instructions, and use common sense.<br \/>\nIf you lack this, find someone who can assist, and who has these attributes.<br \/>\nNo, I&#8217;m not being facetious either, the operations below are destructive, so someone with a cluestick is preferred.<\/p>\n<p>Ready?<\/p>\n<p>Make a temp work folder.<br \/>\neg<\/p>\n<p>mkdir \/tmp\/atv<br \/>\ncd \/tmp\/atv<\/p>\n<p>Unzip the OpenElec files, and put the SYSTEM, KERNEL, and place into the work folder.<br \/>\nCopy the atv_restore.tar.gz to the work folder.<br \/>\nCopy the atv_recovery.tar.gz to the work folder.<\/p>\n<p>Mount your external drive. All data will be erased on it.<br \/>\n*Take a note of the drive letter*<\/p>\n<p>*Make sure that you have the correct drive letter*<br \/>\n**Double check**<\/p>\n<p>Operations below are destructive, so check once more, all data will be erased on the destination drive.<br \/>\nIn my computer, my new drive has popped up as \/dev\/sdf<\/p>\n<p>Instructions below assume your new drive is \/dev\/sdf<\/p>\n<p>If you are using a different drive letter, amend instructions to your drive letter.<br \/>\nAssuming drive is \/dev\/sdf in the following instructions<\/p>\n<p>****Replace \/dev\/sdf with your drive if your drive is not using \/dev\/sdf*****<\/p>\n<p>#Erase existing partitions\/drive if not currently empty.<br \/>\ndd if=\/dev\/zero of=\/dev\/sdf bs=4 count=1M #Quick hacky partition \/ boot sector eradication, bwahahahahhem.<br \/>\n#Create GPT<br \/>\nparted -s \/dev\/sdf mklabel gpt<br \/>\n#make sure current OS knows *current* drive partition setup (i.e. no partitions, 1 gpt)<br \/>\npartprobe \/dev\/sdf <\/p>\n<p>#Create EFI partition, and set bootable (35M size)<br \/>\nparted -s \/dev\/sdf mkpart primary fat32 40s 69671s<br \/>\nparted -s \/dev\/sdf set 1 boot on <\/p>\n<p>#Create a &#8220;Recovery&#8221; partition (419M size)<br \/>\nparted -s \/dev\/sdf mkpart primary HFS 69672s 888871s<br \/>\nparted -s \/dev\/sdf set 2 atvrecv <\/p>\n<p>#Create OS Boot partition (944MB)<br \/>\nparted -s \/dev\/sdf mkpart primary HFS 888872s 2732071s<\/p>\n<p>#Create Media partition (rest of drive-262145sectors)<br \/>\nDISKSIZE=$(parted -s \/dev\/sdf unit s print | grep Disk | awk &#8216;{print $3}&#8217; | sed s\/s\/\/)<br \/>\nlet SECTORS=&#8221;${DISKSIZE}&#8221;-262145<br \/>\nparted -s \/dev\/sdf mkpart primary ext4 2732072s ${SECTORS}s<\/p>\n<p>#Create SWAP partition<br \/>\nlet SECTORS=&#8221;${SECTORS}&#8221;+1<br \/>\nlet DISKSIZE=&#8221;${DISKSIZE}&#8221;-80<br \/>\nparted -s \/dev\/sdf mkpart primary linux-swap ${SECTORS}s ${DISKSIZE}s<\/p>\n<p>#Update OS with new drive setup<br \/>\npartprobe \/dev\/sdf<\/p>\n<p>#&#8212;&#8211;<\/p>\n<p>#Format Partitions &#8212;-<br \/>\nmkfs.msdos -F 32 -n EFI \/dev\/sdf1 #boot<br \/>\nmkfs.hfsplus -v Recovery \/dev\/sdf2 #recovery<br \/>\nmkfs.hfsplus -J -v OSBoot \/dev\/sdf3 #Linux OS \/ ATV OS \/ OpenElec etc<br \/>\nmkfs.ext4 -b 4096 -L Linux \/dev\/sdf4 #Storage<br \/>\nmkswap \/dev\/sdf5<br \/>\nsync <\/p>\n<p>#&#8212;<br \/>\n#My new _4g_ CF &#8220;HDD&#8221; looks like this:<br \/>\n#<br \/>\n#parted \/dev\/sdf print<br \/>\n#Model: TOSHIBA MK4309MAT (scsi)<br \/>\n#Disk \/dev\/sdf: 4327MB<br \/>\n#Sector size (logical\/physical): 512B\/512B<br \/>\n#Partition Table: gpt<br \/>\n#<br \/>\n#Number Start End Size File system Name Flags<br \/>\n# 1 20.5kB 35.7MB 35.7MB primary boot<br \/>\n# 2 35.7MB 455MB 419MB hfs+ primary atvrecv<br \/>\n# 3 455MB 1399MB 944MB hfs+ primary<br \/>\n# 4 1399MB 4193MB 2794MB ext4 primary<br \/>\n# 5 4193MB 4327MB 134MB linux-swap(v1) primary<br \/>\n#<br \/>\n#&#8212;<\/p>\n<p>#Setup Recovery partition (sdf2) to default factory restore files.<br \/>\nmkdir -p \/mnt\/recovery<br \/>\nfsck.hfsplus -f \/dev\/sdf2<br \/>\nmount -t hfsplus -o rw,force \/dev\/sdf2 \/mnt\/recovery<br \/>\ntar -xzvf atv_restore.tar.gz -C \/mnt\/recovery<br \/>\nchown -R root:root \/mnt\/recovery<\/p>\n<p>#Copy OpenElec files to OSBoot Linux partition (sdf3) SYSTEM, LINUX &#8212;&#8212;&#8211;<br \/>\nmkdir -p \/mnt\/linux<br \/>\nfsck.hfsplus -f \/dev\/sdf3<br \/>\nmount -t hfsplus -o rw,force \/dev\/sdf3 \/mnt\/linux<br \/>\ncp KERNEL \/mnt\/linux<br \/>\ncp SYSTEM \/mnt\/linux<br \/>\numount \/dev\/sdf3<\/p>\n<p>#Redo recovery partition (sdf2) to patchstick defaults now. &#8212;&#8211;<br \/>\n#Copy over recovery.tar.gz files<br \/>\n#update keyword -> bootable<br \/>\n#rename boot script to patchstick.sh<br \/>\n#make executable and own all files as root<br \/>\ntar -xzvf atv_recovery.tar.gz -C \/mnt\/recovery<br \/>\necho bootable > \/mnt\/recovery\/keyword<br \/>\nrm \/mnt\/recovery\/patchstick.sh<br \/>\nmv \/mnt\/recovery\/patchstick.boot \/mnt\/recovery\/patchstick.sh <\/p>\n<p>#Make sure to edit fsck.ext4 \/dev\/sdf3 to fsck.hfsplus \/dev\/sdf3 in default patchstick.sh as this may break our HFSplus partition if we fsck.ext4 it&#8230;<\/p>\n<p>chmod 7777 \/mnt\/recovery\/patchstick.sh<br \/>\nchown -R root.root \/mnt\/recovery<br \/>\numount \/dev\/sdf2<\/p>\n<p>#Setup media partition (\/dev\/sdf4) &#8212;&#8212;<br \/>\nmkdir -p \/mnt\/media<br \/>\nmount \/dev\/sdf4 \/mnt\/media<br \/>\nmkdir -p \/mnt\/media\/.config<br \/>\ntouch \/mnt\/media\/.config\/ssh_enable #I like SSH access as a default.<br \/>\nmkdir -p \/mnt\/media\/.cache<br \/>\nmkdir -p \/mnt\/media\/.xbmc\/userdata<br \/>\numount \/dev\/sdf4<\/p>\n<p>#Prepare for takeoff, er eject drive.<br \/>\nsync<br \/>\neject \/dev\/sdf<\/p>\n<p>&#8212;&#8211;<br \/>\nThis drive can now be mounted in the ATV1, and will boot into OpenElec (after a 1st reboot fsck)<\/p>\n<p>=============<br \/>\n#Amended Boot script for reference ( patchstick.sh )<\/p>\n<p>fsck.hfsplus \/dev\/sdf3 &#038;> \/dev\/null<br \/>\nfsck.ext4 \/dev\/sdf4 &#038;> \/dev\/null<br \/>\nmkdir \/boot<br \/>\nmount \/dev\/sdf3 \/boot<br \/>\nkexec -l \/boot\/KERNEL &#8211;command-line=&#8221;boot=\/dev\/sdf3 disk=\/dev\/sdf4 quiet nosplash&#8221;<br \/>\nkexec -e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of my clients had a non-working AppleTV Gen 1 edition (the white not quite Mac Mini one). The Hard disk had died, so we needed to get a new OS on there. While there are plenty of write-ups about upgrading them, I couldn&#8217;t find any clear instructions on starting from scratch. The closest I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[7,282,25,4],"tags":[408,411,409,412,210,410],"class_list":["post-847","post","type-post","status-publish","format-standard","hentry","category-apple","category-firmware-2","category-technical-mumbo-jumbo","category-useful-info","tag-apple-tv","tag-eden","tag-openelec","tag-painful","tag-restore","tag-xbmc"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/posts\/847","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/comments?post=847"}],"version-history":[{"count":1,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/posts\/847\/revisions"}],"predecessor-version":[{"id":848,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/posts\/847\/revisions\/848"}],"wp:attachment":[{"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/media?parent=847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/categories?post=847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/tags?post=847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}