]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/core/execute.c
dissect: introduce new recognizable partition types for /var and /var/tmp
authorLennart Poettering <lennart@poettering.net>
Wed, 18 Dec 2019 11:22:40 +0000 (12:22 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 23 Dec 2019 13:43:59 +0000 (14:43 +0100)
commitd4dffb8533a038fd42da8aae00ed2b09495dedb0
tree16d797db584eb3e67cc810848e12bdd42f44158f
parent4171837be6b8c92886727a04616c4d2b6d123e22
dissect: introduce new recognizable partition types for /var and /var/tmp

This has been requested many times before. Let's add it finally.

GPT auto-discovery for /var is a bit more complex than for other
partition types: the other partitions can to some degree be shared
between multiple OS installations on the same disk (think: swap, /home,
/srv). However, /var is inherently something bound to an installation,
i.e. specific to its identity, or actually *is* its identity, and hence
something that cannot be shared.

To deal with this this new code is particularly careful when it comes to
/var: it will not mount things blindly, but insist that the UUID of the
partition matches a hashed version of the machine-id of the
installation, so that each installation has a very specific /var
associated with it, and would never use any other. (We actually use
HMAC-SHA256 on the GPT partition type for /var, keyed by the machine-id,
since machine-id is something we want to keep somewhat private).

Setting the right UUID for installations takes extra care. To make
things a bit simpler to set up, we avoid this safety check for nspawn
and RootImage= in unit files, under the assumption that such container
and service images unlikely will have multiple installations on them.
The check is hence only required when booting full machines, i.e. in
in systemd-gpt-auto-generator.

To help with putting together images for full machines, PR #14368
introduces a repartition tool that can automatically fill in correctly
calculated UUIDs on first boot if images have the var partition UUID
initialized to all zeroes. With that in place systems can be put
together in a way that on first boot the machine ID is determined and
the partition table automatically adjusted to have the /var partition
with the right UUID.
src/core/execute.c
src/dissect/dissect.c
src/gpt-auto-generator/gpt-auto-generator.c
src/nspawn/nspawn.c
src/portable/portable.c
src/shared/dissect-image.c
src/shared/dissect-image.h
src/shared/gpt.h
src/shared/machine-image.c
src/test/test-dissect-image.c