From 537cf3158b2407bf1fa756e43531c5e2b45a7773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfonso=20S=C3=A1nchez-Beato?= Date: Thu, 14 Mar 2024 16:59:59 +0000 Subject: [PATCH] factory: do not mount /lib/{modules,firmware} for run mode Do not mount /lib/{modules,firmware} for run mode, as in that case the mounts will be created by snapd-generator from the base or from the snapd deb package for hybrid systems. --- factory/usr/lib/core/extra-paths | 10 +++- .../system-generators/kernel-snap-generator | 57 ------------------- .../lib/systemd/system/classic-mounts.service | 16 ------ .../system/detect-classic-sysroot.service | 1 - 4 files changed, 9 insertions(+), 75 deletions(-) delete mode 100755 factory/usr/lib/systemd/system-generators/kernel-snap-generator delete mode 100644 factory/usr/lib/systemd/system/classic-mounts.service diff --git a/factory/usr/lib/core/extra-paths b/factory/usr/lib/core/extra-paths index 70b2877a..2547ce7f 100755 --- a/factory/usr/lib/core/extra-paths +++ b/factory/usr/lib/core/extra-paths @@ -2,8 +2,16 @@ set -eu -cat <>/sysroot/etc/fstab +mode="$(/usr/libexec/core/get-mode mode)" || + mode="$(/usr/libexec/core/get-arg snapd_recovery_mode)" || mode="unknown" + +cat <<'EOF' >>/sysroot/etc/fstab /run/mnt/data /writable none bind,x-initrd.mount 0 0 +EOF + +if [ "$mode" != "run" ]; then + cat <<'EOF' >>/sysroot/etc/fstab /run/mnt/kernel/firmware /usr/lib/firmware none bind,x-initrd.mount 0 0 /run/mnt/kernel/modules /usr/lib/modules none bind,x-initrd.mount 0 0 EOF +fi diff --git a/factory/usr/lib/systemd/system-generators/kernel-snap-generator b/factory/usr/lib/systemd/system-generators/kernel-snap-generator deleted file mode 100755 index e9b8dcf4..00000000 --- a/factory/usr/lib/systemd/system-generators/kernel-snap-generator +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh - -set -eu - -: "${KERNEL_MNT_POINT:=/run/mnt/kernel}" - -if ! mountpoint -q "${KERNEL_MNT_POINT}"; then - exit 0 -fi - -# FIXME use SYSTEMD_IN_INITRD when using systemd 251+ -if [ -f /etc/initrd-release ]; then - sysroot=/sysroot - sysroot_unit=sysroot - target=initrd-fs.target -else - sysroot= - sysroot_unit= - target=local-fs.target -fi - -: "${OS_RELEASE:="${sysroot}/etc/os-release"}" - -# Note that /sysroot/etc/os-release is accessible when generators are -# re-executed due to "daemon-reload" called by -# initrd-parse-etc.service - -# We generate the kernel bind mount units only -# if we are on Ubuntu Classic - -# Ubuntu Core will have those mounts declared in /etc/fstab, thus -# using systemd-fstab-generator instead. - -if ! grep -q "^ID=ubuntu$" "${OS_RELEASE}"; then - exit 0 -fi - -for entry in firmware modules; do - what="${KERNEL_MNT_POINT}/${entry}" - where="${sysroot}/usr/lib/${entry}" - unit="usr-lib-${entry}.mount" - if [ -n "${sysroot_unit}" ]; then - unit="${sysroot_unit}-${unit}" - fi - mkdir -p "${1}/${target}.requires" - ln -sf "../${unit}" "${1}/${target}.requires/${unit}" - cat <"${1}/${unit}" -[Unit] -Before=${target} - -[Mount] -What=${what} -Where=${where} -Options=bind -Type=none -EOF -done diff --git a/factory/usr/lib/systemd/system/classic-mounts.service b/factory/usr/lib/systemd/system/classic-mounts.service deleted file mode 100644 index d5f46931..00000000 --- a/factory/usr/lib/systemd/system/classic-mounts.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=Create mount units specific to classic -OnFailure=emergency.target -OnFailureJobMode=replace-irreversibly - -DefaultDependencies=no - -Requires=initrd-root-fs.target -After=initrd-root-fs.target -Before=initrd-fs.target - -[Service] -Type=oneshot -# We force re-running kernel-snap-generator -ExecStart=systemctl daemon-reload -StandardError=journal+console diff --git a/factory/usr/lib/systemd/system/detect-classic-sysroot.service b/factory/usr/lib/systemd/system/detect-classic-sysroot.service index c80e7908..dfce5562 100644 --- a/factory/usr/lib/systemd/system/detect-classic-sysroot.service +++ b/factory/usr/lib/systemd/system/detect-classic-sysroot.service @@ -3,7 +3,6 @@ Description=Detect Ubuntu classic sysroot DefaultDependencies=no Before=initrd-root-device.target After=snap-initramfs-mounts.service -Wants=classic-mounts.service ConditionPathIsMountPoint=!/run/mnt/base