2

我正在准备一个基于 Orange PI Zero 的 Buildroot IoT 项目,因此我将其设为只读系统。无论如何,当用户为他的 WiFi 网络配置 wpa_supplicant.conf 时,我需要在 /etc 上持续写入以更新它。如果用户愿意,我还需要使用一些配置参数更新自定义文本文件。

我想避免每次需要更新单个文件时都以 r/w 方式重新挂载整个文件系统。

实现这一目标的最佳方法是什么?

4

1 回答 1

2

您可以在 /etc 之上设置一个可写覆盖,以便进行更改。选项要么是内核中的 overlayfs,要么是使用 fuse 的 unionfs。由于 init / initscripts 已经使用 /etc,您可能需要在 init 周围创建一个包装脚本以在执行 init 之前设置此覆盖。- 例如:

mount -t proc proc /proc
mount /mnt/data
mount -o bind /etc/ /mnt/rom-etc
unionfs -o cow,allow_other,use_ino,nonempty \
        mnt/data=RW:/mnt/rom-etc=RO /etc/
exec /sbin/init $*
于 2018-03-05T08:51:02.017 回答