24

I am running macOS 10.15.4 and I need to create a non-user specific folder at the based of primary volume (Macintosh HD), but Finder does not allow me (option greyed out) and from the terminal I get denied.

From terminal:

mkdir /MyFolder
mkdir: /MyFolder: Read-only file system

Can anyone explain how this can be done? It was definitely possible in the past, before Catalina.

bmike
  • 235,889
Andre M
  • 420
  • 1
    As the error noted, the system is now read-only, so the only thing you can do is disable that (not recommended) or fake it - see the synthetic.conf man page for synthesizing a mount point at the root folder. – red_menace Apr 13 '20 at 19:15
  • How about creating the folder in /Users/Shared instead (that's prety much what it's there for)? – Gordon Davisson Apr 13 '20 at 19:18
  • I'll take a look at synthetic.conf. Turns out there is /System/Volumes/Data/, but it is a shame Apple didn't opt to make a unified view in the Finder. The /Users/Shared folder might be okay for some stuff, but for /Servers/ (one of the folders) which should be root only is not ideal and also conceptually out of place. – Andre M Apr 13 '20 at 19:34
  • The other standard place is /usr/local – mmmmmm Apr 13 '20 at 22:03

3 Answers3

28

In Catalina the primary volume is read-only. This means it is not immediately possible to create new folders here.

In order to get around that, the system provides what is known as synthetic firm links. This allows you to create what appears to be folders at the root of the file system.

You need to create the file /etc/synthetic.conf, which should be owned by root and group wheel with permissions 0644.

The contents should look like this:

newfolder     Users/foo/bar

"newfolder" is the name of the virtual folder that will be created in the root of the file system. "Users/foo/bar" is the actual location of the folder. You need to ensure that this folder actually exists. It doesn't need to be inside Users, but can be anywhere in your system.

NOTE: It is important to ensure that the space between the two folder names is a TAB character, and not just a number of space.

After creating the file above with the specified contents, you need to reboot the system. After rebooting, you'll see the /newfolder folder.

jksoegaard
  • 77,783
  • Thanks. BTW per trying it out myself, there is no need for recovery mode to create /etc/synthetic.conf, but a reboot is necessary for changes to take impact. I created the new folder in System/Volumes/Data, per other suggestions. I was caught out by the tab separator, Also Apple KB entry on this change: https://support.apple.com/en-ca/HT210650 – Andre M Apr 13 '20 at 19:53
  • 1
    @DaniilIaitskov /System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t stitches and creates synthetic objects on root volume group according to man apfs.util, since macOS 11 Big Sur. – cachius Sep 21 '22 at 14:34
7

Here's a copy and paste for terminal to set this up:

# Be sure to change:
# FOLDER_NAME   - the root folder name. 
# ACTUAL_PATH_TO_REAL_FOLDER - the path to the "real" folder.
# 
#    Example: 
#    "Drives    Users/bob/Documents/Drives"
#    .......^ this is tab (not spaces)
#    Both of FOLDER_NAME and ACTUAL_PATH_TO_REAL_FOLDER are not starting with /

sudo touch /etc/synthetic.conf sudo chmod 0666 /etc/synthetic.conf sudo echo "FOLDER_NAME ACTUAL_PATH_TO_REAL_FOLDER" >> /etc/synthetic.conf sudo chmod 0644 /etc/synthetic.conf sudo chown root:wheel /etc/synthetic.conf

nohillside
  • 100,768
2

According to man synthetic.conf:

Because the root mount point is read-only as of macOS 10.15, physical files may not be created at this location. All writeable paths must reside on the data volume, which is mounted at /System/Volumes/Data.

As a work around, the documentation suggests to use /etc/synthetic.conf to create virtual symbolic links or empty directories at the root mount point.

Three examples (via man page)

In each case, append the following to /etc/synthetic.conf

# example 1: create an empty directory named "foo" at / which may be mounted over
foo

example 2: create a symbolic link named "bar" at / which points to

"System/Volumes/Data/bar", a writeable location at the root of the data volume

bar System/Volumes/Data/bar

example 3: create a symbolic link named "baz" at / which points to "Users/me/baz"

baz Users/me/baz

Note: the words must be separated by tabs. Unfortunately, StackOverflow renders tabs as spaces.

Automation

echo -e "baz\tUsers/me/baz" | sudo tee -a /etc/synthetic.conf
Michael
  • 191