1

I'm currently working on an embedded linux device, i'm trying to make the file system read only which is fairly easy to do, but the application requires read/write access to files in /etc folder (mainly passwd and shadow) those cannot be moved out to the persist partition and linked back to /etc. I came up with a "solution" not sure if it is a good thing or not and that is why I'm posting here.

Basically what I'm planning to do is make the whole file system read only (including /etc), then add a file /etc/rw-files which will hold paths to files that require read/write privileges for the device to work properly. on each boot I will have a script go through that list of files and folder and remount them as read/write using something like this :

mount --bind directory directory 
mount -o remount,rw directory directory 

i tested this, it is working and device is behaving as it should but i'm still not quite sure of the quality of it.

2

You could look at using the overlayfs filesystem. In a single mount you can superimpose a small readwrite /etc on top of your large readonly /etc, and present a merged filesystem where any changes will be preserved in the upper readwrite layer directory. It is all automatic so you don't need to identify which files need readwrite.

  • that was what i was going at first but i was thinking minimal ram and space usage. i'll give it another go see how it impacts the whole thing. – TheBrash Dec 21 '16 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.