Commit Graph

58726 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
45bcfcb36c units/initrd-parse-etc.service: only start units that are required
This makes use of the option switch that was added in the previous commit.
We used a pretty big hammer on a relatively small nail: we would do daemon-reload
and (in principle) allow any configuration to be changed. But in fact we only
made use of this in systemd-fstab-generator. systemd-fstab-generator filters
out all mountpoints except /usr and those marked with x-initrd.mount, i.e. on
a big majority of systems it wouldn't do anything.

Also, since systemd-fstab-generator first parses /proc/cmdline, and then
initrd's /etc/fstab, and only then /sysroot/etc/fstab, configuration in the
host would only matter if it the same mountpoint wasn't configured "earlier".
So the config in the host could be used for new mountpoints, but it couldn't
be used to amend configuration for existing mountpoints. And we wouldn't actually
remount anything, so mountpoints that were already mounted wouldn't be affected,
even if did change some config.

In the new scheme, we will parse /sysroot/etc/fstab and explicitly start
sysroot-usr.mount and other units that we just wrote. In most cases (as written
above), this will actually result in no units being created or started.

If the generator is invoked on a system with /sysroot/etc/fstab present,
behaviour is not changed and we'll create units as before. This is needed so
that if daemon-reload is later at some points, we don't "lose" those units.

There's a minor bugfix here: we honour x-initrd.mount for swaps, but we
wouldn't restart swap.target, i.e. the new swaps wouldn't necessarilly be
pulled in immediately.
2022-07-23 19:02:39 +02:00
Zbigniew Jędrzejewski-Szmek
028a981c00 fstab-generator: add mode to check /sysroot/etc/fstab and maybe do daemon-reload
The idea is that we can peek into /sysroot/etc/fstab and figure out if there's
anything interesting there. We could use a separate binary for this, but we'd
need to duplicate most of the logic that in systemd-fstab-generator. Thus I
think it's nicer to make systemd-fstab-generator work as a multi-call binary.

If called as systemd-sysroot-fstab-check, we look for units that we'd mount and
call daemon-reload and initrd-fs.target/restart, similarly to what we did
before, but in the process itself.
2022-07-23 19:02:39 +02:00
Zbigniew Jędrzejewski-Szmek
5df2a4a6e0 Use a common define for the reload timeout 2022-07-22 22:34:20 +02:00
Zbigniew Jędrzejewski-Szmek
6ce4de290f man: make bootup charts narrower
docbook already indents diagrams, so there is no need to leave whitespace on
the left. Also, make the charts a bit narrower to fit better on a terminal.
2022-07-22 22:34:20 +02:00
Zbigniew Jędrzejewski-Szmek
8e34fdbd91 various: reword message 2022-07-22 22:34:20 +02:00
Zbigniew Jędrzejewski-Szmek
4e91024177 gpt-auto-generator: include device name in error 2022-07-22 22:33:30 +02:00
Zbigniew Jędrzejewski-Szmek
22e54dd6de booctl: do not say uuids differ if one of the uuids is unset
We allow ESP autodetection to fail, e.g. if it is not mounted, but then we'd
say that the detected one is different than the one reported by the bootloader,
which is rather confusing.

While at it, if we actually detect a mismatch, print the two uuids.
2022-07-18 10:01:27 +02:00
Zbigniew Jędrzejewski-Szmek
ff52ff2565 fstab-generator: do not skip /sysroot prefix if the mount point is missing
When chase_symlinks() is called on something on a doesn't exist, it immediately
returns an error. But we were relying on it to prepend "/sysroot/". If it
fails, we need to do that ourselves.

