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
Tags:none

文章来源网络,如若侵权,请联系作者删除
参考文章: https://juejin.cn/post/7231156908370116664

著作权归作者所有。
商业转载请联系作者获得授权,非商业转载请注明出处。
原文作者:liwiki
原文标题:Mac OS 如何在根目录创建文件夹
原文链接:https://blog.dicuu.com/mac/344.html

上一篇
打赏
没有啦~

添加新评论