Mongod service fails to start if dbpath is mounted as LVM

Hi,

MongoD service doesn’t start if LVM is mounted to the directory which is dbpath for mongod.

# df -h /var/lib/mongo
Filesystem                               Size  Used Avail Use% Mounted on
/dev/mapper/mongosvcVG-mongo----lv--svc  9.8G  364M  8.9G   4% /var/lib/mongo

mongod.conf snippet

# Where and how to store data.
storage:
  dbPath: /var/lib/mongo

mongod service fails to start if I trigger the command:

systemctl start mongod

I am seeing the following error messages in logs present at /var/log/mongodb/mongod.log

{"t":{"$date":"2023-11-16T12:48:10.557+05:30"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"config":"/etc/mongod.conf","net":{"bindIp":"0.0.0.0","port":27017},"processManagement":{"fork":true,"timeZoneInfo":"/usr/share/zoneinfo"},"storage":{"dbPath":"/var/lib/mongo","journal":{"enabled":true}},"systemLog":{"destination":"file","logAppend":true,"path":"/var/log/mongodb/mongod.log"}}}}
{"t":{"$date":"2023-11-16T12:48:10.557+05:30"},"s":"E",  "c":"CONTROL",  "id":20558,   "ctx":"initandlisten","msg":"std::exception in initAndListen, terminating","attr":{"error":"boost::filesystem::status: Permission denied: \"/var/lib/mongo/.initialsync\""}}

Can someone please help?

You got

It means the user with which mongod is started does not have read and write permission on the given directory.

You have to make sure the user has read and write permission.

2 Likes