PostgreSQL for windows create tablespace on network location (nfs shared) failed because directory not exist

postgresqlwindows

My server is Windows Server 2016. The server mounted a NFS remote storage with below command:

mount \\192.168.6.68\nfsshare z:
mkdir z:\pg_data

All the relevant permissions such as read/write/execute were set correctly on z:

I installed PostgreSQL 12.3 to C:\PostgreSQL. And then created tablespace with below commands:

create tablespace my_db_space location 'z:\pg_data'

PostgreSQL replied me:

Error, directory 'z:\pg_data' does not exist.

I also tried 'z:\pg_data', 'z:/pg_data', but all got the same error message.

I also tried another way, which is, I installed PostgreSQL in Z:\postgresql. The installation was successful. but postgreSQL service failed to start because of the error "directory not found".

In Linux, the same situation didn't happen the same error.

It seems that on Windows, PostgreSQL can only use local storage as its data location, right?

Any siggestion ?

Best Answer

It seems that on Windows, PostgreSQL can only use local storage as its data location, right?

On any operating system, PostgreSQL should only use "local" file systems.
On Linux, those file systems can be mounted from other machines in a way that PostgreSQL is not aware of so things "just work".

On Windows, a network drive is another thing entirely.

Under which account are you running PostgreSQL? (Probably as a Windows Service under "Local System").

Does that account have the ability to "see" anything not on the local machine ("No").

Even if you were to change this, putting your data "further" from the process that needs to manipulate it is just asking for [major] Trouble.