I'm trying to change my PostgreSQL data directory initially on my Debian server to my NAS (running also on linux). To do so, I've mounted it on a specific directory through sshfs (in /mnt/titanBDD).
Now I get this error when starting postgre (using service and pg_ctlcluster):
Error: could not exec /usr/lib/postgresql/9.4/bin/pg_ctl /usr/lib/postgresql/9.4/bin/pg_ctl start -D /var/lib/postgresql/9.4/redirect_TITAN -l /var/log/postgresql/postgresql-9.4-main.log -s -o -c config_file="/etc/postgresql/9.4/main/postgresql.conf"
Here is the modified part of postgresql.conf:
data_directory = '/var/lib/postgresql/9.4/main'
modified in:
data_directory = '/var/lib/postgresql/9.4/redirect_TITAN'
Where redirect_TITAN:
0 lrwxrwxrwx 1 root root 18 nov. 1 16:23 /var/lib/postgresql/9.4/redirect_TITAN -> /mnt/titanBDD/main
I've used the following command to move my data:
root@machine:~# cp --preserve=all -R /var/lib/postgresql/9.4/main/ /mnt/titanBDD/
Acutally, in /mnt/titanBDD I have:
root@machine:~# ls -als /mnt/titanBDD/
total 12
4 drwxr-xr-x 1 postgres postgres 4096 nov. 1 16:19 .
4 drwxr-xr-x 3 root root 4096 nov. 1 14:05 ..
4 drwx------ 1 postgres postgres 4096 nov. 1 15:59 main
What is going wrong? I guess it's a context issue but don't have any idea where to search.