New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
systemd forgets mounts during transition from initrd #28452
Comments
After looking at differences between journals from both versions, the main difference is in the
|
Maybe 7c764d4 could be the culprit, since in the commit message it says:
|
Do you have a reproducer that doesn't require DVDs and grub and whatnot? |
I was wondering how to incorporate that into our test suite (since we definitely want this covered), and thanks to @poettering's creds infra I came up with: diff --git a/test/TEST-01-BASIC/test.sh b/test/TEST-01-BASIC/test.sh
index d0e714ac30..474a86be5c 100755
--- a/test/TEST-01-BASIC/test.sh
+++ b/test/TEST-01-BASIC/test.sh
@@ -23,4 +23,26 @@ test_append_files() {
cp -v "$TEST_UNITS_DIR"/{testsuite-01,end}.service "$TEST_UNITS_DIR/testsuite.target" "$dst"
}
+run_qemu_hook() {
+ local extra="$WORKDIR/initrd.extra"
+
+ mkdir -m 755 "$extra"
+ mkdir -m 755 "$extra/etc" "$extra/etc/systemd" "$extra/etc/systemd/system" "$extra/etc/systemd/system/initrd.target.wants"
+
+ cat >"$extra/etc/systemd/system/initrd-run-mount.service" <<EOF
+[Unit]
+Description=Create a mount in /run that should survive the transition from initrd
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=sh -xec "mkdir /run/initrd-mount-source /run/initrd-mount-target; mount -v --bind /run/initrd-mount-source /run/initrd-mount-target"
+EOF
+ ln -svrf "$extra/etc/systemd/system/initrd-run-mount.service" "$extra/etc/systemd/system/initrd.target.wants/initrd-run-mount.service"
+
+ (cd "$extra" && find . | cpio -o -H newc -R root:root > "$extra.cpio")
+
+ INITRD_EXTRA="$extra.cpio"
+}
+
do_test "$@"
diff --git a/test/units/testsuite-01.sh b/test/units/testsuite-01.sh
index 780f37ee12..a1193ce6fb 100755
--- a/test/units/testsuite-01.sh
+++ b/test/units/testsuite-01.sh
@@ -19,6 +19,11 @@ if systemd-detect-virt -q --container; then
test ! -e /run/systemd/container
cp -afv /tmp/container /run/systemd/container
else
+ # We should've created a mount under /run in initrd (see the other half of the test)
+ # that should've survived the transition from initrd to the real system
+ test -d /run/initrd-mount-target
+ mountpoint /run/initrd-mount-target
+
# We bring the loopback netdev up only during a full setup, so it should
# not get brought back up during reexec if we disable it beforehand
[[ "$(ip -o link show lo)" =~ LOOPBACK,UP ]] The only downside is that you need the initrd to already contain the latest systemd version (which is not an issue in CIs). With that in mind the TEST-01 now fails with:
whereas with F38's systemd it passes. |
Please submit that as PR. |
I wanted the test case to go together with a potential fix, so it should, hopefully, be part of #28454. |
Please do anyway. If the PR fails, then we know the test works, and then we can stuff the fix into the PR. |
Since 7c764d4 we bind mount certain directories during switch root instead of moving the mount directly, and for /run we do this without MS_REC. This, unfortunately, leaves all mounts under /run behind in the old root, which breaks certain use cases. See: systemd#28452
-> #28456 |
Since 7c764d4 we bind mount certain directories during switch root instead of moving the mount directly, and for /run we do this without MS_REC. This, unfortunately, leaves all mounts under /run behind in the old root, which breaks certain use cases. See: systemd#28452
Since 7c764d4 we bind mount certain directories during switch root instead of moving the mount directly, and for /run we do this without MS_REC. This, unfortunately, leaves all mounts under /run behind in the old root, which breaks certain use cases. See: systemd#28452
Since 7c764d4 we bind mount certain directories during switch root instead of moving the mount directly, and for /run we do this without MS_REC. This, unfortunately, leaves all mounts under /run behind in the old root, which breaks certain use cases. See: systemd#28452
Since 7c764d4 we bind mount certain directories during switch root instead of moving the mount directly, and for /run we do this without MS_REC. This, unfortunately, leaves all mounts under /run behind in the old root, which breaks certain use cases. See: systemd#28452
There are applications that rely on mounts under /run surviving the switch from initrd to rootfs, so use MS_REC unless we are soft rebooting. Follow-up for 7c764d4 Fixes systemd#28452
Since 7c764d4 we bind mount certain directories during switch root instead of moving the mount directly, and for /run we do this without MS_REC. This, unfortunately, leaves all mounts under /run behind in the old root, which breaks certain use cases. See: systemd#28452
There are applications that rely on mounts under /run surviving the switch from initrd to rootfs, so use MS_REC unless we are soft rebooting. Follow-up for 7c764d4 Fixes systemd#28452
Since 7c764d4 we bind mount certain directories during switch root instead of moving the mount directly, and for /run we do this without MS_REC. This, unfortunately, leaves all mounts under /run behind in the old root, which breaks certain use cases. See: systemd#28452
There are applications that rely on mounts under /run surviving the switch from initrd to rootfs, so use MS_REC unless we are soft rebooting. Follow-up for 7c764d4 Fixes systemd#28452
Since 7c764d4 we bind mount certain directories during switch root instead of moving the mount directly, and for /run we do this without MS_REC. This, unfortunately, leaves all mounts under /run behind in the old root, which breaks certain use cases. See: systemd#28452
There are applications that rely on mounts under /run surviving the switch from initrd to rootfs, so use MS_REC unless we are soft rebooting. Follow-up for 7c764d4 Fixes systemd#28452
Since 7c764d4 we bind mount certain directories during switch root instead of moving the mount directly, and for /run we do this without MS_REC. This, unfortunately, leaves all mounts under /run behind in the old root, which breaks certain use cases. See: systemd#28452
There are applications that rely on mounts under /run surviving the switch from initrd to rootfs, so use MS_REC unless we are soft rebooting. Follow-up for 7c764d4 Fixes systemd#28452
Since 7c764d4 we bind mount certain directories during switch root instead of moving the mount directly, and for /run we do this without MS_REC. This, unfortunately, leaves all mounts under /run behind in the old root, which breaks certain use cases. See: systemd#28452
systemd version the issue has been seen with
254-rc2
Used distribution
Fedora Rawhide
Linux kernel version used
No response
CPU architectures issue was seen on
None
Component
No response
Expected behaviour you didn't see
We've got a couple of reports [0][1] regarding missing mounts and after some playing around with Fedora-Server-dvd-x86_64-Rawhide-20230718.n.0.iso it looks like systemd forgets mounts mounted in initrd when transitioning to the "real" system:
Reproducer:
The same thing with Fedora-Server-dvd-x86_64-38-1.6.iso works as expected (i.e. the mounts are present after the initrd transition).
Unexpected behaviour you saw
No response
Steps to reproduce the problem
No response
Additional program output to the terminal or log subsystem illustrating the issue
No response
The text was updated successfully, but these errors were encountered: