I recently purchased a new hard drive, for the sole purpose of storing a database. I am running Ubuntu 10.0.4.
Since I had not done this sort of thing before, I decided to use the GUI (Disk Utility) to format and mount the disk (to avoid any snarfus caused by typos etc at the command line).
I correctly identified the new drive and proceeded as follows:
- Elected to format the drive
- Selected type: 'Ext4'
- Selected the 'Take ownership of filesystem' checkbox
- Unchecked the 'encrypt underlying device' checkbox
- Provided a name for the new volume (mydata)
Once the device had been formatted, I then mounted the device as follows:
sudo mount /dev/sdb /mydata
I created the directory /mydata/pgdbdata
and changed ownership as follows
sudo chown -R postgres:postgres /mydata/pgdbdata
I check:
username@localhost:~$ ls -l /mydata/
total 20
drwx------ 2 root root 16384 2012-06-19 23:05 lost+found
drwxr-xr-x 2 postgres postgres 4096 2012-06-20 19:04 pgdbdata
However when I change to postgres user:
username@localhost:~$ sudo su - postgres
postgres@localhost:~$ ls -l /mydata/
ls: cannot open directory /mydata/: Permission denied
Because of this permissions issue, I can start the postgresql service and I can't create the postgresql db cluster. I am stuck.
What am I doing wrong?
You have only changed permission of
pgdbdata
but not ofmydata
you should be able to do als -l /mydata/pgdbdata
but if your postgresql user wants to see the content ofmydata
it has to have read access to that too.