MongoDB – Permission Denied on mongod.lock Despite Ownership

linuxmongodb

this is my mongod.lock:

-rw-r--r-- 1 mongodb mongodb    0 Dec  3 17:09 mongod.lock

hence this solution doesn't apply: https://dba.stackexchange.com/a/183018

this is how I start mongodb:

sudo systemctl start mongodb

and this is the output in mongod.log:

2019-12-03T17:12:01.676+0100 I  STORAGE  [initandlisten] exception in initAndListen: Location28596: Unable to determine status of lock file in the data directory /run/media/minze/ssd/mongodb: boost::filesystem::status: Permission denied: "/run/media/minze/ssd/mongodb/mongod.lock", terminating

thanks in advance. I really don't see how mongodb would not be permitted to access a file owned by mongodb

Best Answer

It works after I did:

sudo chmod +r /run/media/minze/ssd
sudo chmod +x /run/media/minze/ssd

I don't understand why.

mongodb.lock is located in /run/media/minze/ssd/mongodb/mongodb.lock

ls -lha gives me (permissions of '.' are important here):

drwxr-xr-x 8 minze   minze   4.0K Dec  3 17:40 .
drwxr-xr-x 3 root    root      60 Dec  3 10:49 ..
drwx------ 2 root    root     16K Oct 15 20:24 lost+found
drwx------ 4 mongodb mongodb 4.0K Dec  3 17:54 mongodb

now