How to over provision free space for SSD?

Prior to OS X 10.11 I was able to over-provision an SSD by not using all of the disk space when partitioning. Disk Utility would show empty space after my Macintosh HD.


In El Capitan if I use less than the full space of the disk when partitioning, a separate Untitiled partition gets created automatically from the remaining space. If I delete that partition the space gets automatically added to the remaining partition before it.


Is there no way to simply have free unallocated space that doesn't belong to a partition?

The Disk Utility app has been made easier for the less filesystem literate in 10.11 but, in the process, a little of the freedom to customise things as you might want them has been lost.


The diskutil command from Terminal will still do what you're looking for however. If you're not so familiar with it, you can run man diskutil to get help with how to use it. Alternatively, if you post the output of diskutil list and tell me which of the referenced disks you want to over-provision, and by how much, I'll post back the command necessary to do it.


-Max

Last login: Sat Sep 19 07:23:50 on console

Allans-MBP:~ allan$ diskutil list

/dev/disk0 (internal, physical):

#: TYPE NAME SIZE IDENTIFIER

0: GUID_partition_scheme *500.1 GB disk0

1: EFI EFI 209.7 MB disk0s1

2: Apple_HFS Macintosh HD 449.5 GB disk0s2

3: Apple_Boot Recovery HD 650.0 MB disk0s3

4: Apple_HFS Empty Partition 49.6 GB disk0s4

/dev/disk1 (external, physical):

#: TYPE NAME SIZE IDENTIFIER

0: GUID_partition_scheme *250.1 GB disk1

1: EFI EFI 209.7 MB disk1s1

2: Apple_HFS Allan Backup 199.3 GB disk1s2

3: Apple_Boot Recovery HD 650.0 MB disk1s3

4: Apple_HFS Untitled 49.6 GB disk1s4

Allans-MBP:~ allan$


disk0 is the internal Samsung SSD. disk1 is an external USB. I am not using Core Storage. It is a mid 2012 Macbook Pro.


'Empty Partition' is what I renamed 'Untitled' to on my own.


Is there any way to delete 'Empty Partition' and just leave unallocated free space on the SSD? At present in the GUI Disk Utility, if I delete 'Empty Partition' it automatically adds the space to 'Macintosh HD'.


Also, if I can remove 'Empty Partition' using diskutil, how will the drive show up in the GUI? Will it simply show less overall partition space than the physical drive, without displaying the empty space the way the old Disk Utility (pre-10.11) did?


Thanks, Allan

Accepted Answer

I appreciate why you want to leave space available - as a redundancy in case the existing provision of reserve storage (probably only a couple of GB) isn't enough in the event of cell failiures in the SSD.


Use the following command to free that space from the GUID table, resulting in the over provisioning you're looking for:

sudo diskutil eraseVolume Free\ Space null disk0s4


Please post the output of that so that I can confirm that it has worked (I haven't done this recently and it's possible that changes have been made to the diskutil command since 10.10)

Thanks, Max108. I ran the diskutil command on the USB drive - disk1.


Allans-MBP:~ allan$ sudo diskutil eraseVolume Free\ Space null disk1s4

Started erase on disk1s4 Untitled

Unmounting disk

Finished erase on disk1

Allans-MBP:~ allan$ diskutil list

/dev/disk0 (internal, physical):

#: TYPE NAME SIZE IDENTIFIER

0: GUID_partition_scheme *500.1 GB disk0

1: EFI EFI 209.7 MB disk0s1

2: Apple_HFS Macintosh HD 449.5 GB disk0s2

3: Apple_Boot Recovery HD 650.0 MB disk0s3

4: Apple_HFS Empty Partition 49.6 GB disk0s4

/dev/disk1 (external, physical):

#: TYPE NAME SIZE IDENTIFIER

0: GUID_partition_scheme *250.1 GB disk1

1: EFI EFI 209.7 MB disk1s1

2: Apple_HFS Allan Backup 199.3 GB disk1s2

3: Apple_Boot Recovery HD 650.0 MB disk1s3

Allans-MBP:~ allan$


Note that the volume 'Untitled' is gone from the USB drive disk1 and that the 49.6GB of free space doesn't show up here or in the GUI. In fact in the GUI Disk Utility there is no way to see the free space or to create a new volume from it.


How would I create a new volume in diskutil?

That process would start with:

sudo gpt -r show disk1


I need the output of that to tell you how to turn it back into a partition (and if it's not a partition it won't be visible in any way in the GUI).

You may prefer to expand the previous partition (in this case Recovery HD) into the free space with the following:

sudo diskutil resizeVolume disk1s3 R


You can then reduce the partition (in this case Recovery HD) back to where you want it (650MB) from the DU GUI, which will create the new free volume for you.


Failing that, I'll need the sudo gpt -r show disk1 as explained above.

Last login: Sat Sep 19 08:41:59 on ttys000

Allans-MBP:~ allan$ sudo gpt -r show disk1

Password:

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 389355464 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC

389765104 262144

390027248 1269536 3 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC

391296784 97100351

488397135 32 Sec GPT table

488397167 1 Sec GPT header

Allans-MBP:~ allan$


I assume partition 1 is EFI, 2 is Allan Backup and 3 is Recovery HD. Is it normal to have nothing in between GPT Partition 2, the main partition and GPT Partition 3, the Recovery HD partition? This Recover HD partition was created by Carbon Copy Cloner.


I assume the 97100351 sectors starting at 391296784 are the free 49.6GB that used to be partition 'Untitled'. How do you recreate it?


Thanks for all your help by the way.


Allan

Also remember, that there is no DU Debug feature so the Recovery HD will not show in the GUI DIsk Utility.

True.

No problem 🙂


All your assumptions are correct. The space between partitions 2 and 3 is the Apple recommended 128MiB buffer between partitions. It's not essential (none of my drives - all partitioned fairly recently - have it). It seems to be a legacy requirement, but we shall still factor it in again in a moment:


As you realised, the free space is indicated by this line (the numbers are 512-byte sectors, so just under 50GB free space):

  391296784  97100351 

Apple requires 128MiB (262144 sectors) free space following the final partition, so the new partition can be 97100351-262144=96838207 sectors.


First, unmount all the volumes on the disk using:

diskutil unmountDisk disk1

Then, this command will create an HFS+ partition in the free space:

sudo gpt add -b 391296784 -s 96838207 -t hfs disk1

That only creates the partition, not the file system. To check that it went well, you should now see a

disk1s4
if you run:
diskutil list disk1

If this is indeed the case, you should be able to erase/format the partition from DU GUI.

Max108, that worked. Thanks so much for an intro course in diskutil.


I noticed some differences in the way RecoveryPartitionCreator 3.8 and Carbon Copy Cloner create the Recovery HD partition. One keeps the 128MB buffer and the other doesn't. As you said earlier, the buffer is not critical?


If you don't have an existing recovery HD Partition or an 'Untitled Partition' but just one partition that is 200GB on a 250GB drive, then Carbon Copy Cloner will use all the 50GB free space for the Recovery HD Partition.


I'm not sure this means anything to anybody but I find it interesting.


This was all done on a non Core Storage drive. Out of curiousity, do you see any advantage to using Core Storage if not using FileVault?


This is the Terminal Output after using CCC to create the Recovery Partition on a drive with free space at the end of it.



Allans-MBP:~ allan$ diskutil list

/dev/disk0 (internal, physical):

#: TYPE NAME SIZE IDENTIFIER

0: GUID_partition_scheme *500.1 GB disk0

1: EFI EFI 209.7 MB disk0s1

2: Apple_HFS Macintosh HD 449.5 GB disk0s2

3: Apple_Boot Recovery HD 650.0 MB disk0s3

4: Apple_HFS Empty Partition 49.6 GB disk0s4

/dev/disk1 (external, physical):

#: TYPE NAME SIZE IDENTIFIER

0: GUID_partition_scheme *250.1 GB disk1

1: EFI EFI 209.7 MB disk1s1

2: Apple_HFS Allan Backup 199.3 GB disk1s2

3: Apple_Boot Recovery HD 50.4 GB disk1s3 **uses all free space for Recovery H


If you do have two partitions, a 200GB one and a 50 GB 'Untitled' one, then Carbon Copy Cloner will create the Recovery HD partition using space from the 200GB one, and will leave the 128MB buffer in between the 200GB partition and the Recovery Partition.


This is the Terminal Output after using CCC to create the Recovery HD Partition.


/dev/disk1 (external, physical):

#: TYPE NAME SIZE IDENTIFIER

0: GUID_partition_scheme *250.1 GB disk1

1: EFI EFI 209.7 MB disk1s1

2: Apple_HFS Allan Backup 199.3 GB disk1s2

3: Apple_Boot Recovery HD 650.0 MB disk1s3

4: Apple_HFS Untitled 49.6 GB disk1s4

Allans-MBP:~ allan$ sudo gpt -r show disk1

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 389355464 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC

389765104 262144 **this buffer stays with CCC, not with Recovery Partition Creator##

390027248 1269536 3 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC

391296784 96838200 4 GPT part - 48465300-0000-11AA-AA11-00306543ECAC

488134984 262151

488397135 32 Sec GPT table

488397167 1 Sec GPT header


This is the Terminal output after using RecoveryPartitionCreator to create the Recovery HD partitions.



/dev/disk1 (external, physical):

#: TYPE NAME SIZE IDENTIFIER

0: GUID_partition_scheme *250.1 GB disk1

1: EFI EFI 209.7 MB disk1s1

2: Apple_HFS Allan Backup 199.5 GB disk1s2

3: Apple_Boot Recovery HD 650.0 MB disk1s5

4: Apple_HFS Untitled 49.6 GB disk1s3

Allans-MBP:~ allan$ sudo gpt -r show disk1

Password:

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 389617608 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC space taken from Allan Backup to make Recovery HD, buffer gone

390027248 1269536 3 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC

391296784 96838200 4 GPT part - 48465300-0000-11AA-AA11-00306543ECAC

488134984 262151

488397135 32 Sec GPT table

488397167 1 Sec GPT header

Allans-MBP:~ allan$

By the way, when creating a partition from the free space, as above, you need to be booted from a different drive to the one that the free space is on. In the case of working on your 500GB drive, you could boot into the Recovery HD of your 250GB drive for example.

Max108, since you appear pretty knowledgeable in these matters, I have two follow up questions.


1. The existence of the 128MB filler in between partitions is not critical?


2. On a freshly partitioned drive, there is a filler (I assume it's that) at the end before the GPT Table and Header that is 262151 sectors, not 262144. What is the significance of that? Using your instructions to delete and recreate the last empty partition left this piece at 262144 sectors, not 262151. Does that matter?

  1. The 262144 sectors (128MiB) "headroom" is recommended after the end of the final partition and it may be good to have the same provision between partitions too.
  2. 262144 sectors (128MiB) is the recommended amount. It won't have mattered that is was fractionally more than that before.

Looking back, I can see that I didn't make it clear that it was only after the final partition that the ~262144 sectors is recommended. I've edited the post to clarify that now.

How to over provision free space for SSD?
 
 
Q