Skip to content

pg_statvfs

Server filesystem capacity and inode statistics through statvfs

Overview

PackageVersionCategoryLicenseLanguage
pg_statvfs1.0STATPostgreSQLC
IDExtensionBinLibLoadCreateTrustRelocSchema
6470pg_statvfsNoYesNoYesNoYes-

Superuser-only; checks server paths under data/log-directory rules. No preload. PostgreSQL 14-18 verified in PGSTY builds; upstream declares no major-version matrix.

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY1.01817161514pg_statvfs-
RPMPIGSTY1.01817161514pg_statvfs_$v-
DEBPIGSTY1.01817161514postgresql-$v-pg-statvfs-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d12.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d12.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d13.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d13.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u22.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u22.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u24.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u24.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u26.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u26.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0

Build

You can build the RPM / DEB packages for pg_statvfs using pig build:

pig build pkg pg_statvfs         # build RPM / DEB packages

Install

You can install pg_statvfs directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

Install
pig install pg_statvfs;          # Install for current active PG version
pig
pig ext install -y pg_statvfs -v 18  # PG 18
pig ext install -y pg_statvfs -v 17  # PG 17
pig ext install -y pg_statvfs -v 16  # PG 16
pig ext install -y pg_statvfs -v 15  # PG 15
pig ext install -y pg_statvfs -v 14  # PG 14
dnf
dnf install -y pg_statvfs_18       # PG 18
dnf install -y pg_statvfs_17       # PG 17
dnf install -y pg_statvfs_16       # PG 16
dnf install -y pg_statvfs_15       # PG 15
dnf install -y pg_statvfs_14       # PG 14
apt
apt install -y postgresql-18-pg-statvfs   # PG 18
apt install -y postgresql-17-pg-statvfs   # PG 17
apt install -y postgresql-16-pg-statvfs   # PG 16
apt install -y postgresql-15-pg-statvfs   # PG 15
apt install -y postgresql-14-pg-statvfs   # PG 14

Create Extension:

CREATE EXTENSION pg_statvfs;

Usage

Sources:

pg_statvfs 1.0 exposes filesystem capacity, inode availability, and mount flags through the server’s statvfs call. It inspects the filesystem containing a server-side path, not a client directory or the size of an individual relation.

Core Workflow

After installing the extension files, use a superuser session:

CREATE EXTENSION pg_statvfs;
SELECT * FROM pg_statvfs(current_setting('data_directory'));
SELECT f_frsize * f_blocks AS total_bytes,
       f_frsize * f_bavail AS available_bytes
FROM pg_statvfs(current_setting('data_directory'));

Result and Access

pg_statvfs(path text) returns one record. f_bsize is the preferred block size; f_frsize is the unit for block counts. f_blocks, f_bfree, and f_bavail report total, free, and unprivileged-available blocks. f_files, f_ffree, and f_favail describe inode counts; f_fsid, f_namemax, and flags expose filesystem identity, name limits, and supported mount flags.

The C function explicitly requires superuser privileges and validates the path before asking the operating system. Missing or inaccessible paths produce an error. The extension needs no preload or restart of its own. Its control file permits relocation, but does not mark it trusted. The upstream subdirectory does not declare a complete PostgreSQL-major compatibility matrix; operating-system support and mount-flag coverage also vary.

Was this page helpful?