When I run command mkdir
in mac os to create a folder, it gives 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.
- Restart macOS, press Command+R to go to macOS utilities window.
- Click menu item Utilities —> Terminal at top menu bar.
- Then input command
csrutil disable
in the popup terminal window. This command will disable the System Integrity Protection. - Click Mac Logo —> Restart menu item at the top left corner to restart the macOS.
- After restart macOS, run the command
sudo mount -uw /
.$ sudo mount -uw / Password:
- Now you can create a directory successfully with the command
mkdir
. - 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.
- 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.
2. Resolve Read-only File System Error When Remove Files.
Now we can create a directory in the macOS system. But when I want to remove files, it also shows 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 / Password:
3. Question & Answer.
3.1 Python script meets read-only file system error on macOS.
- In my python script, I want to use the python
os
module’ssystem
function to execute a zip command to make a zip file like below.os.system('zip target-file.zip /usr/local/abc.py')
But when I run the python script, it shows a permission denied error like below.
>>> import os >>> >>> os.getcwd() '/usr/local' >>> >>> os.system('zip target-file.zip /usr/local/abc.py') zip I/O error: Permission denied zip error: Could not create output file (target-file.zip) 3840
I have run the command
csrutil disable
to disable the System Integrity Protection on my macOS, but it still throws the error when I run the python script. - You can try the below steps.1. Run the command
fsck -n -f
in a macOS terminal. 2. Reboot your macOS. 3. Run the python script file with the root permission.
Copied directly from Apple KB — About the read-only system volume in macOS Catalina*
TL:DR
With macOS Catalina, you can no longer store files or data in the read-only system volume, nor can you write to the «root» directory ( / ) from the command line, such as with Terminal.
macOS Catalina runs in a read-only system volume, separate from other files on your Mac. When you upgrade to Catalina, a second volume
is created, and some files may move to a Relocated Items folder.macOS Catalina runs on a dedicated, read-only system volume called
Macintosh HD. This volume is completely separate from all other data
to help prevent the accidental overwriting of critical operating
system files. Your files and data are stored in another volume named
Macintosh HD — Data. In the Finder, both volumes appear as Macintosh
HD.The Disk Utility app in macOS Catalina shows that Macintosh HD is
the read-only system volume and Macintosh HD — Data contains the the
rest of your files and data.If you upgrade to macOS Catalina from an earlier version of macOS, the
read-only volume is created during the upgrade process. Files or data
that you previously stored in the startup volume are now stored in
this new volume, and some of these files may appear in a new folder
called Relocated Items. You can check this folder for any files that
you can’t locate.With macOS Catalina, you can no longer store files or data in the
read-only system volume, nor can you write to the «root» directory ( /
) from the command line, such as with Terminal.About the Relocated Items folder
While creating the two separate volumes during the upgrade process,
files and data that couldn’t be moved to their new location are placed
in a Relocated Items folder. The Relocated Items folder is in the
Shared folder within the User folder (/Users/Shared/Relocated Items)
and available though a shortcut on the Desktop. The Relocated Items
folder includes a PDF document with more details about these files.
*Copied from en-gb site, link will redirect your your local language site
See also Ask Different — Where does the upgrade to macOS Catalina move root “/” directory files?
Copied directly from Apple KB — About the read-only system volume in macOS Catalina*
TL:DR
With macOS Catalina, you can no longer store files or data in the read-only system volume, nor can you write to the «root» directory ( / ) from the command line, such as with Terminal.
macOS Catalina runs in a read-only system volume, separate from other files on your Mac. When you upgrade to Catalina, a second volume
is created, and some files may move to a Relocated Items folder.macOS Catalina runs on a dedicated, read-only system volume called
Macintosh HD. This volume is completely separate from all other data
to help prevent the accidental overwriting of critical operating
system files. Your files and data are stored in another volume named
Macintosh HD — Data. In the Finder, both volumes appear as Macintosh
HD.The Disk Utility app in macOS Catalina shows that Macintosh HD is
the read-only system volume and Macintosh HD — Data contains the the
rest of your files and data.If you upgrade to macOS Catalina from an earlier version of macOS, the
read-only volume is created during the upgrade process. Files or data
that you previously stored in the startup volume are now stored in
this new volume, and some of these files may appear in a new folder
called Relocated Items. You can check this folder for any files that
you can’t locate.With macOS Catalina, you can no longer store files or data in the
read-only system volume, nor can you write to the «root» directory ( /
) from the command line, such as with Terminal.About the Relocated Items folder
While creating the two separate volumes during the upgrade process,
files and data that couldn’t be moved to their new location are placed
in a Relocated Items folder. The Relocated Items folder is in the
Shared folder within the User folder (/Users/Shared/Relocated Items)
and available though a shortcut on the Desktop. The Relocated Items
folder includes a PDF document with more details about these files.
*Copied from en-gb site, link will redirect your your local language site
See also Ask Different — Where does the upgrade to macOS Catalina move root “/” directory files?
Copied directly from Apple KB — About the read-only system volume in macOS Catalina*
TL:DR
With macOS Catalina, you can no longer store files or data in the read-only system volume, nor can you write to the «root» directory ( / ) from the command line, such as with Terminal.
macOS Catalina runs in a read-only system volume, separate from other files on your Mac. When you upgrade to Catalina, a second volume
is created, and some files may move to a Relocated Items folder.macOS Catalina runs on a dedicated, read-only system volume called
Macintosh HD. This volume is completely separate from all other data
to help prevent the accidental overwriting of critical operating
system files. Your files and data are stored in another volume named
Macintosh HD — Data. In the Finder, both volumes appear as Macintosh
HD.The Disk Utility app in macOS Catalina shows that Macintosh HD is
the read-only system volume and Macintosh HD — Data contains the the
rest of your files and data.If you upgrade to macOS Catalina from an earlier version of macOS, the
read-only volume is created during the upgrade process. Files or data
that you previously stored in the startup volume are now stored in
this new volume, and some of these files may appear in a new folder
called Relocated Items. You can check this folder for any files that
you can’t locate.With macOS Catalina, you can no longer store files or data in the
read-only system volume, nor can you write to the «root» directory ( /
) from the command line, such as with Terminal.About the Relocated Items folder
While creating the two separate volumes during the upgrade process,
files and data that couldn’t be moved to their new location are placed
in a Relocated Items folder. The Relocated Items folder is in the
Shared folder within the User folder (/Users/Shared/Relocated Items)
and available though a shortcut on the Desktop. The Relocated Items
folder includes a PDF document with more details about these files.
*Copied from en-gb site, link will redirect your your local language site
See also Ask Different — Where does the upgrade to macOS Catalina move root “/” directory files?
Jul 31, 2020 8:03 PM in response to gishouk
It appears as though you are attempting to create a directory at the root level of that Mac’s hard disk drive, which is off-limits in recent macOS versions.
/OpenFoam is not where you think it is. If you want to create that folder within /usr/local/bin/ then provide that fully qualified pathname:
/usr/local/bin/OpenFoam
Try using that in your curl command.
There was no need to change permissions the way you did. /usr/local/bin is writeable. Everyone should be Read only. Your User Account should be Read & Write and from your screenshot, it’s completely missing. I recommend undoing whatever you did to change that folder’s permissions.
Aug 1, 2020 12:56 AM in response to John Galt
The command I am using should create a directory automatically. I don’t have to create that directory myself.
I also tried to give a different path like /users/goharshoukat/opt but that too throws the same exception: /user resides on a read-only file system.
Aug 1, 2020 5:31 AM in response to gishouk
The command I am using should create a directory automatically. I don’t have to create that directory myself.
That is correct, but creating directories at the root level of a Mac’s startup disk is prohibited.
I also tried to give a different path like /users/goharshoukat/opt but that too throws the same exception: /user resides on a read-only file system.
That is correct. /user does not exist and cannot be created in recent macOS versions.
Consult the documentation for OpenFoam.