Permission issues with mounted new hard drive on Ubuntu machine

5,519

You have only changed permission of pgdbdata but not of mydata you should be able to do a ls -l /mydata/pgdbdata but if your postgresql user wants to see the content of mydata it has to have read access to that too.

Share:
5,519

Related videos on Youtube

Homunculus Reticulli
Author by

Homunculus Reticulli

Updated on September 18, 2022

Comments

  • Homunculus Reticulli
    Homunculus Reticulli over 1 year

    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:

    1. Elected to format the drive
    2. Selected type: 'Ext4'
    3. Selected the 'Take ownership of filesystem' checkbox
    4. Unchecked the 'encrypt underlying device' checkbox
    5. 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?

    • pl1nk
      pl1nk almost 12 years
      From your question I suppose that /media/market_data/ is owned by user and group root. pgdbdata folder has been only chowned to user and group postgres. But you are checking a wrong folder?
    • Homunculus Reticulli
      Homunculus Reticulli almost 12 years
      @pl1nk: Sorry. That was a typo. I have corrected the text in my question.
    • pl1nk
      pl1nk almost 12 years
      You should change the permissions of /mydata/
  • Homunculus Reticulli
    Homunculus Reticulli almost 12 years
    Thanks. I don't know why or how I missed that ... Nothing like a second pair of eyes ... :)
  • André Stannek
    André Stannek almost 12 years
    You're welcome. Sometimes you're just blind. Happens to me all the time ;-)