Skip to content

Instantly share code, notes, and snippets.

@Shawn1224
Last active August 23, 2021 14:58
Show Gist options
  • Save Shawn1224/bf3ccf96a0f85a9040435771b0b1e321 to your computer and use it in GitHub Desktop.
Save Shawn1224/bf3ccf96a0f85a9040435771b0b1e321 to your computer and use it in GitHub Desktop.
When you run command mkdir in mac os to create a folder, it gives you an error message `mkdir: /data: Read-only file system`

Usually fellow the steps below of the first method is fine. But in some higher versions of macOS, beyond 10.0.1 or Big Sur does not work, in my personal expirence.

  1. https://www.dev2qa.com/how-to-fix-read-only-file-system-error-when-run-mkdir-command-on-macos/
  1. Restart macOS, press Command+R to go to 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.

  4. Click Mac Logo —> Restart menu item at the top left corner to restart the macOS.

  5. After restart macOS, run the command sudo mount -uw /

$ sudo mount -uw /
Password:
  1. Now you can create a directory successfully with the command mkdir.
  2. 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.
  1. If you want to enable System Integrity Protection, you can restart the macOS and press Command + R to go to the macOS utilities window again to enable it with command csrutil enable in terminal.
  1. Use soft link.
    mkdir -p ~/data
    pwd
    sudo vi /etc/synthetic.conf
    # Write result of pwd above into /etc/synthetic.conf, mymac should be the username of your mac machine.
    # Between `data` and `/Users/mymac/data` is a tab, not a plain whitespace.
    data /Users/mymac/data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment