Postgresql – postgres user cannot access location of new data directory

permissionspostgresql-9.3Ubuntu

I moved my postgresql 9.3 data directory to a different drive, however, my postgres user cannot seem to access that new drive despite my best efforts. I am running on ubuntu 14.04 LTS x64. So I created a new directory under /media/$USER/kauthama/data/psql and set postgres:postgres as the owner. However when I try and do initdb the directory keeps saying permission denied. Even when I do su postgres and then try to navidate to the new directory, the autocompletion stops at /media/$USER/ and cannot find the drive kauthama. I even added postgres to the sudoers group to see if that would work. The permissions on kauthama are basically $USER is the owner and the sudo group owns it. So the postgres user should have all the permissions needed to navigate to the directory. Any thought on why this is not working?

Best Answer

I figured it out. So the permissions at one level of the directory hierarchy did not have any setting for letting the other group read that level. Thus that blocked the postgres user from being able to see a drive mounted by any other user. Once that was changed with

chmod -R 777 /media/$USER

Then this created permissions for the other group to see the directory. This fixed the issue.