
我用來mount --bind
將一個ext4,rw
檔案系統中的檔案「覆蓋」到檔案系統中的另一個檔案上ext4,ro
。例如,/etc/hosts
位於唯讀分割區上,但我有另一個可寫入/
分割區。/rw/etc/hosts
所以當我這樣做時
# mount --bind /rw/etc/hosts /etc/hosts
任何寫入/etc/hosts
都會轉到/rw/etc/hosts
這在
CentOS 6.3
.
# mount -o ro /dev/sdc1 /ro
# mount -o rw /dev/sdc2 /rw
# mount --bind rw/test ro/test
# echo 1 > rw/test
# cat ro/test
1
# echo 2 > ro/test # [1]
# cat rw/test
2
但我無法讓它工作,CentOS 6.4
我重複上面的步驟,但在嘗試寫入時出現錯誤ro/test
:
# echo 2 > ro/test # [1]
-bash: ro/test: Read-only file system
SELinux
被禁用。有什麼想法可能會導致它停止工作嗎?
CentOS 6.3 核心:2.6.32-279.22.1.el6.x86_64
CentOS 6.4 核心:2.6.32-358.el6.x86_64
和2.6.32-358.2.1.el6.x86_64
答案1
有什麼想法可能會導致它停止工作嗎?
可能是與 fsfreeze 支援一起引入核心的錯誤。我打開了BZ #951311來跟踪這個。
答案2
# mount --bind rw/test ro/test
# echo 1 > rw/test
您只能掛載目錄。
您不能使用 echo 寫入目錄。
你可能想要
# mount --bind rw ro