I keep running into this error on Windows Postgresql running a large query:
[53100] ERROR: could not write block 21991344 of temporary file: No space left on device
The only problem is that I actually have a huge amount of space left on all of my partitions (including 171gb on the partition holding the data directory and 448gb on my only other partition).
It seems like some sort of internal setting preventing the creation of the temp file that I am unfamiliar with. I looked through the configuration file and tweaked a couple of settings to do with temp tables with no help.
I was able to run the query before, not much has been changed in the database aside from a couple of tables.
21991344 blocks is 168GB. That is pretty close to the space you say you have free. There could be some other smaller temp file also in use making up the differences (or it could be a difference in definition of GB, 10^9 or 2^30).