Search this blog ...

Sunday, October 11, 2009

instructions on how to create customized recovery image (recovery.dmg) directly from Apple TV

Apple TV rocks, but I don't have the finances to purchase an Apple computer. So how did I get NitoTV fully installed on a 2.0.2 firmware released Apple TV with all the bells and whistles with only a Windows machine at my disposal?

The answer was essentially to do everything directly from the Apple TV.

If a version 1 OS.dmg is contained within the recovery image file (recovery.dmg) in the ~/Documents folder, NitoTV should be able to install/unlock all the useful bits and pieces like AFP support on the Apple TV.

The version 1 OS.dmg is available on the original Apple TVs with 1.0 firmware/backup partition. For subsequent released Apple TVs, the OS.dmg on the backup partition is a stripped down version missing key pieces.

--- CUT ---

The notes below refer to my Apple TV which is setup on my local network with IP address 192.168.1.100.

ssh frontrow@192.168.1.100

password: frontrow


Welcome to the AppleTV (via atv-usbcreator)
$ id
uid=501(frontrow) gid=501(frontrow) groups=501(frontrow), 79(appserverusr), 80(admin), 81(appserveradm)

$ diskutil list
/dev/disk0
#: type name size identifier
0: GUID_partition_scheme *37.3 GB disk0
1: EFI 34.0 MB disk0s1
2: Apple_Recovery 400.0 MB disk0s2
3: Apple_HFS OSBoot 900.0 MB disk0s3
4: Apple_HFS Media 35.8 GB disk0s4


$ cd /Volumes

$ ls
OSBoot

$ mkdir Recovery

$ sudo mount -t hfs /dev/disk0s2 /Volumes/Recovery/
Password: frontrow

$ cd /Volumes/Recovery/

$ ls -la
total 360552
drwxrwxr-t 10 root admin 442 Apr 8 2008 .
drwxrwxrwt 4 root admin 136 Sep 2 10:13 ..
d-wx-wx-wt 2 root admin 68 Apr 8 2008 .Trashes
-rw-r--r-- 1 root wheel 45590 Feb 17 2007 BootLogo.png
-rw-r--r-- 1 root admin 1024 Apr 8 2008 Desktop DB
-rw-r--r-- 1 root admin 2 Apr 8 2008 Desktop DF
-rw-rw-r-- 1 root wheel 177099888 Apr 8 2008 OS.dmg
-rw-r--r-- 1 root wheel 298800 Feb 17 2007 boot.efi
-rw-r--r-- 1 root admin 520 Apr 8 2008 com.apple.Boot.plist
-rw-r--r-- 1 root wheel 7138931 Apr 8 2008 mach_kernel.prelink

$ md5 OS.dmg
MD5 (OS.dmg) = 30c4e468d235fb809acf9fb75c09b35f

Note the OS.dmg MD5 hash above matches the 2.0.2 firmware:-

1.0.0 (md5: 55b909196952ff72c93aaf3553cf661e)
1.1.0 (md5: e1cbe29ea136e0a34de09e0144bb5505)
2.0.2 (md5: 30c4e468d235fb809acf9fb75c09b35f)
2.1.0 (md5: 2783d7c2b27d8364bac3bde9de9d5287)

Thus, my Apple TV has a 2.0.2 firmware on the recovery partition. If I were to do a factory restore on my Apple TV, it would be thus running 2.0.2 software.

Recall, NitoTV requires a version 1.0 OS.dmg file to get AFP!

$ hdiutil imageinfo OS.dmg
Backing Store Information:
URL: file://localhost/mnt/Scratch/Volumes/Recovery/OS.dmg
Class Name: CUDIFEncoding
Name: OS.dmg
Backing Store Information:
URL: file://localhost/mnt/Scratch/Volumes/Recovery/OS.dmg
Class Name: CBSDBackingStore
Name: OS.dmg
Class Name: CUDIFDiskImage
Properties:
Kernel Compatible: true
Software License Agreement: false
Encrypted: false
Partitioned: true
Checksummed: true
Compressed: true
Segments:
0: /mnt/Scratch/Volumes/Recovery/OS.dmg
Format: UDZO
Checksum Value: $BD12CFED
udif-ordered-chunks: true
Format Description: UDIF read-only compressed (zlib)
Checksum Type: CRC32
Partition Information:
-1:
Checksum Type: CRC32
Name: Driver Descriptor Map (DDM : 0)
Checksum Value: $F57C291C
Partition Number: -1
0:
Checksum Type: CRC32
Name: Apple (Apple_partition_map : 1)
Checksum Value: $335717A6
Partition Number: 0
2:
Checksum Type: CRC32
Name: (Apple_Free : 3)
Checksum Value: $00000000
Partition Number: 2
1:
Checksum Type: CRC32
Name: disk image (Apple_HFS : 2)
Checksum Value: $935C81CE
Partition Number: 1
partitions:
partitions:
0:
partition-hint: DDM
partition-start: 0
partition-data: {length = 512, capacity = 512, bytes = 0x4552020000156dd20000000000000000 ... 0000000000000000}
partition-length: 1
partition-name: Driver Descriptor Map
partition-synthesized: true
1:
partition-hint: Apple_partition_map
partition-start: 1
partition-number: 1
partition-length: 63
partition-name: Apple
2:
partition-hint: Apple_HFS
partition-start: 64
partition-number: 2
partition-length: 1404296
partition-filesystems:
HFS+:
partition-name: disk image
3:
partition-hint: Apple_Free
partition-start: 1404360
partition-length: 10
partition-name:
partition-synthesized: true
block-size: 2
burnable: true
partition-scheme: Apple
Size Information:
Compressed Bytes: 176991022
Total Bytes: 719037440
Total Empty Bytes: 293822976
CUDIFEncoding-bytes-wasted: 0
Sector Count: 1404370
CUDIFEncoding-bytes-total: 176991022
CUDIFEncoding-bytes-in-use: 176991022
Compressed Ratio: 0.41623871007360652
Total Non-Empty Bytes: 425214464
Resize limits (per hdiutil resize -limits):
1404296 1404296 34359738368


$ sudo umount /Volumes/Recovery

Per: http://wiki.awkwardtv.org/wiki/NitoTV_Take_2
From version 0.6.4 onwards, Smart Installer will now grab the 10.4.9 Combo update and place it in the ~/Documents folder automatically
NitoTV can also setup AFP, so long as a version 1 OS.dmg is contained within the recovery image file in the ~/Documents folder.

$ cd

$ pwd
/Users/frontrow/Documents

-bash-2.05b$ ls -la
total 631104
drwxr-xr-x 5 frontrow frontrow 170 Sep 2 01:49 .
drwxr-xr-x 19 frontrow frontrow 646 Sep 2 02:04 ..
-rw-r--r-- 1 frontrow frontrow 323119366 Nov 19 2008 MacOSXUpdCombo10.4.9Intel.dmg

$ md5 MacOSXUpdCombo10.4.9Intel.dmg
MD5 (MacOSXUpdCombo10.4.9Intel.dmg) = 2c579f52ad69d12d95ea82ee3d9c4937

As our recovery partition is 2.0.2 based, we need to create a customized recovery image with the OS.dmg based on a v1 Apple TV (rather than just a straight dd of the recovery partition).

$ sudo mount -uw /
$ sudo touch /.readwrite

the mount -uw and /.readwrite steps aren't necessary if you have already performed them in the past.


$ cd ~/Documents

get a copy of our 202 recovery partition as an image

$ sudo dd if=/dev/disk0s2 of=recovery_original.dmg bs=1m

here is some info on the image created

$ hdiutil imageinfo recovery_original.dmg
Backing Store Information:
URL: file://localhost/mnt/Scratch/Users/frontrow/Documents/recovery_original.dmg
Class Name: CBSDBackingStore
Name: recovery_original.dmg
Class Name: CRawDiskImage
Properties:
Kernel Compatible: true
Software License Agreement: false
Encrypted: false
Partitioned: false
Checksummed: false
Compressed: no
Segments:
0: /mnt/Scratch/Users/frontrow/Documents/recovery_original.dmg
Format: UDRW
Checksum Value:
Format Description: raw read/write
Checksum Type: none
partitions:
partitions:
0:
partition-hint: Apple_HFS
partition-start: 0
partition-length: 819152
partition-filesystems:
HFS+:
partition-name: whole disk
partition-synthesized: true
block-size: 512
burnable: false
partition-scheme: none
Size Information:
Compressed Ratio: 1
Compressed Bytes: 419405824
Sector Count: 819152
Total Empty Bytes: 0
Total Non-Empty Bytes: 419405824
Total Bytes: 419405824
Resize limits (per hdiutil resize -limits):
450864 819152 34359738368


Note, the format is UDRW - meaning read/write - so we don't need to convert it to RW for editing
(otherwise, we would have had to do something like: hdiutil convert -format UDRW -o dest-rw.dmg source.dmg
- refer to http://dx4.org/linux/modifydmg.html regarding modifying read-only .dmg files.
)

Note, The OS.dmg contained within this image however is an image of format type: UDIF read-only compressed (zlib),
so if we wanted to mount it and modify the contents, we would need to convert to RW first!


