diskutil fails to take into account EFI partition size when creating partitions
| Originator: | robincello | ||
| Number: | rdar://13244804 | Date Originated: | 19-Feb-2013 07:05 PM |
| Status: | Open | Resolved: | |
| Product: | Mac OS X | Product Version: | 10.8.2 |
| Classification: | Other Bug | Reproducible: | Always |
19-Feb-2013 07:05 PM Robin Miller:
Summary:
When partitioning a disk into multiple GPT partitions using /usr/sbin/diskutil's partitionDisk verb, and giving 'R' for the size of a partition other than the last one, the size of the last partition is truncated by almost exactly the number of sectors given to the EFI partition at the beginning of the disk.
Steps to Reproduce:
Use diskutil partitionDisk to create 2 or more partitions, where the last partition has a specified size, and one of the other partitions has a requested size of 'R' to indicate that it should take up the remaining space. For example:
# diskutil partitionDisk disk0 GPT jhfs+ 'apple' R jhfs+ 'banana' 3191831S jhfs+ 'pear' 3191831S jhfs+ 'grape' 3191831S
Expected Results:
One would expect 5 partitions to be created, including the EFI partition as partition 1, with partitions 3, 4 and 5 having *equal* size (of 3191831 sectors minus the 262144 sectors (128MB) that diskutil gives to free space after each partition as noted in TN2166). Partition 2 would get the remainder of the space on the disk.
Actual Results:
Instead, the last partition (partition 5) is 409688 sectors smaller than partitions 3 and 4. That number is very similar to the size of the EFI partition at the start of the disk (409600 sectors).
It appears as if when diskutil is calculating the size for the partition with size 'R', it takes into account the other partitions specified on the command line, but fails to account for the 200MB EFI partition that it will create as partition 1. The last partition then loses that space, rather than the partition with size 'R', which would be the expected behavior from a user's point of view.
This happens irrespective of the units used to specify partition sizes.
Please see Notes for the output from diskutil and gpt.
Regression:
Notes:
localhost:Desktop root# diskutil partitionDisk disk0 jhfs+ 'apple' R jhfs+ 'banana' 3191831S jhfs+ 'pear' 3191831S jhfs+ 'grape' 3191831S
Started partitioning on disk0
Unmounting disk
Creating the partition map
Waiting for the disks to reappear
Formatting disk0s2 as Mac OS Extended (Journaled) with name apple
Initialized /dev/rdisk0s2 as a 694 GB HFS Plus volume with a 57344k journal
Mounting disk
Formatting disk0s3 as Mac OS Extended (Journaled) with name banana
Initialized /dev/rdisk0s3 as a 1 GB HFS Plus volume with a 8192k journal
Mounting disk
Formatting disk0s4 as Mac OS Extended (Journaled) with name pear
Initialized /dev/rdisk0s4 as a 1 GB HFS Plus volume with a 8192k journal
Mounting disk
Formatting disk0s5 as Mac OS Extended (Journaled) with name grape
Initialized /dev/rdisk0s5 as a 1 GB HFS Plus volume with a 8192k journal
Mounting disk
Finished partitioning on disk0
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *750.2 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS apple 745.1 GB disk0s2
3: Apple_HFS banana 1.5 GB disk0s3
4: Apple_HFS pear 1.5 GB disk0s4
5: Apple_HFS grape 1.3 GB disk0s5
localhost:Desktop root# gpt -r show /dev/disk0
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 6
40 409600 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
409640 1455311536 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
1455721176 262144
1455983320 2929688 3 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
1458913008 262144
1459175152 2929688 4 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
1462104840 262144
1462366984 2520000 5 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
1464886984 262151
1465149135 32 Sec GPT table
1465149167 1 Sec GPT header
localhost:Desktop root#
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!