Backup your original Hard Drive

From AwkwardTV
Revision as of 22:56, 14 July 2007 by Elwood (talk | contribs) (Undo revision 3509 by Special:Contributions/AjpKxs (User talk:AjpKxs))
Jump to: navigation, search

<Google>WIKI</Google>

The Phoem method may be superceded by Engadget's. Please consider doing a complete ~40GB backup of your original drive.

Phoem's Fast DD Method (OS X)

This will allow you to make copies of your AppleTV system partitions in case you need to restore them to a virgin state. This has only been tested on MacOS X.

NOTE: These instructions assume /dev/disk2 is your AppleTV drive.

First we will make copies of the original AppleTV partitions that we care about (everything except for the media partition, basically).

Lets copy the partitions onto your local drive:

dd if=/dev/disk2 of=Partition.img bs=1024k count=100
dd if=/dev/disk2s1 of=EFI.img
dd if=/dev/disk2s2 of=OS.img
dd if=/dev/disk2s3 of=OSBoot.img

Now lets put it back in place onto the new drive:

dd if=Partition.img of=/dev/disk2 bs=1024k count=100
dd if=EFI.img of=/dev/disk2s1
dd if=OS.img of=/dev/disk2s2
dd if=OSBoot.img of=/dev/disk2s3

Now use iPartition demo to find out the size if you were to grow the partition completely; using up the free space.
Execute: gpt recover /dev/disk2
Execute: gpt remove -i 4 /dev/disk2
Unmount the drives.
Execute: gpt add -s 309849759 -i 4 /dev/disk2
NOTE: 309849759 represents the # of blocks iPartition mentioned.
Finally, open diskutility and format just the media partition. (erase)

Linux Method

XXX represents your AppleTV 2.5" notebook drive. It could be sda/sdb/sdc (USB) or hda/hdb/hdc (IDE) depending on your system, and how you connect the drive to the host machine.

Execute: dd if=/dev/XXX of=appletv-full-disk.bin bs=1024

This will create a full ~40GB backup of the drive. In the future, we will have to work on manipulating the partition table under linux, given HFS support is missing.

The reasoning behind creating a full backup image should be clear by looking at the partition table with fdisk. The minor partitions are wrapped in one large meta-partition!

Disk /dev/hdc: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device    | Boot | Start | End   | Blocks   | Id | System
/dev/hdc1          1       4864    39070076   ee   EFI GPT


Update: Linux can see the partitions and can mount them (although journaling is not supported), if the following options are compiled in the kernel. (not sure if you need all of them)

Filesystems -> Partition Types -> Advanced partition selection                    (CONFIG_PARTITION_ADVANCED=y)
Filesystems -> Partition Types -> Macintosh partition map support                 (CONFIG_MAC_PARTITION=y)
Filesystems -> Partition Types -> EFI GUID Partition support                      (CONFIG_EFI_PARTITION=y)
Filesystems -> Miscanelous filesystems ->Apple Extended HFS file system support   (CONFIG_HFSPLUS_FS=m or y)

Linux Method With Compression

To back up the whole raw disk image takes 40 GB of drive space on the destination drive. Most of the source disk is empty however.
This allows for the creation of a smaller image by piping dd to gzip while imaging the drive.

dd if=/dev/sdc bs=1024 | gzip > wholedrive.img.gz

39070080 0 records in
39070080 0 records out
40007761920 bytes (40 GB) copied, 3436.62 seconds, 11.6 MB/s

Note: This will take about an hour depending on your machine!

In the end, this results in a file that's about 2.4GB on the destination disk. Not a bad compression ratio!

Update: dd if=/dev/sdc bs=1024 | bzip2 -9 > wholedrive.img.bz2 Will take approx twice as long, and result in a 2.2GB file. FYI.

Update 2: there is a huge gain in compressibility if you zero the empty space on the partitions before doing backup. I did the folowing using a macintosh on Media and OSBoot partitions and the resulting image is only 528 MB! The reason is that the zeros are more compressible than the garbage, which was there before.

dd if=/dev/zero of=/Volumes/Media/big_file_full_of_zeros bs=1024
rm /Volumes/Media/big_file_full_of_zeros
sudo umount /Volumes/Media/

Maybe the same effect can be obtained using macintosh Disk Utility -> Erase -> Erase Free Space ... -> Zero Out Deleted Files