Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I managed to broke something on my iMac's internal HD. I have now done a successful restore using DiskDrill, but just in case I want to make an exact copy of the internal HD. Not just some partition, but everything, even "free" disk space.

I have tried creating a disk image with Disk Utility and CCC, but they both seemed to clone the only working and empty partition, not the free space where all my data is.

I should also mention, the internal HD is 1TB, and the external one where I planned to put the disk image is 2TB with some (about 150GB) used space.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

If you are comfortable using the command line, you could use dd to copy your drive byte-for-byte. First, you need to find the BSD identifier for your internal drive. If you are booted from the drive, this will be disk0. Otherwise, it is most likely disk1, but you should run the following command to see all of your disks and the partitions they contain.

diskutil list

Once you have determined the identifier, you need to determine the exact size of the drive. Run the following command, replacing N with the proper number.

diskutil info diskN

About halfway through the information shown, find the Total Size. Find the size in 512-byte blocks.

I will assume you want to clone your drive as a file on your external disk. With the disk plugged in, run the following command. N is the disk's identifier number, EXTERNAL DRIVE is the name of the external partition (you can use the tab key to complete this automatically, clone.hdraw is the name of the file you are writing to, and XXXXX is the number of blocks on your internal drive.

dd if=/dev/diskN of="/Volumes/EXTERNAL DRIVE/clone.hdraw" bs=512 count=XXXXX

Notes:
This will copy the drive 512 bytes at a time, which means it will be slow. You can copy faster using a larger block size by increasing the bs argument and decreasing the count argument, but make sure that you are copying an exact number of blocks and that the product of the two remains the same (if you double the block size, the count must be half).

This will create a new file on your external drive, but it will not be mountable as a disk image. It is just a binary file containing the raw data from your drive. You can use this file to restore your drive by switching the if and of arguments.

If you want to copy to another disk instead of to a file, you can change the of argument to a different /dev/diskM. This would replace any partitions already on the other drive with the partitions from your internal drive. This is not recommended if your drive uses a GUID partition table (if you have an Intel mac), since the unique partition identifiers would also be copied, and therefore no longer be unique.

share|improve this answer
    
Thanks for the great and clear explanation! I multiplied the bs by 16 which was the largest I could go keeping the count an even number. I have one question though: When this is done and before I erase the internal drive, how can I confirm that everything worked? (Don't have room to unpack it again) Should I cancel, create a 1TB partition and write directly to it instead, so that I can analyze it with DiskDrill? –  Johannes Lund Aug 9 '12 at 19:47
    
@Johannes Since you are copying a drive and not a partition, that probably wouldn't work. The data you are copying starts with the partition table instead of a file system. You could try copying it into a free space on your drive instead of a partition, but unless the command comes up with an error you shouldn't need to worry. –  ughoavgfhw Aug 9 '12 at 22:06
    
@ughoavgfhw: Sounds great! Is there a way to do this and skip the free space? Does it make sense? I want to clone my partition, but I don't need to copy 250GB of free space... I have about 250GB of data/applications/preferences/etc. on a 500GB HD. My external HD is 320GB. Thanks in advance! –  Dror Nov 8 '12 at 21:26
    
@Dror No, there isn't. dd doesn't know anything about the filesystem, so it can't tell what's free and what isn't. This answer was specifically for the case that the filesystem is corrupted so everything appears "free". If your filesystem still works, you can just use a backup tool or Disk Utility. –  ughoavgfhw Nov 8 '12 at 22:41

SuperDuper is considered by many to be the go-to disk imaging utility for OS X, and a vital part of a good system backup routine. For example, see John Gruber's (DaringFireball.net) backup regimen. It costs $27.94, and I've found it to be well-worth the money.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.