A) Mounted a Virtualbox directory with the required ownership and permissions:
ls-l /var:
drwx------. 1 postgres postgres 4096 Aug 20 12:43 pgshared
(and /var/pgshared/data directory has been created with exactly same permission)
B) Changed PGDATA environment variable from default to this data directory
C) initdb failed with below error:
fixing permissions on existing directory /var/pgshared/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Europe/Brussels
creating configuration files ... ok
running bootstrap script ... 2021-08-20 12:16:08.088 CEST [2807] LOG: could not link file "pg_wal/xlogtemp.2807" to "pg_wal/000000010000000000000001": Operation not permitted
2021-08-20 12:16:08.090 CEST [2807] FATAL: could not open file "pg_wal/000000010000000000000001": No such file or directory
child process exited with exit code 1
initdb: removing contents of data directory "/var/pgshared/data"
Additional comments:
Using -D option has the same result (regardless of PGDATA environment variable)
The error means that the file system does not support hard links (the
link(2)
system call fails).Even if you manage to put a data directory, PostgreSQL will not work. To confirm, run the following a couple of times:
You will have to use a different file system that implements all required system calls.