Re: How to store data on an external drive

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: Jia Chen <chen(dot)1002(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, jasen(at)xnet(dot)co(dot)nz
Subject: Re: How to store data on an external drive
Date: 2009-09-08 15:31:40
Message-ID: 20090908153140.GI5407@samason.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

[ please CC the mailing list and not the list owner, they answer
mailing list questions not PG questions ]

On Tue, Sep 08, 2009 at 10:31:50AM -0400, Jia Chen wrote:
> Sam Mason wrote:
> >I don't think you need to go that far. I'd just do an "initdb"
> >somewhere on the removable disk and then start PG pointing at where the
> >cluster was (i.e. postgres -D /media/disk/psqldata) and all should be
> >good. I'd stay away from the official system startup scripts for PG.
>
> If I am not mistaken, the paragraph above means that I don't need to
> reinstall postgresql from source.

Yes; these are all standard programs included with Debian/Ubuntu
packages as normal. Have a look through the man pages for:

update-rc.d
initdb
postgres

> >Yup, the table data is very tied to the state of transactions and
> >other "system level" information, you need to keep everything together
> >unfortunately. This is the price of having transactions with ACID
> >semantics.
>
> However, this paragraph implies that I do need to put other "system
> level" information together on the external drive. Do you mean that I
> can put it together without re-installation? If so, could you offer
> some hints on how to do that? Thanks.

initdb creates a new PG cluster (i.e. the set of files that PG considers
to be a database). You should direct this to be run on your external
disk and then get PG running using this cluster. This is what "postgres
-D /media/disk/psqldata" does, i.e. start the postgres server. Once
it's started you can connect to it from the "normal" clients, psql, odbc
whatever you want.

I expect all you need to run is:

sudo /etc/init.d/postgresql-8.3 stop
sudo update-rc.d -f postgresql-8.3 remove
initdb /media/disk/psqldata
postgres -D /media/disk/psqldata

from there on, all you need to do is to run the last line when you plug
the drive in. Before you take the drive out, just hit the normal Ctrl+C
and PG will shutdown cleanly.

--
Sam http://samason.me.uk/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-09-08 15:37:02 Re: Adding integers ( > 8 bytes) to an inet
Previous Message Alvaro Herrera 2009-09-08 15:06:36 Re: Adding integers ( > 8 bytes) to an inet