简体   繁体   中英

Cannot remove 'Monogod.lock': Read-only file system

My mongodb stopped working and found out that I need to remove the 'mongod.lock' file from var/lib/mongodb but I am faced with 'read-only file system error'

rm: cannot remove 'mongod.lock': Read-only file system

MongoD Lock is some kind of garantee that only one mongo deamon(process) access the folder. So, first be sure that there is no active mongo deamon. Then you can remove read onla attribute and delete the lock file. Alternativly, you could start mongo deamon on the other folder by specifying startup parameter dbpath. eg mongod --dbpath new folder.

I had tons of problems with all that Read-Only file system, Both when setting up mongod initially (couldnt create /data/db) directory and later on when the mongod instance wasn't shut down properly I couldn't re-run it with the same error you got there.

Couldn't delete the file.

I had to disable the SIP (csrutil) on the machine, mount the root directory with right priviliges and then be able to delete the file.

  1. Boot into recovery mode by shutting down the machine and starting it up via Cmd + R + Boot
  2. Once in recovery open up the terminal
  3. Disable SIP using csrutil disable
  4. Restart the machine
  5. When booted into MacOS Catalina open up the terminal
  6. Run sudo mount -uw /

This will give you root access for the current session. It will be reset upon next start up. Though now you can do a lot of things in the root folder, now you can rm that file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM