Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 94C099FB60E for ; Sat, 23 Jun 2007 01:42:34 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 37592-07 for ; Sat, 23 Jun 2007 01:42:30 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 840C89FB5BB for ; Sat, 23 Jun 2007 01:42:31 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l5N4gTlJ007005; Sat, 23 Jun 2007 00:42:29 -0400 (EDT) To: Robert Treat cc: pgsql-admin@postgresql.org, "Chris Hoover" Subject: Re: How to move a tablespace? In-reply-to: <200706230029.42578.xzilla@users.sourceforge.net> References: <1d219a6f0706221114t25ddf96djf62297a8f1428cc2@mail.gmail.com> <200706230029.42578.xzilla@users.sourceforge.net> Comments: In-reply-to Robert Treat message dated "Sat, 23 Jun 2007 00:29:42 -0400" Date: Sat, 23 Jun 2007 00:42:29 -0400 Message-ID: <7004.1182573749@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/252 X-Sequence-Number: 25920 Robert Treat writes: > On Friday 22 June 2007 14:14, Chris Hoover wrote: >> How do you correctly move a tablespace? >> >> I am thinking this would be the process: >> 1. Cleanly shutdown Postgres >> 2. Move tablespace directory and all contents to new location >> 3. Create a symlink from the new location back to the old location >> 4. Restart Postgres > On a side note, this is one reason to make tablespaces on clean mount points, > so that you can swap the disk systems out underneath, but maintain the same > mountpoint, and not let the db care about the difference. But you'd still have to shut down the postmaster. The fine manual sayeth : The directory $PGDATA/pg_tblspc contains symbolic links that point to : each of the non-built-in tablespaces defined in the cluster. Although : not recommended, it is possible to adjust the tablespace layout by hand : by redefining these links. Two warnings: do not do so while the server : is running; and after you restart the server, update the pg_tablespace : catalog to show the new locations. (If you do not, pg_dump will continue : to show the old tablespace locations.) and elsewhere : Each user-defined tablespace has a symbolic link inside the : PGDATA/pg_tblspc directory, which points to the physical tablespace : directory (as specified in its CREATE TABLESPACE command). The symbolic : link is named after the tablespace's OID. Inside the physical tablespace : directory there is a subdirectory for each database that has elements in : the tablespace, named after the database's OID. Tables within that : directory follow the filenode naming scheme. The pg_default tablespace : is not accessed through pg_tblspc, but corresponds to : PGDATA/base. Similarly, the pg_global tablespace is not accessed through : pg_tblspc, but corresponds to PGDATA/global. regards, tom lane