mirror of
https://github.com/systemd/systemd.git
synced 2025-03-08 08:58:27 +03:00
units/systemd-repart: stop pretending that root config is executed in the initrd
I have a system with /usr/lib/repart.d/50-root.conf with GrowFileSystem=yes. The partition wouldn't be resized in the initrd, because ConditionDirectoryNotEmpty=|/sysusr/usr/lib/repart.d was evaluated very early, before /sysroot was mounted. There was no ordering dependency between systemd-repart.service and sysroot.mount. (There was After=initrd-usr-fs.target, but it seems to be only referred to by systemd-fstab-generator, which in my case doesn't even run, because there's no fstab.) But in fact, we neeed to run systemd-repart in the initrd only in limited circumstances: when we need to create the root device based on config under sysusr.mount. If there is config on the root device, it can be executed in the host system, early during boot. Thus, let's remove the condition on /sysroot/…. Without an ordering dependency on sysroot.mount, it was subject to a race condition anyway. (A race condition with a low probability of "winning", because systemd-repart.service has no dependencies, but sysroot.mount requires a device to be detected and the mount to happen.) The other problem was that systemd-repart.service didn't have the ordering wrt. initrd-switch-root.target, so it was subject to the same race condition that was fixed for other units in 7c0e2b555968d70ac563a37e32a6931ee90961a6. (If the systemd-repart.service/stop job is slow, we could end up not restarting systemd-repart.service in the host system.) With the changes here, I see systemd-repart.service/start running twice: in the initrd it is skipped because the conditions fail, and then in the host system it runs normally. Note: support for /sysroot is retained in systemd-repart code. I don't see a strong reason to remove it, since it may still be useful to people invoking repart in the initrd in other circumstances.
This commit is contained in:
parent
ce37fb0d92
commit
d6f6846464
@ -16,9 +16,6 @@ ConditionDirectoryNotEmpty=|/usr/lib/repart.d
|
||||
ConditionDirectoryNotEmpty=|/usr/local/lib/repart.d
|
||||
ConditionDirectoryNotEmpty=|/etc/repart.d
|
||||
ConditionDirectoryNotEmpty=|/run/repart.d
|
||||
ConditionDirectoryNotEmpty=|/sysroot/usr/lib/repart.d
|
||||
ConditionDirectoryNotEmpty=|/sysroot/usr/local/lib/repart.d
|
||||
ConditionDirectoryNotEmpty=|/sysroot/etc/repart.d
|
||||
ConditionDirectoryNotEmpty=|/sysusr/usr/lib/repart.d
|
||||
ConditionDirectoryNotEmpty=|/sysusr/usr/local/lib/repart.d
|
||||
|
||||
@ -26,8 +23,8 @@ DefaultDependencies=no
|
||||
Wants=modprobe@loop.service modprobe@dm_mod.service
|
||||
After=initrd-usr-fs.target modprobe@loop.service modprobe@dm_mod.service
|
||||
Before=initrd-root-fs.target
|
||||
Conflicts=shutdown.target
|
||||
Before=shutdown.target
|
||||
Conflicts=shutdown.target initrd-switch-root.target
|
||||
Before=shutdown.target initrd-switch-root.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
|
Loading…
x
Reference in New Issue
Block a user