Skip to content

Instantly share code, notes, and snippets.

@iangow
Last active May 15, 2020 18:55
Show Gist options
  • Save iangow/96835be8c681a631526f7ab70035e541 to your computer and use it in GitHub Desktop.
Save iangow/96835be8c681a631526f7ab70035e541 to your computer and use it in GitHub Desktop.
Script to make tablespace on new drive
sudo mkdir /mnt/2TB/pg_data
sudo chown postgres:postgres /mnt/2TB/pg_data
sudo chmod a+rx /mnt/2TB/
psql -d crsp -c "CREATE TABLESPACE hdd_2tb OWNER igow LOCATION '/mnt/2TB/pg_data'"
@iangow
Copy link
Author

iangow commented May 15, 2020

I then followed up with

igow@igow-ubuntu:/mnt/2TB$ psql -d postgres 
psql (12.3 (Ubuntu 12.3-1.pgdg20.04+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

postgres=# ALTER DATABASE crsp TABLESPACE hdd_2tb ;
ERROR:  database "crsp" is being accessed by other users
DETAIL:  There is 1 other session using the database.
postgres=# ALTER DATABASE crsp TABLESPACE hdd_2tb ;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment