From a71d5e1ac3fade2e9f632374fb680309ce9bc3340eba2f78d9f5bd4ab2a78036 Mon Sep 17 00:00:00 2001 From: Ignaz Forster Date: Wed, 6 Apr 2022 17:10:21 +0000 Subject: [PATCH] - ignition-mount-initrd-fstab.service: - Don't ignore errors in loops - Unmount mount points recursively - a new submount may have appeared - Split umount part into own service file: - ignition-umount-initrd-fstab.service: - Unmounts the additional mounts as soon as they are not required for Ignition any more; the ExecStop operation is running quite late in initrd and may unmount essential mount points flagged with "x-initrd.mount" (e.g. when storing /usr on a separate mount point). In theory this will also affect Ignition itself, but it hasn't been reported as a problem so far. OBS-URL: https://build.opensuse.org/package/show/devel:kubic:ignition/ignition?expand=0&rev=91 --- README.SUSE | 2 +- ignition-mount-initrd-fstab.service | 5 +---- ignition-suse-generator | 1 + ignition-umount-initrd-fstab.service | 10 ++++++++++ ignition.changes | 17 +++++++++++++++++ ignition.spec | 3 ++- module-setup.sh | 2 ++ 7 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 ignition-umount-initrd-fstab.service diff --git a/README.SUSE b/README.SUSE index c522c78..d11dd6a 100644 --- a/README.SUSE +++ b/README.SUSE @@ -1,6 +1,6 @@ Changes for openSUSE / SLE: -* ignition-mount-initrd-fstab.service: +* ignition-mount-initrd-fstab.service / ignition-umount-initrd-fstab.service: Upstream Ignition will only mount partitions or subvolumes explicitly mentioned in the Ignition configuration. A default SUSE system, however, is split over several subvolumes, and most users won't want to define diff --git a/ignition-mount-initrd-fstab.service b/ignition-mount-initrd-fstab.service index 5c283f0..c6c9cba 100644 --- a/ignition-mount-initrd-fstab.service +++ b/ignition-mount-initrd-fstab.service @@ -17,7 +17,4 @@ Before=ignition-files.service [Service] Type=oneshot -RemainAfterExit=yes -ExecStart=/bin/sh -c 'eval $(awk '"'"'$4 ~ /x-initrd.mount/ && $1 !~ /^#/ {print "if ! findmnt /sysroot" $2 " >/dev/null; then mount -t " $3 " -o " $4 " " $1 " /sysroot" $2 "; fi;" }'"'"' /sysroot/etc/fstab)' -ExecStop=/bin/sh -c 'if [ -f /sysroot/etc/systemd/system-preset/20-ignition.preset ]; then while read line; do systemctl --root=/sysroot $line; done < /sysroot/etc/systemd/system-preset/20-ignition.preset; fi' -ExecStop=/usr/bin/umount -a -O "x-initrd.mount" +ExecStart=/bin/sh -e -c 'eval $(awk '"'"'$4 ~ /x-initrd.mount/ && $1 !~ /^#/ {print "if ! findmnt /sysroot" $2 " >/dev/null; then mount -t " $3 " -o " $4 " " $1 " /sysroot" $2 "; fi;" }'"'"' /sysroot/etc/fstab)' diff --git a/ignition-suse-generator b/ignition-suse-generator index 2014f92..3cc5789 100644 --- a/ignition-suse-generator +++ b/ignition-suse-generator @@ -9,6 +9,7 @@ set -e . /run/ignition.env add_requires ignition-mount-initrd-fstab.service ignition-files.service +add_requires ignition-umount-initrd-fstab.service ignition-files.service add_requires ignition-enable-network.service ignition-fetch.service if [ -z "${PLATFORM_ID}" ]; then diff --git a/ignition-umount-initrd-fstab.service b/ignition-umount-initrd-fstab.service new file mode 100644 index 0000000..a932c5e --- /dev/null +++ b/ignition-umount-initrd-fstab.service @@ -0,0 +1,10 @@ +[Unit] +Description=Unmount initrd fstab entries for Ignition +DefaultDependencies=false +Before=ignition-complete.target +After=ignition-files.service + +[Service] +Type=oneshot +ExecStart=/bin/sh -e -c 'if [ -f /sysroot/etc/systemd/system-preset/20-ignition.preset ]; then while read line; do systemctl --root=/sysroot $line; done < /sysroot/etc/systemd/system-preset/20-ignition.preset; fi' +ExecStart=/bin/sh -e -c 'eval $(awk '"'"'$4 ~ /x-initrd.mount/ && $1 !~ /^#/ {print "if findmnt /sysroot" $2 " >/dev/null; then umount -R /sysroot" $2 "; fi;" }'"'"' /sysroot/etc/fstab)' diff --git a/ignition.changes b/ignition.changes index 770ae3f..65276ef 100644 --- a/ignition.changes +++ b/ignition.changes @@ -1,3 +1,20 @@ +------------------------------------------------------------------- +Tue Apr 5 14:57:20 UTC 2022 - Ignaz Forster + +- ignition-mount-initrd-fstab.service: + - Don't ignore errors in loops + - Unmount mount points recursively - a new submount may have + appeared + - Split umount part into own service file: +- ignition-umount-initrd-fstab.service: + - Unmounts the additional mounts as soon as they are not + required for Ignition any more; the ExecStop operation is + running quite late in initrd and may unmount essential mount + points flagged with "x-initrd.mount" (e.g. when storing /usr on + a separate mount point). In theory this will also affect + Ignition itself, but it hasn't been reported as a problem so + far. + ------------------------------------------------------------------- Mon Apr 4 17:23:10 UTC 2022 - Ignaz Forster diff --git a/ignition.spec b/ignition.spec index 5d22249..49c17e2 100644 --- a/ignition.spec +++ b/ignition.spec @@ -25,6 +25,7 @@ Group: System/Management URL: https://github.com/coreos/ignition Source: %{name}-%{version}.tar.xz Source1: ignition-mount-initrd-fstab.service +Source2: ignition-umount-initrd-fstab.service Source3: ignition-suse-generator Source4: module-setup.sh Source5: 02_ignition_firstboot @@ -88,7 +89,7 @@ which creates firstboot_happened after the first boot. mkdir dracut/30ignition-microos grub systemd_suse chmod +x %{SOURCE3} %{SOURCE4} %{SOURCE8} %{SOURCE12} -cp %{SOURCE1} %{SOURCE3} %{SOURCE4} %{SOURCE8} %{SOURCE9} %{SOURCE10} %{SOURCE11} %{SOURCE13} %{SOURCE14} dracut/30ignition-microos/ +cp %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} %{SOURCE8} %{SOURCE9} %{SOURCE10} %{SOURCE11} %{SOURCE13} %{SOURCE14} dracut/30ignition-microos/ %ifarch aarch64 %{arm} cp %{SOURCE21} dracut/30ignition-microos/ignition-userconfig-timeout.conf %else diff --git a/module-setup.sh b/module-setup.sh index 33e416c..118fc1e 100644 --- a/module-setup.sh +++ b/module-setup.sh @@ -21,6 +21,8 @@ install() { "$systemdsystemunitdir/ignition-enable-network.service" inst_simple "$moddir/ignition-mount-initrd-fstab.service" \ "$systemdsystemunitdir/ignition-mount-initrd-fstab.service" + inst_simple "$moddir/ignition-umount-initrd-fstab.service" \ + "$systemdsystemunitdir/ignition-umount-initrd-fstab.service" inst_simple "$moddir/ignition-userconfig-timeout.conf" \ "$systemdsystemunitdir/dev-disk-by\x2dlabel-ignition.device.d/ignition-userconfig-timeout.conf" inst_simple "$moddir/ignition-touch-selinux-autorelabel.conf" \