Mac OS 如何在根目录创建文件夹
直接用sudo mkdir /newdir会报错Read-only file system,不能创建
可以通过在/etc下新建conf文件创建文件夹
1、创建synthetic.conf文件
sudo touch /etc/synthetic.conf
2、创建自己想要的文件夹,例如data
mkdir /Users/dicuu/data
3、vim 编辑synthetic.conf文件内容
data /Users/dicuu/data
Note: 注意两者之间用tab
连接,而不是空格
4、重启
就能在根目录下看到新建的data
文件夹了
通过manual命令可以看到synthetic.conf的官方手册解释了这个配置文件的功能,
可以看到macOS 10.15之前的系统可以通过挂载根目录并链接文件夹的方式,而之后的系统需要通过这个配置文件来达到类似的效果
synthetic.conf -- synthetic symbolic link and directory manifest
DESCRIPTION
synthetic.conf describes virtual symbolic links and empty directories to be created
at the root mount point. 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.
synthetic.conf provides a mechanism for some limited, user-controlled file-creation
at /. The synthetic entities described in this file are synthesized by the kernel
during early system boot. They are not physically present on the disk, but when the
system is booted, they behave as if they were within certain parameters.
synthetic.conf is intended to be used for creating mount points at / (e.g. for use as
NFS mount points in enterprise deployments) and symbolic links (e.g. for creating a
package manager root without modifying the system volume). synthetic.conf is read by
apfs.util(8) during early system boot.
FILES
/etc/synthetic.conf
EXAMPLES
# create an empty directory named "foo" at / which may be mounted over
foo
# 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
# create a symbolic link named "baz" at / which points to "Users/me/baz"
baz Users/me/baz