diff --git a/factory/usr/lib/core/extra-paths b/factory/usr/lib/core/extra-paths index 70b2877a..17e993c3 100755 --- a/factory/usr/lib/core/extra-paths +++ b/factory/usr/lib/core/extra-paths @@ -2,8 +2,14 @@ set -eu -cat <>/sysroot/etc/fstab +cat <<'EOF' >>/sysroot/etc/fstab /run/mnt/data /writable none bind,x-initrd.mount 0 0 +EOF + +# Mount /lib/{firmware,modules} only if there is no drivers tree created by snapd +if [ ! -d /run/mnt/data/system-data/var/lib/snapd/kernel ]; 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