2

I'm preparing a Buildroot IoT project based on Orange PI Zero, so I will make it a readonly system. Anyway, I need to persistently write on /etc to update wpa_supplicant.conf when user configure it for his WiFi network. I also need to update a custom text file with some config parameters, if the user want to.

I'd like to avoid remounting the whole filesystem in r/w everytime I need to update a single file.

Which is the best way to accomplish this?

flip79
  • 1,178
  • 2
  • 15
  • 28

1 Answers1

2

You can set up a writable overlay on top of /etc so changes goes there. Options are either overlayfs in the kernel or unionfs using fuse. As init / initscripts already use /etc you may need to create a wrapper script around init to setup this overlay before executing init. - E.G. something like:

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 $*
Peter Korsgaard
  • 626
  • 4
  • 3