DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · File Locations

data_directory

Sets the server's data directory.

  • Default: '' (empty)
  • Type: string
  • Applies: Restart required

In plain words

The directory that holds the whole database cluster: tables, indexes, WAL, transaction status, and usually the configuration files. It is normally given to the server with -D or the PGDATA environment variable. This parameter exists so a configuration file kept elsewhere can point at it.

For DBAs and operators

On Debian/Ubuntu packages, postgresql.conf lives in /etc/postgresql/18/main/ and sets data_directory = '/var/lib/postgresql/18/main'; pg_ctlcluster starts the server with -c config_file=/etc/postgresql/18/main/postgresql.conf (visible in ps). The PGDG RPM packages (RHEL and derivatives) keep everything in /var/lib/pgsql/18/data.

Inside it (verified on 18.6): base/ (databases), global/ (shared catalogs, pg_control), pg_wal/, pg_xact/, pg_multixact/, pg_subtrans/, pg_commit_ts/, pg_logical/, pg_replslot/, pg_tblspc/ (symlinks), pg_stat/, PG_VERSION, postmaster.pid, postmaster.opts, postgresql.auto.conf.

The directory must be owned by the server's OS user with mode 0700 (or 0750 with group access). Find it with SHOW data_directory; (superuser or pg_read_all_settings). Never delete files from pg_wal or pg_xact by hand to free space: that destroys the cluster.

How to change it

Change in postgresql.conf or ALTER SYSTEM, then restart the server.

See it in context

Physical layout on disk Postmaster Server startup sequence

Related parameters

config_file hba_file ident_file external_pid_file

All File Locations parameters