Work from a clone of the image (don't modify the original); also note, NitoTV looks for a file named recovery.dmg
$ cp recovery_original.dmg recovery.dmg


$ ls -la
total 3493792
drwxr-xr-x 9 frontrow frontrow 306 Sep 3 00:04 .
drwxr-xr-x 19 frontrow frontrow 646 Sep 2 02:04 ..
-rw-r--r-- 1 frontrow frontrow 323119366 Nov 19 2008 MacOSXUpdCombo10.4.9Intel.dmg
-rw-r--r-- 1 frontrow frontrow 419405824 Sep 2 20:40 recovery.dmg
-rw-r--r-- 1 root frontrow 419405824 Sep 2 20:37 recovery_original.dmg


note hdiutil mount/attach do the same thing!
mount the image
$ hdiutil mount recovery.dmg
/dev/disk1 /Volumes/Recovery 1


$ diskutil list
/dev/disk0
#: type name size identifier
0: GUID_partition_scheme *37.3 GB disk0
1: EFI 34.0 MB disk0s1
2: Apple_Recovery 400.0 MB disk0s2
3: Apple_HFS OSBoot 900.0 MB disk0s3
4: Apple_HFS Media 35.8 GB disk0s4
/dev/disk1
#: type name size identifier
0: Recovery *400.0 MB disk1



$ mount
/dev/disk0s3 on / (local, journaled)
devfs on /dev (local)
fdesc on /dev (union)
on /.vol
/dev/disk0s4 on /mnt (local, journaled)
/dev/disk1 on /mnt/Scratch/Volumes/Recovery 1 (local, nodev, nosuid, journaled, mounted by frontrow)


$ cd /Volumes/Recovery\ 1/


$ pwd
/Volumes/Recovery 1


$ ls -la
total 360552
drwxrwxr-t 10 frontrow frontrow 442 Apr 8 2008 .
drwxrwxrwt 5 root admin 170 Sep 3 00:38 ..
d-wx-wx-wt 2 frontrow frontrow 68 Apr 8 2008 .Trashes
-rw-r--r-- 1 frontrow frontrow 45590 Feb 17 2007 BootLogo.png
-rw-r--r-- 1 frontrow frontrow 1024 Apr 8 2008 Desktop DB
-rw-r--r-- 1 frontrow frontrow 2 Apr 8 2008 Desktop DF
-rw-rw-r-- 1 frontrow frontrow 177099888 Apr 8 2008 OS.dmg
-rw-r--r-- 1 frontrow frontrow 298800 Feb 17 2007 boot.efi
-rw-r--r-- 1 frontrow frontrow 520 Apr 8 2008 com.apple.Boot.plist
-rw-r--r-- 1 frontrow frontrow 7138931 Apr 8 2008 mach_kernel.prelink

$ md5 OS.dmg
MD5 (OS.dmg) = 30c4e468d235fb809acf9fb75c09b35f

remove the v202 copy, we will be replacing with a v1
$ rm OS.dmg


*****************************************************************
Obtain and upload the v1 OS.dmg file to the Apple TV :-

e.g. join the following two files together (fix the "xxx" first, then unzip)
inside you will find a file named OS-dot-DMG 1.0.dmg with MD5 55b909196952ff72c93aaf3553cf661e
this is the v1 OS.dmg we are after (rename it to OS.dmg)

rapidshare.xxx/files/166624209/OS-dot-DMG_1.0.dmg.MD.zip.001
rapidshare.xxx/files/166628115/OS-dot-DMG_1.0.dmg.MD.zip.002

sftp as user frontrow the v1.0 OS.dmg file

cd "/Volumes/Recovery 1"

mput OS.dmg
*****************************************************************


$ md5 OS.dmg
MD5 (OS.dmg) = 55b909196952ff72c93aaf3553cf661e


$ hdiutil imageinfo OS.dmg
Backing Store Information:
URL: file://localhost/mnt/Scratch/Volumes/Recovery%201/OS.dmg
Class Name: CUDIFEncoding
Name: OS.dmg
Backing Store Information:
URL: file://localhost/mnt/Scratch/Volumes/Recovery%201/OS.dmg
Class Name: CBSDBackingStore
Name: OS.dmg
Class Name: CUDIFDiskImage
Properties:
Kernel Compatible: true
Software License Agreement: false
Encrypted: false
Partitioned: true
Checksummed: true
Compressed: true
Segments:
0: /mnt/Scratch/Volumes/Recovery 1/OS.dmg
Format: UDZO
Checksum Value: $DACE2662
udif-ordered-chunks: true
Format Description: UDIF read-only compressed (zlib)
Checksum Type: CRC32
Partition Information:
-1:
Checksum Type: CRC32
Name: Driver Descriptor Map (DDM : 0)
Checksum Value: $5C4AABFF
Partition Number: -1
0:
Checksum Type: CRC32
Name: Apple (Apple_partition_map : 1)
Checksum Value: $0EA9B196
Partition Number: 0
2:
Checksum Type: CRC32
Name: (Apple_Free : 3)
Checksum Value: $00000000
Partition Number: 2
1:
Checksum Type: CRC32
Name: disk image (Apple_HFS : 2)
Checksum Value: $F8E3B513
Partition Number: 1
partitions:
partitions:
0:
partition-hint: DDM
partition-start: 0
partition-data: {length = 512, capacity = 512, bytes = 0x45520200001825b20000000000000000 ... 0000000000000000}
partition-length: 1
partition-name: Driver Descriptor Map
partition-synthesized: true
1:
partition-hint: Apple_partition_map
partition-start: 1
partition-number: 1
partition-length: 63
partition-name: Apple
2:
partition-hint: Apple_HFS
partition-start: 64
partition-number: 2
partition-length: 1582440
partition-filesystems:
HFS+:
partition-name: disk image
3:
partition-hint: Apple_Free
partition-start: 1582504
partition-length: 10
partition-name:
partition-synthesized: true
block-size: 2
burnable: true
partition-scheme: Apple
Size Information:
Compressed Bytes: 207346057
Total Bytes: 810247168
Total Empty Bytes: 293618176
CUDIFEncoding-bytes-wasted: 0
Sector Count: 1582514
CUDIFEncoding-bytes-total: 207346057
CUDIFEncoding-bytes-in-use: 207346057
Compressed Ratio: 0.40134345383388781
Total Non-Empty Bytes: 516628992
Resize limits (per hdiutil resize -limits):
1582440 1582440 34359738368



unmount / detach; note make sure not in the Recovery\ 1 directory, otherwise get error 49153

$ cd ~/Documents

$ hdiutil detach /mnt/Scratch/Volumes/Recovery\ 1
"disk1" unmounted.
"disk1" ejected.

No comments:

Post a Comment