From fa53d1469e974c698b4c53303719738b7eda2330 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Wed, 14 Aug 2024 16:43:07 +0100 Subject: [PATCH 1/4] tmpfiles-early: Drop obsolete Dracut module systemd-tmpfiles-setup-dev-early.service was backported from a newer systemd version, but now our version is new enough. Signed-off-by: James Le Cuirot --- dracut/52tmpfiles-early/module-setup.sh | 12 ---------- .../systemd-tmpfiles-setup-dev-early.service | 24 ------------------- 2 files changed, 36 deletions(-) delete mode 100755 dracut/52tmpfiles-early/module-setup.sh delete mode 100644 dracut/52tmpfiles-early/systemd-tmpfiles-setup-dev-early.service diff --git a/dracut/52tmpfiles-early/module-setup.sh b/dracut/52tmpfiles-early/module-setup.sh deleted file mode 100755 index dc527f2..0000000 --- a/dracut/52tmpfiles-early/module-setup.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# called by dracut -depends() { - echo systemd-networkd -} - -# called by dracut -install() { - inst_simple "$moddir/systemd-tmpfiles-setup-dev-early.service" \ - "$systemdsystemunitdir/systemd-tmpfiles-setup-dev-early.service" -} diff --git a/dracut/52tmpfiles-early/systemd-tmpfiles-setup-dev-early.service b/dracut/52tmpfiles-early/systemd-tmpfiles-setup-dev-early.service deleted file mode 100644 index 847ca43..0000000 --- a/dracut/52tmpfiles-early/systemd-tmpfiles-setup-dev-early.service +++ /dev/null @@ -1,24 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later -# -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. - -[Unit] -Description=Create Static Device Nodes in /dev gracefully -Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8) - -DefaultDependencies=no -Before=sysinit.target local-fs-pre.target systemd-udevd.service -Wants=local-fs-pre.target -Conflicts=shutdown.target initrd-switch-root.target -Before=shutdown.target initrd-switch-root.target - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=systemd-tmpfiles --prefix=/dev --create --boot -SuccessExitStatus=DATAERR CANTCREAT From f17d64a501708c361746416d3a418508ce6007b6 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Wed, 14 Aug 2024 16:56:27 +0100 Subject: [PATCH 2/4] usr-fsck-generator: Drop obsolete Dracut module This has been ineffective for a while because systemd now uses systemd-fsck-usr.service rather than systemd-fsck@${usr}.service. Signed-off-by: James Le Cuirot --- dracut/51usr-fsck-generator/module-setup.sh | 13 --- dracut/51usr-fsck-generator/testsuite.sh | 81 ------------------- .../51usr-fsck-generator/usr-fsck-generator | 80 ------------------ 3 files changed, 174 deletions(-) delete mode 100755 dracut/51usr-fsck-generator/module-setup.sh delete mode 100755 dracut/51usr-fsck-generator/testsuite.sh delete mode 100755 dracut/51usr-fsck-generator/usr-fsck-generator diff --git a/dracut/51usr-fsck-generator/module-setup.sh b/dracut/51usr-fsck-generator/module-setup.sh deleted file mode 100755 index 5253359..0000000 --- a/dracut/51usr-fsck-generator/module-setup.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh - -depends() { - echo systemd -} - -install() { - inst_multiple tr - inst_simple "$moddir/usr-fsck-generator" \ - "$systemdutildir/system-generators/usr-fsck-generator" -} diff --git a/dracut/51usr-fsck-generator/testsuite.sh b/dracut/51usr-fsck-generator/testsuite.sh deleted file mode 100755 index cf73a15..0000000 --- a/dracut/51usr-fsck-generator/testsuite.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash - -moddir=$(dirname "$0") -failed=0 - -run_test() { - local cmdline="$1" - local checkfunc="$2" - local unitdir=$(mktemp -d) - trap "rm -rf '${unitdir}'" EXIT - - echo "Starting test ${checkfunc}" - export USR_FSCK_GENERATOR_CMDLINE="${cmdline}" - if ! "${moddir}/usr-fsck-generator" "${unitdir}"; then - echo "FAILED ${checkfunc}" - failed=$((failed + 1)) - elif ! "${checkfunc}" "${unitdir}"; then - echo "FAILED ${checkfunc}" - failed=$((failed + 1)) - else - echo "PASSED ${checkfunc}" - fi - - rm -rf "${unitdir}" - trap - EXIT -} - -test_noop() { - if [[ -e "$1"/* ]]; then - echo "$1 not empty" - return 1 - fi -} -run_test "nothing" test_noop -run_test "usr=nothing" test_noop -run_test "mount.usr=nothing" test_noop -run_test "usr=nothing mount.usr=nothing" test_noop - - -test_simple() { - [[ -e $1/systemd-fsck@foo-bar-baz.service.d/disable.conf ]] - return $? -} -run_test "usr=/foo/bar/baz" test_simple -run_test "mount.usr=/foo/bar/baz" test_simple -run_test "usr=bar mount.usr=/foo/bar/baz" test_simple -run_test "usr=foo mount.usr=bar usr=baz mount.usr=/foo/bar/baz usr=bleh" test_simple - - -test_label() { - [[ -e $1/systemd-fsck@dev-disk-by\\x2dlabel-foo.service.d/disable.conf ]] - return $? -} -run_test "mount.usr=LABEL=foo" test_label - - -test_uuid() { - [[ -e $1/systemd-fsck@dev-disk-by\\x2duuid-a123.service.d/disable.conf ]] - return $? -} -run_test "mount.usr=UUID=A123" test_uuid - - -test_partuuid() { - [[ -e $1/systemd-fsck@dev-disk-by\\x2dpartuuid-a123.service.d/disable.conf ]] - return $? -} -run_test "mount.usr=PARTUUID=A123" test_partuuid - - -test_partlabel() { - [[ -e $1/systemd-fsck@dev-disk-by\\x2dpartlabel-foo.service.d/disable.conf ]] - return $? -} -run_test "mount.usr=PARTLABEL=foo" test_partlabel - - -if [[ "${failed}" -ne 0 ]]; then - echo "${failed} test(s) failed!" - exit 1 -fi diff --git a/dracut/51usr-fsck-generator/usr-fsck-generator b/dracut/51usr-fsck-generator/usr-fsck-generator deleted file mode 100755 index 100069e..0000000 --- a/dracut/51usr-fsck-generator/usr-fsck-generator +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh - -# This script adds a drop-in which disables systemd-fsck for the /usr -# partition. Cases: -# -# 1. /usr is backed by dm-verity and is read-only. fsck.ext4 would fail -# and print a confusing error to the journal. -# -# 2. The /usr filesystem is configured for verity but the bootloader is -# too old to enable it. fsck.ext4 would fail because of the read-only -# compat flags that prevent writing to the filesystem, and print a -# confusing error to the journal. -# -# 3. Neither #1 or #2 are true because this is a dev image. This case -# is not trivial to detect and not actually important. - -set -e - -UNIT_DIR="${1:-/tmp}" - -# env var for testing -if [[ -n "${USR_FSCK_GENERATOR_CMDLINE}" ]]; then - cmdline=( ${USR_FSCK_GENERATOR_CMDLINE} ) -else - cmdline=( $("${dropin_dir}/disable.conf" < Date: Mon, 29 Jun 2026 18:38:37 +0100 Subject: [PATCH 3/4] usr-generator: verity-generator: Drop obsolete Dracut modules remount-sysroot.service is already provided by upstream Ignition as ignition-remount-sysroot.service. The rest has been unused since switching to the minimal init, and even before that, much of it was handled by systemd-fstab-generator instead. Signed-off-by: James Le Cuirot --- README.md | 6 - .../51diskless-generator/diskless-generator | 4 +- dracut/51diskless-generator/module-setup.sh | 1 - dracut/51usr-generator/module-setup.sh | 29 ----- .../51usr-generator/remount-sysroot.service | 14 --- dracut/51usr-generator/testsuite.sh | 102 ---------------- dracut/51usr-generator/usr-generator | 114 ------------------ dracut/51verity-generator/module-setup.sh | 16 --- dracut/51verity-generator/no-job-timeout.conf | 2 - .../ignition-remount-sysroot.service | 2 +- test | 5 - 11 files changed, 3 insertions(+), 292 deletions(-) delete mode 100755 dracut/51usr-generator/module-setup.sh delete mode 100644 dracut/51usr-generator/remount-sysroot.service delete mode 100755 dracut/51usr-generator/testsuite.sh delete mode 100755 dracut/51usr-generator/usr-generator delete mode 100755 dracut/51verity-generator/module-setup.sh delete mode 100644 dracut/51verity-generator/no-job-timeout.conf delete mode 100755 test diff --git a/README.md b/README.md index 8eca603..10d4900 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,6 @@ This repo holds custom dracut modules required by Flatcar Container Linux -## Running tests - -``` -./test -``` - ## Code of Conduct In the interest of promoting a fair, diverse, and open community, Kinvolk uses its [Code of Conduct](https://github.com/kinvolk/contribution/blob/master/CODE_OF_CONDUCT.md) for all its projects and events. diff --git a/dracut/51diskless-generator/diskless-generator b/dracut/51diskless-generator/diskless-generator index d45bf8c..83a82af 100755 --- a/dracut/51diskless-generator/diskless-generator +++ b/dracut/51diskless-generator/diskless-generator @@ -43,8 +43,8 @@ if [[ -z "${usr}" && -f /usr.squashfs ]]; then [Unit] Before=initrd-root-fs.target -Wants=remount-sysroot.service -After=remount-sysroot.service +Wants=ignition-remount-sysroot.service +After=ignition-remount-sysroot.service # Make sure the loop device nodes are available Wants=systemd-tmpfiles-setup-dev-early.service After=systemd-tmpfiles-setup-dev-early.service diff --git a/dracut/51diskless-generator/module-setup.sh b/dracut/51diskless-generator/module-setup.sh index 85820ba..9426c80 100755 --- a/dracut/51diskless-generator/module-setup.sh +++ b/dracut/51diskless-generator/module-setup.sh @@ -4,7 +4,6 @@ depends() { echo systemd - echo usr-generator } install() { diff --git a/dracut/51usr-generator/module-setup.sh b/dracut/51usr-generator/module-setup.sh deleted file mode 100755 index bb67798..0000000 --- a/dracut/51usr-generator/module-setup.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh - -depends() { - echo systemd -} - -install() { - inst_multiple tr - inst_simple "$moddir/usr-generator" \ - "$systemdutildir/system-generators/usr-generator" - inst_simple "$moddir/remount-sysroot.service" \ - "$systemdutildir/system/remount-sysroot.service" - - # Overwrite systemd-fsck-usr.service because it wants After=local-fs-pre.target - # which prevents (the systemd-generated) sysusr-usr.mount from starting before Ignition - # but we need it because we want to start Ignition from /sysusr/usr/ already. - cat > "$initdir/etc/systemd/system/systemd-fsck-usr.service" <"${UNIT_DIR}/sysusr-usr.mount.d/10-norecovery.conf" <"${UNIT_DIR}/sysroot-usr.mount" < Date: Thu, 5 Jun 2025 11:15:41 +0100 Subject: [PATCH 4/4] ignition: Drop sysroot-boot.service in favour of boot.mount sysroot-boot.service used to be a simple mount unit way back before 8bf46fe78ec59bcd5148ce9ab8ec5fb805600151. This was changed due to umount sometimes being called after an unmount had already happened, causing it and its associated unit to fail. This was harmless, but it did cause Kola test failures. Although the precise cause of that issue was never found, I think that between moving the mount point outside of /sysroot, not forcing it to unmount before switching root (that will happen anyway), and the intervening 8 years of systemd changes, there's a good chance we won't see it again. Signed-off-by: James Le Cuirot --- dracut/53disk-uuid/disk-uuid.service | 2 +- dracut/53ignition/boot.mount | 8 ++++++ dracut/53ignition/ignition-quench.service | 5 ++-- dracut/53ignition/module-setup.sh | 10 +++---- dracut/53ignition/retry-umount.sh | 32 ----------------------- dracut/53ignition/sysroot-boot.service | 25 ------------------ 6 files changed, 14 insertions(+), 68 deletions(-) create mode 100644 dracut/53ignition/boot.mount delete mode 100755 dracut/53ignition/retry-umount.sh delete mode 100644 dracut/53ignition/sysroot-boot.service diff --git a/dracut/53disk-uuid/disk-uuid.service b/dracut/53disk-uuid/disk-uuid.service index 019d7c3..9c9c8f5 100644 --- a/dracut/53disk-uuid/disk-uuid.service +++ b/dracut/53disk-uuid/disk-uuid.service @@ -10,7 +10,7 @@ After=systemd-udevd.service dev-disk-by\x2dpartlabel-USR\x2dA.device # Run before services that use device nodes, preventing them from racing # with udev activity generated by sgdisk -Before=ignition-disks.service verity-setup.service +Before=boot.mount ignition-disks.service [Service] Type=oneshot diff --git a/dracut/53ignition/boot.mount b/dracut/53ignition/boot.mount new file mode 100644 index 0000000..61a3848 --- /dev/null +++ b/dracut/53ignition/boot.mount @@ -0,0 +1,8 @@ +[Unit] +Description=Boot partition +DefaultDependencies=no + +[Mount] +What=/dev/disk/by-label/EFI-SYSTEM +Where=/boot +Type=vfat diff --git a/dracut/53ignition/ignition-quench.service b/dracut/53ignition/ignition-quench.service index 6460917..ae04834 100644 --- a/dracut/53ignition/ignition-quench.service +++ b/dracut/53ignition/ignition-quench.service @@ -9,11 +9,10 @@ After=ignition-disks.service Requires=ignition-files.service After=ignition-files.service -Requires=sysroot-boot.service -After=sysroot-boot.service +RequiresMountsFor=/boot [Service] Type=oneshot # We will only run if GRUB detected this file. Fail if we are unable to # remove it, rather than risking rerunning Ignition at next boot. -ExecStart=/bin/sh -c 'if [ ! -e /sysroot/boot/flatcar/first_boot ] && [ ! -e /sysroot/boot/coreos/first_boot ]; then echo "error: /sysroot/boot/(flatcar|coreos)/first_boot not found"; exit 1; else rm -f /sysroot/boot/flatcar/first_boot /sysroot/boot/coreos/first_boot; fi' +ExecStart=/bin/sh -c 'if [ ! -e /boot/flatcar/first_boot ] && [ ! -e /boot/coreos/first_boot ]; then echo "error: /boot/(flatcar|coreos)/first_boot not found"; exit 1; else rm -f /boot/flatcar/first_boot /boot/coreos/first_boot; fi' diff --git a/dracut/53ignition/module-setup.sh b/dracut/53ignition/module-setup.sh index 61f818a..10dab7f 100755 --- a/dracut/53ignition/module-setup.sh +++ b/dracut/53ignition/module-setup.sh @@ -84,10 +84,6 @@ install() { inst_simple "$moddir/ignition-luks.conf" \ "/etc/security/pwquality.conf.d/ignition-luks.conf" - # Flatcar: add retry-umount - inst_script "$moddir/retry-umount.sh" \ - "/usr/sbin/retry-umount" - # Ignition calls is-live-image. inst_script "$moddir/is-live-image.sh" \ /bin/is-live-image @@ -101,13 +97,13 @@ install() { "$systemdsystemunitdir/ignition-$x.target" done - # Flatcar: add ignition-quench.service, sysroot-boot.service, + # Flatcar: add ignition-quench.service, boot.mount, # flatcar-afterburn-network.service, flatcar-static-network.service, # flatcar-metadata-hostname.service, flatcar-openstack-hostname.service inst_simple "$moddir/ignition-quench.service" \ "$systemdsystemunitdir/ignition-quench.service" - inst_simple "$moddir/sysroot-boot.service" \ - "$systemdsystemunitdir/sysroot-boot.service" + inst_simple "$moddir/boot.mount" \ + "$systemdsystemunitdir/boot.mount" inst_simple "$moddir/flatcar-afterburn-network.service" \ "$systemdsystemunitdir/flatcar-afterburn-network.service" inst_simple "$moddir/flatcar-static-network.service" \ diff --git a/dracut/53ignition/retry-umount.sh b/dracut/53ignition/retry-umount.sh deleted file mode 100755 index 4a62b33..0000000 --- a/dracut/53ignition/retry-umount.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# Unmount $1, retrying a few times. - -set -e - -mp="$1" -if [ -z "$mp" ] ; then - echo "Usage: $0 " - exit 1 -fi - -if ! mountpoint -q "$mp"; then - exit 0 -fi - -tries=5 -while true; do - umount "$mp" ||: - # Apparently umount may return failure when it actually succeeded - if ! mountpoint -q "$mp"; then - exit 0 - fi - - tries=$(( $tries - 1 )) - if [[ $tries = 0 ]]; then - echo "Giving up." >&2 - exit 1 - fi - - echo "Couldn't unmount $mp; retrying..." >&2 - sleep 1 -done diff --git a/dracut/53ignition/sysroot-boot.service b/dracut/53ignition/sysroot-boot.service deleted file mode 100644 index 9d8fb6c..0000000 --- a/dracut/53ignition/sysroot-boot.service +++ /dev/null @@ -1,25 +0,0 @@ -[Unit] -Description=/sysroot/boot -DefaultDependencies=false - -BindsTo=dev-disk-by\x2dlabel-EFI\x2dSYSTEM.device -After=dev-disk-by\x2dlabel-EFI\x2dSYSTEM.device - -RequiresMountsFor=/sysroot - -# Creates mountpoint -Requires=initrd-setup-root.service -After=initrd-setup-root.service - -# This is to make sure that /sysroot/boot is unmounted before we start -# switching root in initrd-switch-root.target. -Before=initrd-switch-root.target - -Conflicts=dracut-emergency.service emergency.service emergency.target -Conflicts=initrd-switch-root.target umount.target - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/bin/mount /dev/disk/by-label/EFI-SYSTEM /sysroot/boot -ExecStop=/usr/sbin/retry-umount /sysroot/boot