“Couldn’t create temporary file” error when erasing free space on startup disk When I tried to erase space on Disk Utility, it couldn't create a second temporary file for my startup disk.
Ran into the same issue while erasing free space on El Capitan. I was doing it from the terminal, and this was likely the error you ran in to:

Error: -69847: Couldn't create temporary file
Underlying error: 1: POSIX reports: Operation not permitted


As @Tetsujin mentioned, there is a solution in this question &mdash; though, in this case, I think the easiest solution is to run the operation via the command line, with sudo. From a terminal window, you should be able to do:

sudo diskutil secureErase freespace 0 "/Volumes/[Disk Name]"


This isn't the accepted answer in the linked issue, but it's one of the answers...and way easier than all the other solutions.

The 0 in the command specifies that you want to overwrite the free space with zeros...there are other "more secure" options, although there are arguments that erasing free space may not be necessary at all, when you have a solid state hard drive.