Does adding a postgres index concurrently take up disk space gradually or all at once? I'm adding a unique index (concurrently, over the course of hours or maybe even days, on a column of 5 billion bigints, all of them NULL) on a Postgres 9.6 server that's pretty low on disk space. I can see that it's increased disk utilization from 94% to 95%, and I'm not sure if it's set aside all the space it wants, or if it's going to write more to disk later and take down the server over the weekend.
Does Postgres set aside disk space for indexes in advance, use more disk space gradually over the entire course of indexing, or write intermittently?
When running CREATE INDEX in PostgreSQL, disk space will be allocated gradually as needed. It should be easy to observe with a simple command like watch du -s $PGDATA.

Same applies to any data-generating command (INSERT, COPY, CREATE TABLE AS, etc etc).

It's hard (and in most cases, pointless) to pre-calculate and pre-allocate all required space before object is created. If the transaction breaks, data can be simply discarded.