How To Fix Read-Only File System Error When Run Mkdir Command On MacOS

When i run command mkdir in mac os to create a folder, it give me an error message  mkdir: /data: Read-only file system like below. This article will tell you how to fix it.

sh-3.2# mkdir /data
mkdir: /data: Read-only file system

1. Fix MacOS Read-Only File System Error Steps.

  1. Restart macOS, press Command+R to go to macOS utilities window.
    macos utilities window
  2. Click menu item Utilities —> Terminal at top menu bar.
  3. Then input command csrutil disable in the popup terminal window. This command will disable the System Integrity Protection.
    disable system integrity protection
  4. Click Mac Logo —> Restart menu item at top left corner to restart the macOS.
  5. After restart macOS, run command
    $ sudo mount -uw /
  6. Now you can create directory successfully with command mkdir.
  7. If you want to check whether System Integrity Protection is enabled or disabled, you can run command csrutil status in a terminal.
    # csrutil status
    System Integrity Protection status: disabled.
  8. If you want to enable System Integrity Protection, you can restart the macOS and press Command + R to go to macOS utilities window again to enable it with command csrutil enable in terminal.

2. Resolve Read-only File System Error When Remove Files.

Now we can create directory in macOS system. But when i want to remove files, it also show me below error messages.

# rm -rf /data/db
rm: /data/db/journal/WiredTigerPreplog.0000000002: Read-only file system
rm: /data/db/journal/WiredTigerLog.0000000001: Read-only file system
rm: /data/db/journal/WiredTigerPreplog.0000000001: Read-only file system

To fix this issue, you should run command sudo mount -uw /, after that you can remove files as you want.

$ sudo mount -uw /
0 0 vote
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x