In psql:
CREATE TABLESPACE mytablespace LOCATION '/Volumes/MyVolume/postgres'; CREATE DATABASE mydatabase TABLESPACE mytablespace;
Kudos to GregHNZ for posting this on StackOverflow.
In macOS (possibly other OSes as well) you can safely unmount the drive without stopping the Postgres process as long as there are no I/O operations running. When you mount the drive again, the database works instantly — again, Postgres doesn’t even need to be restarted. Magic!