When formatting an external disk larger than 2GB, OS X automatically creates an EFI System Partition (ESP). For compatibility with other devices, I want to format a large disk with only one partition, and no ESP. How can I do this in OS X Yosemite?
diskutil eraseDisk HFS+ 002 disk2
I found this Technical Note describing Apple's partitioning policy, but it doesn't say how to avoid creating the ESP.
Edit: Forgot to mention I need to use GUID partition map for compatibility, not MBR.
Best Answer
You can repartition the disk with gpt and format the partition with newfs_hfs:
Open Terminal.app and to get an overview enter:
Get the partition table of the disk in question (below I assume the disk to partition is disk2):
Destroy the GUID partition table and create a new one:
If the disk previously was formatted as a FAT volume, a new GUID partition table can't be created because the PMBR turns into an MBR (which blocks the GPT creation) and you have to overwrite it first:
Get the new partition table:
Now create a new partition with gpt. Depending on the block size of your disk you may have to align the partition. Disks with a block size of 512 Bytes have to be aligned. On disks with a block size of 4096 Bytes you can use the first free block (block nr. 6) and the size of the free space.
Example (a 2.2 TB disk with a block size of 512 Bytes):
Do the math and align your volume to 4k blocks. This means: the start block and the size is divisible through 8 (and has to fit in 4292870071 blocks in my example because the lowest recommended start block is 40). Create a new partition:
with i: index position (usually 1 for the first partition); b: start block; s: size in blocks and t: type of partition (here HFS+ = 48465300-0000-11AA-AA11-00306543ECAC).
Example (a 6.0 TB disk with a block size of 4096 Bytes):
Format the partition with newfs_hfs (-v name: name the volume; -J: journaled):
The volume will be mounted automatically. Else enter
diskutil mount disk2s1
.Be warned: checking the disk with Disk Utility will yield:
and with
diskutil verifyDisk disk2