macOS - How to Create a new Directory in Root Directory (/)?

macOS - How to Create a new Directory in Root Directory (/)?

Sasivarnan R Sasivarnan R · January 2, 2024 · 1 min read

Screenshot of terminal indicating the error while creating a 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 a space.

  • 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.

Screenshot of a Terminal showing the contents of root directory