Bug 11776 - read-only rootfs + systemd: systemd-tmpfiles fails
Summary: read-only rootfs + systemd: systemd-tmpfiles fails
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 2.8 M2
Assignee: Chen Qi
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2017-07-10 19:26 UTC by Patrick Ohly
Modified: 2019-07-12 09:20 UTC (History)
4 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Ohly 2017-07-10 19:26:15 UTC
When booting a read-only rootfs with systemd as init system, systemd-tmpfiles.service fails with:


Jul 10 19:00:39 intel-corei7-64 systemd-tmpfiles[460]: [[0;1;31msymlink(/var/run/connman/resolv.conf, /etc/resolv.conf) failed: Read-only file sys
tem[[0m
Jul 10 19:00:39 intel-corei7-64 systemd[1]: Starting Rebuild Dynamic Linker Cache...
Jul 10 19:00:39 intel-corei7-64 systemd[1]: Starting Load/Save Random Seed...
Jul 10 19:00:39 intel-corei7-64 systemd-tmpfiles[460]: [[0;1;31m/etc/security/namespace.d does not exist and cannot be created as the file system 
is read-only.[[0m
Jul 10 19:00:39 intel-corei7-64 systemd-tmpfiles[460]: [[0;1;31m/etc/security/limits.d does not exist and cannot be created as the file system is 
read-only.[[0m
Jul 10 19:00:39 intel-corei7-64 systemd-tmpfiles[460]: [[0;1;31m/etc/network/if-down.d does not exist and cannot be created as the file system is 
read-only.[[0m
Jul 10 19:00:39 intel-corei7-64 systemd-tmpfiles[460]: [[0;1;31m/etc/systemd/network does not exist and cannot be created as the file system is re
ad-only.[[0m
Jul 10 19:00:39 intel-corei7-64 systemd-tmpfiles[460]: [[0;1;31m/etc/modprobe.d does not exist and cannot be created as the file system is read-on
ly.[[0m
Jul 10 19:00:39 intel-corei7-64 systemd-tmpfiles[460]: [[0;1;31m/etc/request-key.d does not exist and cannot be created as the file system is read
-only.[[0m
Jul 10 19:00:39 intel-corei7-64 systemd-tmpfiles[460]: [[0;1;31m/etc/depmod.d does not exist and cannot be created as the file system is read-only
.[[0m
Jul 10 19:00:39 intel-corei7-64 systemd-tmpfiles[460]: [[0;1;31m/etc/sysctl.d does not exist and cannot be created as the file system is read-only
.[[0m
Jul 10 19:00:39 intel-corei7-64 systemd-tmpfiles[460]: [[0;1;39m"/var/tmp" already exists and is not a directory.[[0m
Jul 10 19:00:39 intel-corei7-64 systemd-tmpfiles[460]: [[0;1;39m"/var/log" already exists and is not a directory.[[0m
Jul 10 19:00:39 intel-corei7-64 systemd[1]: [[0;1;39msystemd-tmpfiles-setup.service: Main process exited, code=exited, status=1/FAILURE[[0m

The ConnMan /etc/resolv.conf issue was already discussed with Maxin ("Re: [OE-core] [PATCH 1/2] systemd: enable resolved and networkd"), he is working on removing that tmpfiles.d entry because it shouldn't be active at all.

The other failures are a result of tmpfiles.d entries that are out of sync with the read-only content of /etc.

Several solutions are possible:
1. manually populate /etc in the systemd packaging
2. write some code similar to the existing code for sysusers.d which
   parses the tmpfiles.d config in the rootfs and creates the entries
   at image build time (see systemd_create_users in rootfs-postcommands.bbclass)
3. disable the tmpfiles.d entries that trigger the error

My preference is solution 2.

The issue can be reproduced in refkit by building and booting refkit-image-installer under qemu.

OE-core probably needs a test case for this configuration.
Comment 1 Chen Qi 2019-07-12 09:20:22 UTC
No such problem anymore in latest master branch.