Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Make a partition of an exact size for cloning System
It is very difficult to create a disk partition of the exact same size as an existing partition of another disk using Apple's Disk Utility. Whenever I try this, I always find the size of the partition created by Disk Utility is slightly different from the partition I'm trying to clone. Here's a way using the command line that allows you to get the size exactly right.

The standard warning applies: Be very careful. This will wipe the entire disk that you are repartitioning. One small typo could result in the wrong disk being wiped!

Here's how to do it:
  1. Open Terminal, and if your account doesn't have administrator privileges, su to the administrator user.
  2. Type diskutil info /Volumes/partition_to_clone/ to find the size of the partition you want to clone. The output should include something like this:
    Total Size: 74.2 Gi (79682387968 B) (155629664 512-byte blocks)
  3. Note the number of 512-byte blocks, and then add 262144 to that number. Why 262144? Because that amount is added to each partition, for "future use by Apple, and are populated as needed for some boot methods, such as AppleRAID booting on PowerPC systems," according to this email message.
  4. Create the new partition using the augmented size you just calculated, for example:
    sudo diskutil partitionDisk partition_id 2 GPTFormat "Journaled HFS+" "Bootable Clone" 155891808S "Journaled HFS+" "Spare" 1G
    partition_id represents the disk that you are partitioning, for example, /dev/disk1. diskutil automatically extends the final partition to use the remaining space on the disk, so the given size (1G) doesn't actually mean anything here. The S suffix means that the size is being specified in 512-byte blocks.
The key to getting this right is adding on the 262144 blocks. If you don't do this, your partition will always be slightly too small!
    •    
  • Currently 1.57 / 5
  You rated: 1 / 5 (7 votes cast)
 
[8,895 views]  

Make a partition of an exact size for cloning | 5 comments | Create New Account
Click here to return to the 'Make a partition of an exact size for cloning' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Make a partition of an exact size for cloning
Authored by: Sven G on Dec 19, '07 08:16:26AM

BTW, Apple's Disk Utility usually creates an additional 128 MB of free space included in the partition size you specify: the exact reason for this maybe is unknown (for a future RAID? for a Linux Apple_Bootstrap, or even a /boot partition? for future file system features? for storing what? who knows...), but it has been so for a long time.



[ Reply to This | # ]
Make a partition of an exact size for cloning
Authored by: Sven G on Dec 20, '07 12:59:50AM

Of course this was also said in the hint above, but in other ways. The "automatic" 128 MB free space is very useful, besides RAID, also to easily add an Apple_Bootstrap-type partition when you repartition your system to install Linux besides Mac OS X on PowerPC systems.



[ Reply to This | # ]
Make a partition of an exact size for cloning
Authored by: davidmorr on Dec 19, '07 01:23:33PM
Note the number of 512-byte blocks, and then add 262144 to that number. Why 262144? Because that amount is added to each partition, for "future use by Apple, and are populated as needed for some boot methods, such as AppleRAID booting on PowerPC systems," according to this email message.
Actually, these extra blocks are not added to the partition you want, but are a separate partition. If you use pdisk -l in the Terminal, you will see a full list of partitions on each disk. At the start of the disk, you will find a number of partitions related to booting and drivers. Then you will find a 128MB (262144 blocks) partition, and another between each of the other partitions.

So if you want a proper clone of your original partition, *don't* add the 262144 blocks.

[ Reply to This | # ]

Make a partition of an exact size for cloning
Authored by: iangoldby on Dec 20, '07 03:09:15PM

Your experience may vary, but I found that when I did not add the extra 262144 blocks, the new partition - the one I wanted to use for the clone - was too small by exactly 262144 blocks. I verified this both with the diskutil info command, and also by looking at the disk size in the Finder.

I wonder if perhaps the partition size used to be exactly what was requested, but Apple have changed it for some reason so that the 262144 blocks of this reserved space is now carved out of the request.



[ Reply to This | # ]
Make a partition of an exact size for cloning
Authored by: badtz on Apr 29, '08 01:50:39AM

i was able to just copy+paste the log byte number in the disk utility, and it came out EXACTLY the same as the original disk size. Even if the number is long, just paste it in the box, it'll format appropriately! ;)



[ Reply to This | # ]