macOS - How to Create a new Directory in Root Directory (/)?
Tried to create a new directory at root directory of macOS but received an error - mkdir: folder-name: Read-only file system
?
Starting with macOS Catalina (version 10.15+), the root mount point is read-only, so physical files cannot be created at this location.
However, we can use virtual symbolic links to directories that exist outside of the root.
To do this, create a new file at /etc/synthetic.conf
and add the following line to it:
log Users/sasivarnan/log
The log
part is the name of the virtual folder that needs to be created in the root directory, and the Users/sasivarnan/log
part is the path where the actual folder on disk. The folder must already exist in that path.
Note:
The space between the two folder names is a
tab
, not aspace
.The virtual folder can be placed anywhere on disk, not just in the Users directory.
After creating the file, reboot your system. The /log
folder will then appear in the root directory.
Subscribe to my newsletter
Read articles from Sasivarnan R directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Sasivarnan R
Sasivarnan R
Software Engineer. Casual Gamer. Introvert