Go to file
Yann E. MORIN 26085bbbd5 system: make systemd work on a read-only rootfs
When the rootfs is readonly, systemd will expect /var to be writable.
Because we do not really have a R/W filesystem to mount on /var, we make
it a tmpfs [*], and use the systemd-tmpfiles feature to populate it with
"factory" defaults.

We obtain those factory defaults by redirecting /var to that location at
build time, using a symlink /var -> /usr/share/factory which is the
location in which systemd-tmpfiles will look for when instructed to
"recursively copy" a directory.

With a line like:

    C /var/something - - - -

it will look for /usr/share/factory/something and copy it (recursively
if it is a directory) to /var/something, but only if it does not already
exist there.

We also mark this copy with the exclamation mark, as it is only safe to
copy on boot, not when changing targets.

To be noted: the real format for such lines are:

    C /var/something - - - - /from/where/to/copy/something

But if the source is not given, then it is implicitly taken from
/usr/share/factory (which in our case is as-good a location as whatever
else, so we use it, and thus we need not specify the source of the
copy).

Note that we treat symlinks a little bit specially, by creating symlinks
to the factory defaults rather than copying them.

Finally, /var at build time is a symlink, but at runtime, it must be a
directory (so we can mount the tmpfs over there). We can't change that
as a target-finalize hook, because:

  - some packages may want to set ownership and/or access rights on
    files or directories in /var, and that only happens while assembling
    the filesystem images; changing /var from a symlink to a (then
    empty) directory would break this;

  - /var would be a directory on sub-sequent builds (until the next
    "make clean").

Instead, we use the newly-introduce pre- and post-rootfs command hooks,
to turn /var into a directory before assembling the image, and back to a
symlink after assembling the image.

[*] People who want the factory-defaults only on first boot will have
    to tweak the fstab to mount something else than a tmpfs on /var.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: Romain Naour <romain.naour@gmail.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2017-08-02 20:59:27 +02:00
arch arch/arm: add big.LITTLE cpu variants 2017-07-22 23:29:24 +02:00
board configs/armadeus_apf27: bump to kernel 4.12.4 2017-07-31 19:35:19 +02:00
boot uboot: bump to version 2017.07 2017-07-21 22:43:36 +02:00
configs configs/armadeus_apf27: bump to kernel 4.12.4 2017-07-31 19:35:19 +02:00
docs core/legal-info: use hash file from version sub-dir 2017-07-29 22:34:41 +02:00
fs fs: add pre- and post-command hooks 2017-08-02 20:58:27 +02:00
linux linux: bump default to version 4.12.4 2017-07-29 15:38:16 +02:00
package system: make systemd work on a read-only rootfs 2017-08-02 20:59:27 +02:00
support support/testing: add runtime testing for init systems 2017-08-02 17:42:49 +02:00
system system: make systemd work on a read-only rootfs 2017-08-02 20:59:27 +02:00
toolchain arch/arm: add big.LITTLE cpu variants 2017-07-22 23:29:24 +02:00
utils utils/readme.txt: add documentation of genrandconfig 2017-07-29 15:41:09 +02:00
.defconfig arch: remove support for sh64 2016-09-08 22:15:15 +02:00
.gitignore
.gitlab-ci.yml support/testing: add runtime testing for init systems 2017-08-02 17:42:49 +02:00
.gitlab-ci.yml.in .gitlab-ci.yml: save rootfs as artifact for runtime tests 2017-07-31 21:23:25 +02:00
CHANGES CHANGES: update after binutils changes 2017-08-01 23:40:09 +02:00
Config.in Config.in: add BR2_HOST_GCC_AT_LEAST_7 2017-07-05 16:20:27 +02:00
Config.in.legacy binutils: remove support for 2.26 2017-08-01 23:38:05 +02:00
COPYING COPYING: add exception about patch licensing 2016-02-26 19:50:13 +01:00
DEVELOPERS let-me-create: new package 2017-07-29 23:10:41 +02:00
Makefile Makefile: add alldefconfig target 2017-07-25 23:06:58 +02:00
Makefile.legacy Remove BR2_DEPRECATED 2016-10-15 23:14:45 +02:00
README README: add reference to submitting-patches 2016-02-01 19:16:08 +01:00

Buildroot is a simple, efficient and easy-to-use tool to generate embedded
Linux systems through cross-compilation.

The documentation can be found in docs/manual. You can generate a text
document with 'make manual-text' and read output/docs/manual/manual.text.
Online documentation can be found at http://buildroot.org/docs.html

To build and use the buildroot stuff, do the following:

1) run 'make menuconfig'
2) select the target architecture and the packages you wish to compile
3) run 'make'
4) wait while it compiles
5) find the kernel, bootloader, root filesystem, etc. in output/images

You do not need to be root to build or run buildroot.  Have fun!

Buildroot comes with a basic configuration for a number of boards. Run
'make list-defconfigs' to view the list of provided configurations.

Please feed suggestions, bug reports, insults, and bribes back to the
buildroot mailing list: buildroot@buildroot.org
You can also find us on #buildroot on Freenode IRC.

If you would like to contribute patches, please read
https://buildroot.org/manual.html#submitting-patches