Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the proper way to create a root sym link in Catalina

I need to replicate our production environment by having a directory placed at /reports/2019/, and as you know this is not possible in Catalina anymore (at least without disabling the SIP.

Doing that is actually disabling the security but I guess there is a proper way to do this.

Is there a way to create a symlink like /reports that is linked to the read-write volume without disabling SIP or not compromising the security?

like image 405
Federico Piazza Avatar asked Oct 15 '19 14:10

Federico Piazza


2 Answers

You can add symlinks to the root filesystem by adding entries to /etc/synthetic.conf.

From the synthetic.conf(5) man page:

synthetic.conf specifies a single synthetic entity per line. Each line may have one or two columns, separated by a tab character. If a line has a single column, it denotes a virtual empty directory to be created at /. If a line has two columns, it denotes a symbolic link at / whose link target is given in the second column.

So, if you had your writable directory at /Users/myself/reports, you could symlink it to /reports by doing the following:

  1. sudo vi /etc/synthetic.conf
  2. Add an entry reports Users/myself/reports, where the empty space is a tab (Ctrl-V + Tab) character.
  3. Reboot

The directory should show up after the reboot.

like image 97
squidpickles Avatar answered Oct 19 '22 19:10

squidpickles


Many thanks for documenting that @eqzx

In 2021 with Big Sur, things have changed a little bit. I got the crashloop for an undefined reason. Safe mode will NOT help you. Starting in recovery, as mentioned, is possible. Apple support will not help you but tell you to repair. Repairing the system will, beside waste your time, solve nothing.

The solution is:

  • start in recovery mode (CMD+R)
  • open a terminal
  • you may expect to see your synthetic.conf under /etc or private/etc... it won't be there
  • Mount the Data volumes: diskutil apfs unlock "Macintosh HD - Data"
  • If you are curious: diskutil info disk2s2
  • cd into the data volumes: cd /Volumes/"Macintosh HD - Data"
  • cd private/etc
  • from here you can remove the file with rm synthetic.conf

You can now reboot, create a new file, likely get stuck again :) and fix it with the same solution.

like image 4
Chevdor Avatar answered Oct 19 '22 18:10

Chevdor