[yocto] How handle files needing updates in read-only filesystem

Ulf Samuelsson yocto at emagii.com
Thu Jun 14 14:02:54 PDT 2018


I looked at the populate-volatile.sh, and this seemed to almost do the job,
if I solve the problem using symlinks.
What it needs is a copy file function.
As a temporary solution, I  created a derivative: populate-settings.sh
which will check /etc/default/settings in the same way populate-volatile.sh
checks /etc/default/volatiles.

It also support copying a file, if the copy target does not exist.

What I have right now is a ”writeable.bbclass”
To make a file located in a read-only location, I just inherit writeable and declare it writeable in a bbappend.

inherit writeable
WRITEABLE = ”/etc/localtime”

At build time, the ”/etc/localtime” is moved to ”/etc/update/localtime”, and ”/etc/localtime” becomes a symlink to ”/persistent/localtime”
(a leading ”/etc” is shaved off)
An entry to copy ”/etc/update/localtime” to “/persistent/localtime” is created in 
“/etc/default/settings/99_tzdata” 
When “/etc/init.d/populate-settings.sh” is run,  “/persistent/localtime” is created.

This works.

Efficiency is on several levels.
I am looking for a solution, where I, like above, only need to declare the name of the file. I want to avoid solutions, where I manually have to add symlinks etc.

Once the symlink/bind mount is accessed, it should not eat up the CPU cycles,
Kno
Best Regards,
Ulf Samuelsson


> 14 juni 2018 kl. 01:02 skrev Andre McCurdy <armccurdy at gmail.com>:
> 
>> On Wed, Jun 13, 2018 at 9:28 AM, Ulf Samuelsson <yocto at emagii.com> wrote:
>> Thanks, is it more efficient than symlinking?
> 
> Efficient in what way?
> 
> Have you looked at the volatile-binds recipe in oe-core? Its job is to
> setup enough bind mounts to enable systemd to run from a readonly
> rootfs. Although it's currently systemd specific (it only provides a
> systemd service file, no init script) it might give you some clues
> about how to setup bind mounts at boot time.
> 
>> Best Regards,
>> Ulf Samuelsson
>> 
>>> 13 juni 2018 kl. 15:20 skrev Anders Darander <anders at chargestorm.se>:
>>> 
>>> * Ulf Samuelsson <yocto at emagii.com> [180612 22:01]:
>>> 
>>>> We want most of /etc to be read-only for security reasons,
>>>> and the overlayfs will make the whole of /etc writeable.
>>> 
>>>> I tried mount —bind /etc/timezone /persistent/etc/timezone, and it
>>>> complained that they were not directories. Bind mounting /etc again
>>>> will make all of /etc writeable.
>>> 
>>> Try to use: mount —o bind /etc/timezone /persistent/etc/timezone
>>> 
>>> I'm using that heavily, either manually or by the volatile-binds recipe.
>>> It works perfectly fine with files.
>>> 
>>>> Symlinking to /persistent is fine, so the question is what an
>>>> acceptable method is to have a simple way of ensuring that a certain
>>>> file is converted to that symlink.
>>> 
>>> This is normally done by a manual inspection / addition of bbappend
>>> file.
>>> 
>>> Cheers,
>>> Anders
>>> --
>>> Anders Darander, Senior System Architect
>>> ChargeStorm AB / eStorm AB
>> 
>> --
>> _______________________________________________
>> yocto mailing list
>> yocto at yoctoproject.org
>> https://lists.yoctoproject.org/listinfo/yocto



More information about the yocto mailing list