Tuesday, November 11, 2008

Using dd(1) to copy disks at super-user prompt in Darwin

To binary-level copy one disk to another (including partition, boot record and boot loader data):

1. Boot OSX for interactive Darwin bootloader and use '-s' for single-user mode to get a root prompt (#).

2. Assuming source=disk0 and destination=disk1, issue:
# dd if=/dev/disk0 of=/dev/disk1 bs=4096

Important:
Eliminate confusion by disabling (in BIOS or by unplugging) all irrelevant disks in BIOS before proceeding.

1. If source & dest are mistakenly reversed when dd is run, the source disk will be quietly overwritten. Avoid this.

2. A type of disk signature(s) get copied as well, so that Disk Utility subsequently interprets the two (now identical) disks as having the same partitions names, even if they are manually changed later.

3. dd is not verbose (so issue 'iostat disk0 disk1 &' first, for status).
I saw ~100Gb/hour on my slow SATA-1 drives.

4. After the copy, if both source and dest disks are active in BIOS, Windows XP will get confused (since both disks are named "C:"). Avoid by deactivating one in BIOS before booting XP.

No comments: