Unable to create files in mac root directory

Unable to create files in mac root directory


The reason is that
mac os has introduced the System Integrity Protection (SIP) mechanism and cannot create new files in the / and /usr directories.

Solution 1:
Open the terminal and enter

csrutil status

Displaying enabled indicates that SIP is enabled, and you need to disable SIP next;

Restart your mac and hold down command+R to enter recovery mode;

Click the fourth column of utility tools in the upper left corner of the screen: Terminal, open the terminal, enter csrutil disable, and restart;

After restarting, you will find that you still cannot create new files and will prompt Read-only file system. At this time, you need to remount the root directory:

sudo mount -uw

After remounting, you can create a new folder, but this mount will become invalid after the computer is restarted, that is, it will revert to the Read-only file system after the restart;

To re-enable SIP, you need to re-enter recovery mode, enter csrutil enable and then restart.

Solution 2:

Create a new /etc/synthetic.conf file:

sudo vim /etc/synthetic.conf

Add directory mapping to the file. Each line is equivalent to creating a soft link. It contains three columns. The first column represents the directory name under the root directory/, and the second column is a tab key \t (cannot be a space). The third column is its own directory:

data	/Users/my/data

The above configuration is equivalent to ln -s /Users/my/data /data

Restart your mac and you will see an additional /data directory in the root directory.

Guess you like

Origin blog.csdn.net/wufagang/article/details/132741716