]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-08-INITRD: Set up exitrd on boot rather than including in image
authorDaan De Meyer <daan@amutable.com>
Thu, 21 May 2026 10:25:03 +0000 (10:25 +0000)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 21 May 2026 16:06:07 +0000 (18:06 +0200)
Just copy the initramfs from the VM rather than doing it during
the image build.

mkosi/mkosi.conf
mkosi/mkosi.initrd.conf/mkosi.extra/usr/lib/systemd/system/initrd-run-initramfs.service [new file with mode: 0644]
test/integration-tests/TEST-08-INITRD/meson.build
test/units/TEST-08-INITRD.sh

index a6966de2058fb9e6067a00404f98e7b3d79d9d80..d539b65e00d737bc6e126ae4f4d3437e4305c8bd 100644 (file)
@@ -55,7 +55,6 @@ ExtraTrees=
         %O/minimal-1.root-%a-verity.raw:/usr/share/minimal_1.verity
         %O/minimal-1.root-%a-verity-sig.raw:/usr/share/minimal_1.verity.sig
         %O/minimal-base:/usr/share/TEST-13-NSPAWN-container-template
-        %O/initrd:/exitrd
 
 KernelInitrdModules=default
 
diff --git a/mkosi/mkosi.initrd.conf/mkosi.extra/usr/lib/systemd/system/initrd-run-initramfs.service b/mkosi/mkosi.initrd.conf/mkosi.extra/usr/lib/systemd/system/initrd-run-initramfs.service
new file mode 100644 (file)
index 0000000..b95397f
--- /dev/null
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+[Unit]
+Description=Copy initrd contents to /run/initramfs to serve as exitrd
+DefaultDependencies=no
+AssertPathExists=/etc/initrd-release
+After=initrd.target
+Before=initrd-cleanup.service initrd-switch-root.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=mkdir -p /run/initramfs
+ExecStart=cp -a --one-file-system /. /run/initramfs/
index 5425096a563525b7af20ce9b04232b44deb93619..db4a2c6da2dd4513efddaec55da1dd1c0293fde0 100644 (file)
@@ -5,6 +5,7 @@ integration_tests += [
                 'name' : fs.name(meson.current_source_dir()),
                 'cmdline' : integration_test_template['cmdline'] + [
                         'rd.systemd.wants=initrd-run-mount.service',
+                        'rd.systemd.wants=initrd-run-initramfs.service',
                 ],
                 'exit-code' : 124,
                 'vm' : true,
index b59a5b99ffe63b8807a4e8a2a76ebd19ed19e7f5..7aa2a7e60d3531382cfe2902227049c7942bc836 100755 (executable)
@@ -22,8 +22,8 @@ test -d /run/initrd-mount-target
 mountpoint /run/initrd-mount-target
 [[ -e /run/initrd-mount-target/hello-world ]]
 
-# Copy the prepared exitrd to its intended location.
-mkdir -p /run/initramfs
-unzstd --stdout /exitrd | cpio --extract --make-directories --directory /run/initramfs/
+# The initrd-run-initramfs.service in the initrd should have populated /run/initramfs
+# from the initrd's own contents before switch-root.
+test -x /run/initramfs/shutdown
 
 touch /testok