Mac pro升級 MacOS 10.15 Catalina 後根目錄是隻讀的, Recovery OS不能訪問

前言

升級這個事情儘量還是少做比較好,升級MacOS之後很多以前的文件換目錄了,頭痛了很久!因爲代碼裏面的目錄是從跟目錄開始的,數據轉移之後程序沒法跑起來,直接建立新目錄的話會報錯:

xuemins-MacBook-Pro:/ zhuxuemin$ mkdir -p /test
mkdir: /test: Read-only file system

當然很多百度出來的文章是關閉系統文件保護,然後執行csrutil disable
c。在開機狀態下按住alt鍵可以選擇RecoveryOS,但是我沒得那個選項。

估計找到了那個選項就可以了,我把方法也貼出來

方案一

Macbook pro 升級 MacOS 10.15 Catalina 後不能在根目錄 創建文件 文件夾,根目錄是隻讀的 ,不能創建不能移動 不能刪除

解決辦法:
1、關閉SIP 命令行執行csrutil disable 正常啓動
2、重新掛載根目錄 命令執行 sudo mount -uw /
3、命令執行 mount
操作完之後 爲了計算機安全可以打開 SIP 命令行執行csrutil enable 正常啓動
我這招不頂用

方案二

這個主要是synthetic.conf文件中的配置,首先可以使用man synthetic.conf看到這個文件的,我大致解釋一下:

  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 loca-
     tion. All writeable paths must reside on the data volume, which is mounted at /System/Volumes/Data.

這裏其實就是說在macOS 10.15之後物理文件是不能在root目錄下面穿件的,所有的文件都放到了/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 physi-
     cally present on the disk, but when the system is booted, they behave as if they were within certain parame-
     ters.

synthetic.conf提供了用戶希望把文件創建到/目錄下面的機制,當然即使我們這樣子看到,實際文件也不會真正放到根目錄下面,配置參數之後重啓會生效,其實這裏就是提供一種映射機制

     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.

synthetic.conf 的目的其實就是把目錄掛載到我們的/下面,其實這個就是我們要。
讀完之後我們可以瞭解到這個其實就是升級之後Mac提供給我們的官方做法。
於是乎我按照文檔配置。

sudo vim /etc/synthetic.conf
添加一行記錄(如果有兩列需要使用 tab 進行分割,注意空格分割是無效的),然後重啓即可
舉例
bar System/Volumes/Data/bar
將會在根目錄下創建 bar 軟連接到根目錄下的 System/Volumes/Data/bar 目錄

重啓之後我的目錄是這個樣子的:

......
lrwxr-xr-x   1 root  wheel    23  6 25 14:59 bar -> System/Volumes/Data/bar
......

這個是有效的~

後記

其實之前爲了做恢復模式下面改配置折騰了好久,後面纔看得這個配置,雖然最後比較簡單,我覺得可以幫到一部分人,便記錄下來了~~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章