How to calculate RAM disk size on OS X Mojave—500 or 512 byte block size? I created an APFS RAM disk on macOS X 10.14 Mojave using these commands:

diskutil partitionDisk $(hdiutil attach -nomount ram://12582912) 1 GPTFormat APFS 'RAMDisk' '100%'


Which should create a 6 GB RAM Disk. I ended up with a "6.53 GB" Ram Disk. The question is does hdiutil calculate block sizes as 512 bytes or 500 bytes?

The old way was:
1 block = 512 bytes
 2 blocks = 1024 bytes (KB) 
1024 bytes X 1024 = 1048576 bytes (MB) 
1048576 bytes x 1024 = 1073741824 bytes (GB)
1073741824 bytes / 512 = 2097152 blocks per GB

But maybe storage is now calculated differently:
1 block = 500 bytes 
2 blocks = 1000 bytes (KB) 
1000 bytes X 1000 = 1000000 bytes (MB) 
1000000 bytes x 1000 = 1000000000 bytes (GB)
1000000000 bytes / 500 = 2000000 blocks per GB

EDIT: Just tested this myself and ended up with these numbers which seems to indicate that hdiutil does indeed use 500 byte block size for calculation. There is some overhead for EFI which reduces available size but the GUID partition was 6.1 GB.

$ diskutil partitionDisk $(hdiutil attach -nomount ram://12000000) 1 GPTFormat APFS 'RAMDisk' '100%'
Started partitioning on disk15
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk15s2 as APFS with name RAMDisk
Mounting disk
Finished partitioning on disk15
/dev/disk15 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        +6.1 GB     disk15
   1:                        EFI EFI                     209.7 MB   disk15s1
   2:                 Apple_APFS Container disk16        5.9 GB     disk15s2


&nbsp;
This seems simple enough. You asked for 12000000 sectors. The sector size is 512 bytes. So 12000000 * 512 = 6.1 GB which is the size of disk15. If a block size of 500 bytes was substituted for the 512 byte sector size, then the calculation would be 12000000 * 500 = 6.0 GB. This is not what is shown.

The output from diskutil info disk15 | grep -e Size should be as shown below.

   Disk Size:                 6.1 GB (6144000000 Bytes) (exactly 12000000 512-Byte-Units)
   Device Block Size:         512 Bytes


&nbsp;