[v3] isar-installer: Mount /tmp as tmpfs for read-only boot fix

Message ID 20250616094433.44736-1-badrikesh.prusty@siemens.com
State Under Review
Headers show
Series [v3] isar-installer: Mount /tmp as tmpfs for read-only boot fix | expand

Commit Message

Badrikesh Prusty June 16, 2025, 9:44 a.m. UTC
Fix image installation when isar-image-installer rootfs is booted as read-only
by ensuring /tmp is mounted as tmpfs.

With the latest isar installer, Bmaptool now creates the /tmp/progress pipe to
track and display installation progress in a progress bar.

This change utilizes systemd's tmp.mount to mount /tmp as tmpfs. Since systemd
versions up to Debian Bookworm ship tmp.mount in /usr/share/systemd/, the file
must be copied to a directory where systemctl can enable it.
For systemd versions 256.x and newer, tmp.mount is shipped in the appropriate
location: /usr/lib/systemd/system/tmp.mount

Signed-off-by: Badrikesh Prusty <badrikesh.prusty@siemens.com>
---
 .../deploy-image/deploy-image_0.1.bb              |  6 ++++--
 .../systemd-tmpfs-tmp/files/postinst              | 15 +++++++++++++++
 .../systemd-tmpfs-tmp/systemd-tmpfs-tmp_0.1.bb    | 13 +++++++++++++
 3 files changed, 32 insertions(+), 2 deletions(-)
 create mode 100644 meta-isar/recipes-installer/systemd-tmpfs-tmp/files/postinst
 create mode 100644 meta-isar/recipes-installer/systemd-tmpfs-tmp/systemd-tmpfs-tmp_0.1.bb

Patch

diff --git a/meta-isar/recipes-installer/deploy-image/deploy-image_0.1.bb b/meta-isar/recipes-installer/deploy-image/deploy-image_0.1.bb
index 54e521b5..b287a8d1 100644
--- a/meta-isar/recipes-installer/deploy-image/deploy-image_0.1.bb
+++ b/meta-isar/recipes-installer/deploy-image/deploy-image_0.1.bb
@@ -10,8 +10,10 @@  inherit dpkg-raw
 SRC_URI = "file://usr/bin/deploy-image-wic.sh \
            file://usr/lib/deploy-image-wic/handle-config.sh \
           "
-DEPENDS:bookworm += "bmap-tools"
-DEBIAN_DEPENDS = "bmap-tools, pv, dialog, util-linux, parted, fdisk, gdisk, pigz, xz-utils, pbzip2, zstd"
+
+DEPENDS:append:bookworm = " bmap-tools"
+DEPENDS:append = " systemd-tmpfs-tmp"
+DEBIAN_DEPENDS = "bmap-tools, pv, dialog, util-linux, parted, fdisk, gdisk, pigz, systemd-tmpfs-tmp, xz-utils, pbzip2, zstd"
 do_install[cleandirs] = "${D}/usr/bin/ \
                          ${D}/usr/lib/deploy-image-wic \
                         "
diff --git a/meta-isar/recipes-installer/systemd-tmpfs-tmp/files/postinst b/meta-isar/recipes-installer/systemd-tmpfs-tmp/files/postinst
new file mode 100644
index 00000000..cb979303
--- /dev/null
+++ b/meta-isar/recipes-installer/systemd-tmpfs-tmp/files/postinst
@@ -0,0 +1,15 @@ 
+#!/bin/sh
+
+set -e
+
+# Enable tmp.mount if /tmp is not configured in /etc/fstab
+if ! grep -q '/tmp' /etc/fstab; then
+    # Ensure tmp.mount exists in systemd path
+    if [ ! -e /usr/lib/systemd/system/tmp.mount ] && [ ! -e /etc/systemd/system/tmp.mount ]; then
+        cp /usr/share/systemd/tmp.mount /etc/systemd/system/tmp.mount
+    fi
+
+    # Enable the mount unit using deb-systemd-helper
+    deb-systemd-helper enable tmp.mount || true
+fi
+
diff --git a/meta-isar/recipes-installer/systemd-tmpfs-tmp/systemd-tmpfs-tmp_0.1.bb b/meta-isar/recipes-installer/systemd-tmpfs-tmp/systemd-tmpfs-tmp_0.1.bb
new file mode 100644
index 00000000..c0ab1bcf
--- /dev/null
+++ b/meta-isar/recipes-installer/systemd-tmpfs-tmp/systemd-tmpfs-tmp_0.1.bb
@@ -0,0 +1,13 @@ 
+# This software is a part of ISAR.
+# Copyright (C) Siemens AG, 2025
+#
+# SPDX-License-Identifier: MIT
+
+inherit dpkg-raw
+
+DESCRIPTION = "Configures /tmp as systemd-managed temporary filesystem (tmpfs), ensuring read-write access even if rootfs is read-only"
+MAINTAINER = "isar-users <isar-users@googlegroups.com>"
+
+SRC_URI = "file://postinst"
+
+DEBIAN_DEPENDS = "systemd"