For example, with /sysroot/etc/fstab containing a line for /foo, if /sysroot/foo
doesn't exist, we'd generate a mount point for /foo.
2022-07-15 15:48:05 +02:00
Zbigniew Jędrzejewski-Szmek
640dc2f3ad fsck,sulogin: fix cargo-culted comment 2022-07-15 15:48:05 +02:00
Zbigniew Jędrzejewski-Szmek
da69e8e430 fstab-generator: rename 'post' variable
Originally (6b1dc2bd3c) we had 'pre' and 'post'
to refer to remote-fs-pre.target and remote-fs.target or local-fs-pre.target
and local-fs.target. But 'pre' is long gone, and 'post' by itself doesn't
make much sense. Rename it for clarity.
2022-07-15 15:48:05 +02:00
Zbigniew Jędrzejewski-Szmek
4981427cd4 fstab-generator: tweak comments 2022-07-15 15:48:05 +02:00
Zbigniew Jędrzejewski-Szmek
99e3d47679 fstab-generator: allow overriding path to /sysroot/etc/fstab too
This adds $SYSTEMD_SYSROOT_FSTAB analoguous to $SYSTEMD_FSTAB.
2022-07-15 15:48:05 +02:00
Zbigniew Jędrzejewski-Szmek
7772c177b8 fstab-generator: properly report the source of data
Mount information can come from /etc/fstab, /sysroot/etc/fstab, and
/proc/cmdline. Even when we had the path to the right source handy, we would
often write something inaccurate. In particular, in the initrd, we would
generally write "/etc/fstab" instead of "/sysroot/etc/fstab" for no good
reason.
2022-07-15 15:48:05 +02:00
Zbigniew Jędrzejewski-Szmek
efc5fd3d72 fstab-generator: use path_equal() to detect alternate spellings of /usr
In the initrd we would treat e.g. "/usr/" as different from "/usr", which
doesn't seem right.
2022-07-15 15:48:05 +02:00
Zbigniew Jędrzejewski-Szmek
911017f052 generators: only redirect logging when invoked by systemd
We would always print output to the kmsg or journal, but that is only needed
and useful when invoked by systemd. So let's skip redirection unless we are
invoked by systemd. Otherwise, let's log normally. This makes test invocations
easier, and also helps when the generator is invoked by mistake. If redirection
is necessary, the generator can be invoked with SYSTEMD_LOG_TARGET=… even
during tests.
2022-07-15 15:48:05 +02:00
Zbigniew Jędrzejewski-Szmek
494f4ee9c7 basic/log: split out invoked_by_systemd() utility function 2022-07-15 15:47:23 +02:00
Zbigniew Jędrzejewski-Szmek
17021368fc generators: accept one or three args, do not write to /tmp
Since the general generator logic was established in the rewrite in
07719a21b6, generators would always write to /tmp
by default. I think this not a good default at all, because generators write a
bunch of files and would create a mess in /tmp. And for debugging, one
generally needs to remove all the files in the output directory, because
generators will complain in the output paths are already present. Thus the
approach of disabling console logging and writing many files to /tmp when
invoked with no arguments is not nice, so let's disallow operation with no
args.

But when debugging, one generally does not care about the separate output dirs
(most generators use only one). Thus the general pattern I use is something
like:
  rm -rf /tmp/x && mkdir /tmp/x && build/some-generator /tmp/{x,x,x}
This commit allows only one directory to be specified and simplifies this to:
  rm -rf /tmp/x && mkdir /tmp/x && build/some-generator /tmp/x
2022-07-15 13:10:39 +02:00
Zbigniew Jędrzejewski-Szmek
b711a9ee18 bless-boot-generator: use DEFINE_MAIN_GENERATOR_FUNCTION()
DEFINE_MAIN_GENERATOR_FUNCTION() always sets dest*, so there should be no
change in behaviour.
2022-07-15 13:10:34 +02:00
Zbigniew Jędrzejewski-Szmek
b8110a3eb8 hibernate-resume-generator: use DEFINE_MAIN_GENERATOR_FUNCTION()
DEFINE_MAIN_GENERATOR_FUNCTION() always sets dest*, so there should be no
change in behaviour.
2022-07-15 13:09:38 +02:00
Zbigniew Jędrzejewski-Szmek
78f8ce6d90 environment-d-generator: use DEFINE_MAIN_FUNCTION() 2022-07-14 19:25:15 +02:00
Zbigniew Jędrzejewski-Szmek
9cfc294fe0 man: fix formatting of "BARRIER=1"
Whitespace inside of the <varname> field was propagated to the displayed form,
causing strange indentation.
2022-07-14 19:25:15 +02:00
Zbigniew Jędrzejewski-Szmek
8f41e6b636 core: wrap long comments and capitalize sentences 2022-07-14 19:25:15 +02:00
Lennart Poettering
93cbc9ca12 base-filesystem: pick more conservative access mode for /root/
Let's not allow anyone to look into /root/ if we create it via the
base-filesystem logic. i.e. change 0755 → 0750 as default access mode
for /root/, in case we create it if it happens to be missing.
2022-07-14 18:18:34 +02:00
Lennart Poettering
6ecc6c4536 Merge pull request #24008 from poettering/tmpfiles-is-dir-fix
tmpfiles: fix wrong is_dir_fd() call
2022-07-14 18:16:07 +02:00
undef
e9a28b8ccd growfs: Expand FS even if underlying block expansion fails
This allows growfs to expand the filesystem even when the underlying
block device cannot be expanded. This has been useful for example on
LUKS devices that have already been expanded using systemd-repart.

This works around the following error:
```
root@mobian:/home/mobian# /usr/lib/systemd/systemd-growfs /
crypt_resize() of /dev/block/179:2 failed: Operation not permitted
```
2022-07-14 18:13:23 +02:00