[PATCH v4 02/10] rootfs: Allow to overwrite the initramfs generation cmds

5 views
Skip to first unread message

Quirin Gylstorff

unread,
Oct 22, 2025, 11:08:03 AM (8 days ago) Oct 22
to isar-...@googlegroups.com, cedric.h...@siemens.com, jan.k...@siemens.com, felix.mo...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

This is in preparation to support additional initramfs generators
like dracut.

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
meta/classes/rootfs.bbclass | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index 4d73bfec..b7310e0c 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -5,7 +5,13 @@ inherit deb-dl-dir

ROOTFS_ARCH ?= "${DISTRO_ARCH}"
ROOTFS_DISTRO ?= "${DISTRO}"
+
+def initramfs_generator_cmdline(d):
+ return "update-initramfs -u -v -k \"$kernel_version\""
+
ROOTFS_PACKAGES ?= ""
+ROOTFS_INITRAMFS_GENERATOR_CMD = "${@ d.getVar('ROOTFS_INITRAMFS_GENERATOR_CMDLINE').split()[0]}"
+ROOTFS_INITRAMFS_GENERATOR_CMDLINE = "${@ initramfs_generator_cmdline(d)}"
ROOTFS_BASE_DISTRO ?= "${BASE_DISTRO}"

# Features of the rootfs creation:
@@ -254,7 +260,7 @@ rootfs_disable_initrd_generation() {
set -e

mkdir -p "${ROOTFSDIR}${ROOTFS_STUBS_DIR}"
- ln -s /usr/bin/true ${ROOTFSDIR}${ROOTFS_STUBS_DIR}/update-initramfs
+ ln -s /usr/bin/true ${ROOTFSDIR}${ROOTFS_STUBS_DIR}/${ROOTFS_INITRAMFS_GENERATOR_CMD}

mkdir -p '${ROOTFSDIR}/etc/apt/apt.conf.d'
echo 'DPkg::Path ${ROOTFS_STUBS_DIR}:/usr/sbin:/usr/bin:/sbin:/bin;' \
@@ -577,12 +583,13 @@ rootfs_generate_initramfs() {
echo "Total number of modules: $mods_total"
echo "Generating initrd for kernel version: $kernel_version"
sudo -E chroot "${ROOTFSDIR}" sh -c ' \
- update-initramfs -u -v -k "$kernel_version"'
+ ${ROOTFS_INITRAMFS_GENERATOR_CMDLINE};'
done
if [ -n "${INITRD_DEPLOY_FILE}" ]; then
if [ -f "${ROOTFSDIR}/initrd.img" ]; then
# debian (mkinitramfs)
- cp ${ROOTFSDIR}/initrd.img ${DEPLOYDIR}/${INITRD_DEPLOY_FILE}
+ sudo cp ${ROOTFSDIR}/initrd.img ${DEPLOYDIR}/${INITRD_DEPLOY_FILE}
+ sudo chown $(id -u):$(id -g) ${DEPLOYDIR}/${INITRD_DEPLOY_FILE}
else
# ubuntu (dracut)
cp ${ROOTFSDIR}/boot/initrd.img ${DEPLOYDIR}/${INITRD_DEPLOY_FILE}
--
2.51.0

Quirin Gylstorff

unread,
Oct 22, 2025, 11:08:03 AM (8 days ago) Oct 22
to isar-...@googlegroups.com, cedric.h...@siemens.com, jan.k...@siemens.com, felix.mo...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

Debian intends to change the default initrd generator from
initramfs-tools to dracut[1],[2].

This is a first draft to support multiple initrd generator in
ISAR. I tested it with bookworm and trixie.

You can switch a normal Debian version to a dracut based initrd
by installing the package `dracut`. This similar to a normal Debian
installation.

Customizing the initrd generation should be done with a seperate recipe
which inherit `initrd-dracut`. This is intentionally done to avoid
installing packages which are only used by the initrd generation process.

[1]: https://salsa.debian.org/kernel-team/meetings/-/wikis/20250730
[2]: https://meetbot.debian.net/debian-kernel/2025/debian-kernel.2025-08-06-19.00.log.html

Changes v4:
- fix extra_modules and extra_drivers
- extend user_manual to switch normal installation to dracut

Changes v3:
- drop initramfs patch
- add examples
- add user_manual section

Changes v2:
- extract the initramfs-cmd from the cmdline
- increase version of enable-fsck
- add function to print an error in case a invalid package is installed

Quirin Gylstorff (10):
add dracut to custom kernel builds
rootfs: Allow to overwrite the initramfs generation cmds
rootfs Add dracut to initramfs generator
initramfs: allow to set the generator command
Add class to generate custom dracut initramfs
rootfs: add flag to use dracut if it is not part of the package list
Add example dracut initramfs
Add dracut module helper
Use lighttpd as a example how to add a dracut module
user_manual: Add dracut for initramfs generation

doc/user_manual.md | 51 ++++++++++++++++--
.../dracut-example-lighttpd_0.1.bb | 26 ++++++++++
.../dracut-example-lighttpd/files/install.sh | 21 ++++++++
.../files/lighttpd.conf | 52 +++++++++++++++++++
.../files/lighttpd.service | 13 +++++
.../files/sysuser-lighttpd.conf | 3 ++
.../recipes-initramfs/images/isar-dracut.bb | 20 +++++++
meta/classes/initramfs.bbclass | 19 ++++++-
meta/classes/initrd-dracut.bbclass | 49 +++++++++++++++++
meta/classes/rootfs.bbclass | 17 ++++--
.../dracut-module/dracut-module.inc | 41 +++++++++++++++
.../dracut-module/files/module-setup.sh.tmpl | 20 +++++++
meta/recipes-kernel/linux/linux-custom.inc | 2 +-
13 files changed, 324 insertions(+), 10 deletions(-)
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/dracut-example-lighttpd_0.1.bb
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.conf
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.service
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/files/sysuser-lighttpd.conf
create mode 100644 meta-isar/recipes-initramfs/images/isar-dracut.bb
create mode 100644 meta/classes/initrd-dracut.bbclass
create mode 100644 meta/recipes-initramfs/dracut-module/dracut-module.inc
create mode 100644 meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl

--
2.51.0

Quirin Gylstorff

unread,
Oct 22, 2025, 11:08:04 AM (8 days ago) Oct 22
to isar-...@googlegroups.com, cedric.h...@siemens.com, jan.k...@siemens.com, felix.mo...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
meta/classes/rootfs.bbclass | 3 +++
1 file changed, 3 insertions(+)

diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index b7310e0c..a496e50a 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -7,6 +7,9 @@ ROOTFS_ARCH ?= "${DISTRO_ARCH}"
ROOTFS_DISTRO ?= "${DISTRO}"

def initramfs_generator_cmdline(d):
+ rootfs_packages = d.getVar('ROOTFS_PACKAGES') or ''
+ if 'dracut' in rootfs_packages:
+ return "dracut --force /initrd.img \"$kernel_version\""
return "update-initramfs -u -v -k \"$kernel_version\""

ROOTFS_PACKAGES ?= ""
--
2.51.0

Quirin Gylstorff

unread,
Oct 22, 2025, 11:08:05 AM (8 days ago) Oct 22
to isar-...@googlegroups.com, cedric.h...@siemens.com, jan.k...@siemens.com, felix.mo...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

This allows to exchange the initramfs generator.

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
meta/classes/initramfs.bbclass | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/meta/classes/initramfs.bbclass b/meta/classes/initramfs.bbclass
index 658ef0ac..862bd873 100644
--- a/meta/classes/initramfs.bbclass
+++ b/meta/classes/initramfs.bbclass
@@ -10,6 +10,7 @@ INITRAMFS_INSTALL ?= ""
INITRAMFS_PREINSTALL ?= ""
INITRAMFS_ROOTFS ?= "${WORKDIR}/rootfs"
INITRAMFS_IMAGE_NAME = "${INITRAMFS_FULLNAME}.initrd.img"
+INITRAMFS_GENERATOR_PKG ??= "initramfs-tools"
INITRD_DEPLOY_FILE = "${INITRAMFS_IMAGE_NAME}"

# Install proper kernel
@@ -26,6 +27,20 @@ DEPENDS += "${INITRAMFS_INSTALL}"

ROOTFSDIR = "${INITRAMFS_ROOTFS}"
ROOTFS_FEATURES = "generate-manifest"
-ROOTFS_PACKAGES = "initramfs-tools ${INITRAMFS_PREINSTALL} ${INITRAMFS_INSTALL}"
-
+ROOTFS_PACKAGES = "${INITRAMFS_GENERATOR_PKG} ${INITRAMFS_PREINSTALL} ${INITRAMFS_INSTALL}"
+
+# validate if have incompatible packages in the installation list
+python do_validate_rootfs_packages () {
+ # in Debian initramfs-tools specific packages should end or star
+ # with initramfs
+ # dracut specific packages end with dracut
+ incompatible_initrd_packages = { 'initramfs-tools':['dracut'],
+ 'dracut':['initramfs']}
+ initrd_generator = d.getVar("INITRAMFS_GENERATOR_PKG")
+ for invalid_generator_idenitifier in incompatible_initrd_packages.get(initrd_generator):
+ for pkg in d.getVar('ROOTFS_PACKAGES').split():
+ if invalid_generator_idenitifier in pkg:
+ bb.error(f"{pkg} is incompatible with the selected generator '{initrd_generator}'")
+}
+addtask do_validate_rootfs_packages before do_rootfs_install
inherit rootfs
--
2.51.0

Quirin Gylstorff

unread,
Oct 22, 2025, 11:08:06 AM (8 days ago) Oct 22
to isar-...@googlegroups.com, cedric.h...@siemens.com, jan.k...@siemens.com, felix.mo...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

This class allows to customize a dracut initramfs by using
configuration files add addition modules and drivers.

It is recommended to use the addition of modules and drivers
sparely and prefer dracut configuration files.

This class has the option to add custom modules automatically to
the initramfs if:
- The modules are provided by the ISAR build system
- The module name is part of the package name, valid names are
- dracut-<module-name>
- <module-name>-dracut
- <something>-dracut-<module-name>

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
meta/classes/initrd-dracut.bbclass | 49 ++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 meta/classes/initrd-dracut.bbclass

diff --git a/meta/classes/initrd-dracut.bbclass b/meta/classes/initrd-dracut.bbclass
new file mode 100644
index 00000000..53cb6df5
--- /dev/null
+++ b/meta/classes/initrd-dracut.bbclass
@@ -0,0 +1,49 @@
+# This software is a part of ISAR.
+# This class provides the necessary options to
+# customize a dracut based initramfs.
+#
+# This class should not provide every dracut cmdline
+# option possible. Use the dracut configuration files.
+
+INITRAMFS_GENERATOR_PKG = "dracut"
+
+# The preferred way to configure dracut is to
+# provide dracut-config-<your-config> package which
+# contains all necessary config options
+DRACUT_CONFIG_PATH ??= ""
+DRACUT_EXTRA_DRIVERS ??= ""
+DRACUT_EXTRA_MODULES ??= ""
+DRACUT_EXTRACT_MODULES_FROM_PACKAGE_NAMES ??= "False"
+def extend_dracut_cmdline(d):
+ config_path = d.getVar('DRACUT_CONFIG_PATH') or ''
+ extra_drivers = d.getVar('DRACUT_EXTRA_DRIVERS') or ''
+ extra_modules = d.getVar('DRACUT_EXTRA_MODULES') or ''
+ enable_module_extraction = bb.utils.to_boolean(d.getVar('DRACUT_EXTRACT_MODULES_FROM_PACKAGE_LIST'))
+ pkg_list = d.getVar('INITRAMFS_INSTALL') or ''
+
+ cmdline = []
+ modules_from_pkg_names = []
+ if enable_module_extraction:
+ for pkg in pkg_list.split():
+ # Skip dracut-config-* packages
+ if pkg.startswith('dracut-config-'):
+ continue
+ elif pkg.startswith('dracut-'):
+ modules_from_pkg_names.append(pkg[7:])
+ elif pkg.endswith('-dracut'):
+ modules_from_pkg_names.append(pkg[:-7])
+ elif '-dracut-' in pkg:
+ _, module_name = pkg.split('-dracut-', 1)
+ modules_from_pkg_names.append(module_name)
+ extra_modules = extra_modules + ' ' +' '.join(modules_from_pkg_names)
+
+ if config_path:
+ cmdline.append(f"--conf {config_path}")
+ if extra_drivers:
+ cmdline.append(f"--add-drivers {extra_drivers}")
+ if extra_modules:
+ cmdline.append(f"--add {extra_modules}")
+ return ' '.join(cmdline)
+
+ROOTFS_INITRAMFS_GENERATOR_CMDLINE += "${@ extend_dracut_cmdline(d)}"
+inherit initramfs
--
2.51.0

Quirin Gylstorff

unread,
Oct 22, 2025, 11:08:06 AM (8 days ago) Oct 22
to isar-...@googlegroups.com, cedric.h...@siemens.com, jan.k...@siemens.com, felix.mo...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

This is intend for version where dracut is the default initramfs where
dracut is part of the dependency tree and not explicit requested.

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
meta/classes/rootfs.bbclass | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index a496e50a..01f34e93 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -6,9 +6,10 @@ inherit deb-dl-dir
ROOTFS_ARCH ?= "${DISTRO_ARCH}"
ROOTFS_DISTRO ?= "${DISTRO}"

+ROOTFS_USE_DRACUT ??= ""
def initramfs_generator_cmdline(d):
rootfs_packages = d.getVar('ROOTFS_PACKAGES') or ''
- if 'dracut' in rootfs_packages:
+ if 'dracut' in rootfs_packages or bb.utils.to_boolean(d.getVar('ROOTFS_USE_DRACUT')):
return "dracut --force /initrd.img \"$kernel_version\""
return "update-initramfs -u -v -k \"$kernel_version\""

--
2.51.0

Quirin Gylstorff

unread,
Oct 22, 2025, 11:08:07 AM (8 days ago) Oct 22
to isar-...@googlegroups.com, cedric.h...@siemens.com, jan.k...@siemens.com, felix.mo...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
.../recipes-initramfs/images/isar-dracut.bb | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 meta-isar/recipes-initramfs/images/isar-dracut.bb

diff --git a/meta-isar/recipes-initramfs/images/isar-dracut.bb b/meta-isar/recipes-initramfs/images/isar-dracut.bb
new file mode 100644
index 00000000..226fdeaa
--- /dev/null
+++ b/meta-isar/recipes-initramfs/images/isar-dracut.bb
@@ -0,0 +1,17 @@
+# Example of a custom initramfs image recipe. The image will be deployed to
+#
+# build/tmp/deploy/images/${MACHINE}/isar-initramfs-${DISTRO}-${MACHINE}.initrd.img
+#
+# This software is a part of ISAR.
+
+inherit initrd-dracut
+
+# Debian packages that should be installed into the system for building the
+# initramfs. E.g. the cryptsetup package which contains initramfs scripts for
+# decrypting a root filesystem.
+INITRAMFS_PREINSTALL += " \
+ "
+
+# Recipes that should be installed into the initramfs build rootfs.
+INITRAMFS_INSTALL += " \
+ "
--
2.51.0

Quirin Gylstorff

unread,
Oct 22, 2025, 11:08:09 AM (8 days ago) Oct 22
to isar-...@googlegroups.com, cedric.h...@siemens.com, jan.k...@siemens.com, felix.mo...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
.../dracut-example-lighttpd_0.1.bb | 26 ++++++++++
.../dracut-example-lighttpd/files/install.sh | 21 ++++++++
.../files/lighttpd.conf | 52 +++++++++++++++++++
.../files/lighttpd.service | 13 +++++
.../files/sysuser-lighttpd.conf | 3 ++
.../recipes-initramfs/images/isar-dracut.bb | 3 ++
6 files changed, 118 insertions(+)
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/dracut-example-lighttpd_0.1.bb
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.conf
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.service
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/files/sysuser-lighttpd.conf

diff --git a/meta-isar/recipes-initramfs/dracut-example-lighttpd/dracut-example-lighttpd_0.1.bb b/meta-isar/recipes-initramfs/dracut-example-lighttpd/dracut-example-lighttpd_0.1.bb
new file mode 100644
index 00000000..7895e689
--- /dev/null
+++ b/meta-isar/recipes-initramfs/dracut-example-lighttpd/dracut-example-lighttpd_0.1.bb
@@ -0,0 +1,26 @@
+#
+# Copyright (c) Siemens AG, 2025
+#
+# Authors:
+# Quirin Gylstorff <quirin.g...@siemens.com>
+#
+# SPDX-License-Identifier: MIT
+#
+require recipes-initramfs/dracut-module/dracut-module.inc
+
+DEBIAN_DEPENDS:append = ",lighttpd"
+SRC_URI += "file://install.sh \
+ file://lighttpd.conf \
+ file://lighttpd.service \
+ file://sysuser-lighttpd.conf \
+ "
+DRACUT_REQUIRED_BINARIES = "lighttpd"
+DRACUT_MODULE_DEPENDENCIES = "systemd-network-management"
+
+do_install[cleandirs] += "${D}/usr/lib/sysusers.d/"
+do_install:append() {
+ install -m 666 ${WORKDIR}/lighttpd.conf ${DRACUT_MODULE_PATH}
+ install -m 666 ${WORKDIR}/lighttpd.service ${DRACUT_MODULE_PATH}
+ install -m 666 ${WORKDIR}/sysuser-lighttpd.conf ${D}/usr/lib/sysusers.d/lighttpd.conf
+}
+
diff --git a/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh
new file mode 100644
index 00000000..e7e50ad4
--- /dev/null
+++ b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh
@@ -0,0 +1,21 @@
+install() {
+ inst_binary /usr/sbin/lighttpd
+ inst_binary /usr/sbin/lighttpd-angel
+ inst_binary /usr/sbin/lighttpd-disable-mod
+ inst_binary /usr/sbin/lighttpd-enable-mod
+ inst_multiple -o /usr/lib/lighttpd/*.so
+ inst_multiple -o /usr/share/lighttpd/*
+ inst_simple "${moddir}/lighttpd.service" "$systemdsystemunitdir/lighttpd.service"
+ mkdir -p -m 0700 "$initdir/etc/lighttpd/"
+ mkdir -p -m 0700 "$initdir/var/cache/lighttpd/compress"
+ mkdir -p -m 0700 "$initdir/var/cache/lighttpd/uploads"
+ mkdir -p -m 0700 "$initdir/var/log/lighttpd/"
+ mkdir -p -m 0755 "$initdir/var/www/html"
+ /usr/bin/install -m 0644 /usr/share/lighttpd/index.html "$initdir/var/www/html/index.html"
+ touch "$moddir"/error.log
+ /usr/bin/install -m 0644 "$moddir"/error.log "$initdir/var/log/lighttpd/error.log"
+ chown -R www-data:www-data "$initdir/var/log/lighttpd/"
+ inst_simple "${moddir}/lighttpd.conf" /etc/lighttpd/lighttpd.conf
+ inst_sysusers lighttpd.conf
+ systemctl -q --root "$initdir" enable lighttpd
+}
diff --git a/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.conf b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.conf
new file mode 100644
index 00000000..3a1bb351
--- /dev/null
+++ b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.conf
@@ -0,0 +1,52 @@
+server.modules = (
+ "mod_indexfile",
+ "mod_access",
+ "mod_alias",
+ "mod_redirect",
+)
+
+server.document-root = "/var/www/html"
+server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
+server.errorlog = "/var/log/lighttpd/error.log"
+server.pid-file = "/run/lighttpd.pid"
+server.username = "www-data"
+server.groupname = "www-data"
+server.port = 80
+
+# features
+#https://redmine.lighttpd.net/projects/lighttpd/wiki/Server_feature-flagsDetails
+server.feature-flags += ("server.h2proto" => "enable")
+server.feature-flags += ("server.h2c" => "enable")
+server.feature-flags += ("server.graceful-shutdown-timeout" => 5)
+#server.feature-flags += ("server.graceful-restart-bg" => "enable")
+
+# strict parsing and normalization of URL for consistency and security
+# https://redmine.lighttpd.net/projects/lighttpd/wiki/Server_http-parseoptsDetails
+# (might need to explicitly set "url-path-2f-decode" = "disable"
+# if a specific application is encoding URLs inside url-path)
+server.http-parseopts = (
+ "header-strict" => "enable",# default
+ "host-strict" => "enable",# default
+ "host-normalize" => "enable",# default
+ "url-normalize-unreserved"=> "enable",# recommended highly
+ "url-normalize-required" => "enable",# recommended
+ "url-ctrls-reject" => "enable",# recommended
+ "url-path-2f-decode" => "enable",# recommended highly (unless breaks app)
+ #"url-path-2f-reject" => "enable",
+ "url-path-dotseg-remove" => "enable",# recommended highly (unless breaks app)
+ #"url-path-dotseg-reject" => "enable",
+ #"url-query-20-plus" => "enable",# consistency in query string
+)
+
+index-file.names = ( "index.php", "index.html" )
+url.access-deny = ( "~", ".inc" )
+static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
+
+# default listening port for IPv6 falls back to the IPv4 port
+include "/etc/lighttpd/conf-enabled/*.conf"
+
+#server.compat-module-load = "disable"
+server.modules += (
+ "mod_dirlisting",
+ "mod_staticfile",
+)
diff --git a/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.service b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.service
new file mode 100644
index 00000000..da8c9033
--- /dev/null
+++ b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Lighttpd Daemon
+DefaultDependencies=no
+
+[Service]
+Type=simple
+PIDFile=/run/lighttpd.pid
+ExecStartPre=/usr/sbin/lighttpd -tt -f /etc/lighttpd/lighttpd.conf
+ExecStart=/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
+ExecReload=/bin/kill -USR1 $MAINPID
+Restart=on-failure
+[Install]
+WantedBy=sysinit.target
diff --git a/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/sysuser-lighttpd.conf b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/sysuser-lighttpd.conf
new file mode 100644
index 00000000..6507ccf3
--- /dev/null
+++ b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/sysuser-lighttpd.conf
@@ -0,0 +1,3 @@
+g www-data - -
+u www-data - - /var/www /usr/sbin/nologin
+
diff --git a/meta-isar/recipes-initramfs/images/isar-dracut.bb b/meta-isar/recipes-initramfs/images/isar-dracut.bb
index 226fdeaa..95739b12 100644
--- a/meta-isar/recipes-initramfs/images/isar-dracut.bb
+++ b/meta-isar/recipes-initramfs/images/isar-dracut.bb
@@ -14,4 +14,7 @@ INITRAMFS_PREINSTALL += " \

# Recipes that should be installed into the initramfs build rootfs.
INITRAMFS_INSTALL += " \
+ dracut-example-lighttpd \
"
+
+DRACUT_EXTRA_MODULES += "example-lighttpd"
--
2.51.0

Quirin Gylstorff

unread,
Oct 22, 2025, 11:08:09 AM (8 days ago) Oct 22
to isar-...@googlegroups.com, cedric.h...@siemens.com, jan.k...@siemens.com, felix.mo...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

This adds a helper similar to initramfs-hook to generate a dracut
module.

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
.../dracut-module/dracut-module.inc | 41 +++++++++++++++++++
.../dracut-module/files/module-setup.sh.tmpl | 20 +++++++++
2 files changed, 61 insertions(+)
create mode 100644 meta/recipes-initramfs/dracut-module/dracut-module.inc
create mode 100644 meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl

diff --git a/meta/recipes-initramfs/dracut-module/dracut-module.inc b/meta/recipes-initramfs/dracut-module/dracut-module.inc
new file mode 100644
index 00000000..54071105
--- /dev/null
+++ b/meta/recipes-initramfs/dracut-module/dracut-module.inc
@@ -0,0 +1,41 @@
+#
+# Copyright (c) Siemens AG, 2025
+#
+# Authors:
+# Quirin Gylstorff <quirin.g...@siemens.com>
+#
+# SPDX-License-Identifier: MIT
+#
+
+inherit dpkg-raw
+
+FILESPATH:append := ":${FILE_DIRNAME}/files"
+
+DPKG_ARCH = "all"
+
+DRACUT_MODULE_SETUP = "module-setup.sh"
+SRC_URI += "file://${DRACUT_MODULE_SETUP}.tmpl"
+
+DRACUT_REQUIRED_BINARIES = ""
+DRACUT_MODULE_DEPENDENCIES = ""
+DRACUT_MODULE_NO ??= "50"
+DRACUT_MODULE_NAME ?= "${@ d.getVar('PN')[7:] if d.getVar('PN').startswith('dracut-') else d.getVAR('PN')}"
+
+TEMPLATE_FILES:append = " \
+ ${DRACUT_MODULE_SETUP}.tmpl \
+ "
+
+TEMPLATE_VARS:append = " \
+ DRACUT_REQUIRED_BINARIES \
+ DRACUT_MODULE_DEPENDENCIES \
+ "
+DEBIAN_DEPENDS = "dracut-core"
+DRACUT_MODULE_PATH = "${D}/usr/lib/dracut/modules.d/${DRACUT_MODULE_NO}${DRACUT_MODULE_NAME}/"
+do_install[cleandirs] += "${DRACUT_MODULE_PATH}"
+do_install:append() {
+ install -m 770 ${WORKDIR}/${DRACUT_MODULE_SETUP} ${DRACUT_MODULE_PATH}
+ if [ -f ${WORKDIR}/install.sh ]; then
+ cat ${WORKDIR}/install.sh >> ${DRACUT_MODULE_PATH}/${DRACUT_MODULE_SETUP}
+ fi
+}
+
diff --git a/meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl b/meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl
new file mode 100644
index 00000000..46477cf4
--- /dev/null
+++ b/meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# called by dracut
+check() {
+
+ # If the binary(s) requirements are not fulfilled the module can't be installed.
+ require_binaries \
+ ${DRACUT_REQUIRED_BINARIES} \
+ || return 1
+
+ return 0
+
+}
+# Module dependency requirements.
+depends() {
+ echo "${DRACUT_MODULE_DEPENDENCIES}"
+ return 0
+
+}
+
--
2.51.0

Quirin Gylstorff

unread,
Oct 22, 2025, 11:08:10 AM (8 days ago) Oct 22
to isar-...@googlegroups.com, cedric.h...@siemens.com, jan.k...@siemens.com, felix.mo...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
doc/user_manual.md | 51 ++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 47 insertions(+), 4 deletions(-)

diff --git a/doc/user_manual.md b/doc/user_manual.md
index 30d60d4c..af988f1b 100644
--- a/doc/user_manual.md
+++ b/doc/user_manual.md
@@ -1681,10 +1681,11 @@ SRC_URI += "docker://debian;digest=sha256:f528891ab1aa484bf7233dbcc84f3c806c3e42
## Customize the initramfs

Isar supports the customization of initramfs images by providing an
-infrastructure for quickly creating hooks and by allowing to replace the
-Debian-generated image with a separately built one.
+infrastructure for quickly creating hooks in case of `initramfs-tools`
+or modules for `dracut` by allowing to replace the Debian-generated
+image with a separately built one.

-### Creating initramfs hooks
+### Creating initramfs-tools hooks

To create an initramfs hook that adds tools or modules to the image and may
also run custom scripts during boot, use the include file
@@ -1721,6 +1722,33 @@ initramfs.

See `initramfs-example` for an exemplary hook recipe.

+### Creating dracut modules
+
+To create a custom dracut module that adds tools, kernel-modules or services
+to the initrd, use the include file `recipes-initramfs/dracut-module/dracut-module.inc`.
+It is controlled by following variables:
+
+- `DRACUT_REQUIRED_BINARIES` defines the binaries required by the module.
+- `DRACUT_MODULE_DEPENDENCIES` defines dependencies to other dracut modules.
+- `DRACUT_MODULE_NO` defines the module number which prefixes the module name
+to define the execution order.The default is `50`.
+- `DRACUT_MODULE_NAME` the name of the module which is used to install the
+module in the initrd or as a dependency to other modules. It defaults to
+`${PN}` without the prefix `dracut-`.
+- `DRACUT_MODULE_PATH` contains the path to the installed module. It is set
+to `${D}/usr/lib/dracut/modules.d/${DRACUT_MODULE_NO}${DRACUT_MODULE_NAME}/`
+
+The `install()` function is added by storing the file `install.sh` in the
+files directory of the dracut module.
+
+Other files can by added to the module by coping them to the Module folder
+with:
+```bash
+install -m 666 ${WORKDIR}/lighttpd.service ${DRACUT_MODULE_PATH}
+```
+
+See `dracut-example-lighttpd` for an exemplary hook recipe.
+
### Creating an initramfs image aside the rootfs

To avoid shipping all tools and binaries needed to generate an initramfs, isar
@@ -1734,4 +1762,19 @@ self-built packages and `INITRAMFS_PREINSTALL` for prebuilt ones, analogously
to the respective `IMAGE_*` variables. Note that the kernel is automatically
added to `INITRAMFS_INSTALL` if `KERNEL_NAME` is set.

-See `isar-initramfs` for an example recipe.
+See `isar-initramfs` or `isar-dracut` for an example recipes.
+
+#### dracut config
+
+A dracut initramfs can be configured by the command line or a configuration file.
+The use configuration files is preferred:
+ - Debian provides dracut-config-* packages
+ - It is easier to upstream and to maintain.
+
+The configuration file can be chosen with the variable `DRACUT_CONFIG_PATH`. This variable
+contains the absolut path to the used configuration in the root file system.
+
+Still there are some use cases like debugging to add modules via the command line.
+For this the recipe meta/classes/initrd-dracut.bbclass provides the following options:
+ - `DRACUT_EXTRA_DRIVERS` add extra drivers to the dracut initrd
+ - `DRACUT_EXTRA_MODULES` add extra modules to the dracut initrd
--
2.51.0

Jan Kiszka

unread,
Oct 22, 2025, 11:45:02 AM (8 days ago) Oct 22
to Quirin Gylstorff, isar-...@googlegroups.com, cedric.h...@siemens.com, felix.mo...@siemens.com
Do we need more sudo? bwrap?

And why do we need this here now?

Jan

> else
> # ubuntu (dracut)
> cp ${ROOTFSDIR}/boot/initrd.img ${DEPLOYDIR}/${INITRD_DEPLOY_FILE}

--
Siemens AG, Foundational Technologies
Linux Expert Center

cedric.h...@siemens.com

unread,
Oct 22, 2025, 11:53:52 AM (8 days ago) Oct 22
to quirin.g...@siemens.com, Kiszka, Jan, isar-...@googlegroups.com, MOESSBAUER, Felix
dracut creates the initrd.img with 0600 perms so bwrap wouldn't help
here :(

we may need to check if we can convince dracut to use 0644

>
> Jan
>
> >              else
> >                  # ubuntu (dracut)
> >                  cp ${ROOTFSDIR}/boot/initrd.img
> > ${DEPLOYDIR}/${INITRD_DEPLOY_FILE}
>

--
Cedric Hombourger
Siemens AG
www.siemens.com

Jan Kiszka

unread,
Oct 22, 2025, 11:56:36 AM (8 days ago) Oct 22
to Hombourger, Cedric (FT FDS CES LX), Gylstorff, Quirin (FT RPD CED OES-DE), isar-...@googlegroups.com, Moessbauer, Felix (FT RPD CED OES-DE)
I was suspecting something like that but not reading it anywhere.

Besides micro-optimizations (chown first, then there is no need for sudo
cp), this should probably be done in dracut context, not for all
initramfs generators.

And, yes, checking with dracut if they consider this a feature or rather
a bug would be good as well.

Jan

>>
>> Jan
>>
>>>              else
>>>                  # ubuntu (dracut)
>>>                  cp ${ROOTFSDIR}/boot/initrd.img
>>> ${DEPLOYDIR}/${INITRD_DEPLOY_FILE}
>>
>


--

Jan Kiszka

unread,
Oct 22, 2025, 11:59:05 AM (8 days ago) Oct 22
to Quirin Gylstorff, isar-...@googlegroups.com, cedric.h...@siemens.com, felix.mo...@siemens.com
On 22.10.25 17:06, Quirin Gylstorff wrote:
General style remarks:

- lots of every new-lines at EOF
- lots of missing newlines elsewhere between those two

VARIABLE = "value"
do_something {

Repeating pattern...

Jan

Jan Kiszka

unread,
Oct 22, 2025, 12:08:34 PM (8 days ago) Oct 22
to Quirin Gylstorff, isar-...@googlegroups.com, cedric.h...@siemens.com, felix.mo...@siemens.com
On 22.10.25 17:06, Quirin Gylstorff wrote:
> From: Quirin Gylstorff <quirin.g...@siemens.com>
>

Some words about what we will get? An initramfs that runs a tiny
webserver, right?
But this config file is not for the dracut building rootfs, it's for the
initramfs, right? Is that installation location a good idea then?

> +}
> +
> diff --git a/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh
> new file mode 100644
> index 00000000..e7e50ad4
> --- /dev/null
> +++ b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh
> @@ -0,0 +1,21 @@
> +install() {
> + inst_binary /usr/sbin/lighttpd
> + inst_binary /usr/sbin/lighttpd-angel
> + inst_binary /usr/sbin/lighttpd-disable-mod
> + inst_binary /usr/sbin/lighttpd-enable-mod

Can't we generate that? Like HOOK_COPY_EXECS?

> + inst_multiple -o /usr/lib/lighttpd/*.so
> + inst_multiple -o /usr/share/lighttpd/*
> + inst_simple "${moddir}/lighttpd.service" "$systemdsystemunitdir/lighttpd.service"
> + mkdir -p -m 0700 "$initdir/etc/lighttpd/"
> + mkdir -p -m 0700 "$initdir/var/cache/lighttpd/compress"
> + mkdir -p -m 0700 "$initdir/var/cache/lighttpd/uploads"
> + mkdir -p -m 0700 "$initdir/var/log/lighttpd/"
> + mkdir -p -m 0755 "$initdir/var/www/html"
> + /usr/bin/install -m 0644 /usr/share/lighttpd/index.html "$initdir/var/www/html/index.html"
> + touch "$moddir"/error.log
> + /usr/bin/install -m 0644 "$moddir"/error.log "$initdir/var/log/lighttpd/error.log"
> + chown -R www-data:www-data "$initdir/var/log/lighttpd/"
> + inst_simple "${moddir}/lighttpd.conf" /etc/lighttpd/lighttpd.conf
> + inst_sysusers lighttpd.conf
> + systemctl -q --root "$initdir" enable lighttpd

This is a rather complex example. I'm still wondering what of all these
will repeat often enough to maybe simplify the install() functions
people will need to write (or not?) for their modules.

Did you already try to convert some of the isar-cip-core hooks? Those
basically made me create initramfs-hook/hook.inc in the end.
We cannot derive a package name from the module name, right? Packages
might be named differently or have multiple modules included?

Quirin Gylstorff

unread,
Oct 23, 2025, 4:00:11 AM (8 days ago) Oct 23
to Jan Kiszka, Hombourger, Cedric (FT FDS CES LX), isar-...@googlegroups.com, Moessbauer, Felix (FT RPD CED OES-DE)
I will look into it.

Quirin>

Quirin Gylstorff

unread,
Oct 23, 2025, 4:19:30 AM (8 days ago) Oct 23
to Jan Kiszka, isar-...@googlegroups.com, cedric.h...@siemens.com, felix.mo...@siemens.com


On 10/22/25 18:08, Jan Kiszka wrote:
> On 22.10.25 17:06, Quirin Gylstorff wrote:
>> From: Quirin Gylstorff <quirin.g...@siemens.com>
>>
>
> Some words about what we will get? An initramfs that runs a tiny
> webserver, right?
>
I will write something in v5. The intention was to have a complex
example which contains the most stuff necessary to create a module.

I should also try to document the stuff more.>> Signed-off-by: Quirin
inst_sysuser will use that config and it needs to be in that location.
I will write some documentation or a new hook.

>
>> +}
>> +
>> diff --git a/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh
>> new file mode 100644
>> index 00000000..e7e50ad4
>> --- /dev/null
>> +++ b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh
>> @@ -0,0 +1,21 @@
>> +install() {
>> + inst_binary /usr/sbin/lighttpd
>> + inst_binary /usr/sbin/lighttpd-angel
>> + inst_binary /usr/sbin/lighttpd-disable-mod
>> + inst_binary /usr/sbin/lighttpd-enable-mod
>
> Can't we generate that? Like HOOK_COPY_EXECS?
I will try to adapt that code.>
>> + inst_multiple -o /usr/lib/lighttpd/*.so
>> + inst_multiple -o /usr/share/lighttpd/*
>> + inst_simple "${moddir}/lighttpd.service" "$systemdsystemunitdir/lighttpd.service"
>> + mkdir -p -m 0700 "$initdir/etc/lighttpd/"
>> + mkdir -p -m 0700 "$initdir/var/cache/lighttpd/compress"
>> + mkdir -p -m 0700 "$initdir/var/cache/lighttpd/uploads"
>> + mkdir -p -m 0700 "$initdir/var/log/lighttpd/"
>> + mkdir -p -m 0755 "$initdir/var/www/html"
>> + /usr/bin/install -m 0644 /usr/share/lighttpd/index.html "$initdir/var/www/html/index.html"
>> + touch "$moddir"/error.log
>> + /usr/bin/install -m 0644 "$moddir"/error.log "$initdir/var/log/lighttpd/error.log"
>> + chown -R www-data:www-data "$initdir/var/log/lighttpd/"
>> + inst_simple "${moddir}/lighttpd.conf" /etc/lighttpd/lighttpd.conf
>> + inst_sysusers lighttpd.conf
>> + systemctl -q --root "$initdir" enable lighttpd
>
> This is a rather complex example. I'm still wondering what of all these
> will repeat often enough to maybe simplify the install() functions
> people will need to write (or not?) for their modules.
>
> Did you already try to convert some of the isar-cip-core hooks? Those
> basically made me create initramfs-hook/hook.inc in the end.
I haven't start yet. But I should start now the get the hook in a better
shape.>
Mhm, I look into it but the problem is already in debian that the module
name does not follow the pacakge name. We could add the convention to Isar:
- the package name must be `dracut-<module-name>`

Quirin>
> Jan
>

Quirin Gylstorff

unread,
5:45 AM (13 hours ago) 5:45 AM
to isar-...@googlegroups.com, jan.k...@siemens.com, felix.mo...@siemens.com, cedric.h...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

This is in preparation to support additional initramfs generators
like dracut.

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
meta/classes/rootfs.bbclass | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index 2fef3120..98da62fb 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -5,7 +5,13 @@ inherit deb-dl-dir

ROOTFS_ARCH ?= "${DISTRO_ARCH}"
ROOTFS_DISTRO ?= "${DISTRO}"
+
+def initramfs_generator_cmdline(d):
+ return "update-initramfs -u -v -k \"$kernel_version\""
+
ROOTFS_PACKAGES ?= ""
+ROOTFS_INITRAMFS_GENERATOR_CMD = "${@ d.getVar('ROOTFS_INITRAMFS_GENERATOR_CMDLINE').split()[0]}"
+ROOTFS_INITRAMFS_GENERATOR_CMDLINE = "${@ initramfs_generator_cmdline(d)}"
ROOTFS_BASE_DISTRO ?= "${BASE_DISTRO}"

# Features of the rootfs creation:
@@ -254,7 +260,7 @@ rootfs_disable_initrd_generation() {
set -e

mkdir -p "${ROOTFSDIR}${ROOTFS_STUBS_DIR}"
- ln -s /usr/bin/true ${ROOTFSDIR}${ROOTFS_STUBS_DIR}/update-initramfs
+ ln -s /usr/bin/true ${ROOTFSDIR}${ROOTFS_STUBS_DIR}/${ROOTFS_INITRAMFS_GENERATOR_CMD}

mkdir -p '${ROOTFSDIR}/etc/apt/apt.conf.d'
echo 'DPkg::Path ${ROOTFS_STUBS_DIR}:/usr/sbin:/usr/bin:/sbin:/bin;' \
@@ -577,7 +583,7 @@ rootfs_generate_initramfs() {
echo "Total number of modules: $mods_total"
echo "Generating initrd for kernel version: $kernel_version"
sudo -E chroot "${ROOTFSDIR}" sh -c ' \
- update-initramfs -u -v -k "$kernel_version"'
+ ${ROOTFS_INITRAMFS_GENERATOR_CMDLINE};'
done
if [ -n "${INITRD_DEPLOY_FILE}" ]; then
if [ -f "${ROOTFSDIR}/initrd.img" ]; then
--
2.51.0

Quirin Gylstorff

unread,
5:45 AM (13 hours ago) 5:45 AM
to isar-...@googlegroups.com, jan.k...@siemens.com, felix.mo...@siemens.com, cedric.h...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

Debian intends to change the default initrd generator from
initramfs-tools to dracut[1],[2].

This is a first draft to support multiple initrd generator in
ISAR. I tested it with bookworm and trixie.

You can switch a normal Debian version to a dracut based initrd
by installing the package `dracut`. This similar to a normal Debian
installation.

Customizing the initrd generation should be done with a seperate recipe
which inherit `initrd-dracut`. This is intentionally done to avoid
installing packages which are only used by the initrd generation process.

[1]: https://salsa.debian.org/kernel-team/meetings/-/wikis/20250730
[2]: https://meetbot.debian.net/debian-kernel/2025/debian-kernel.2025-08-06-19.00.log.html

Changes v5:
- cleanup formatting
- Add additional comments
- Add isar-work mount point to the rootfs to copy the initrd to the workdir
- make the build compatible with ubuntu
- use the feature to derive the module name from the installed package

Changes v4:
- fix extra_modules and extra_drivers
- extend user_manual to switch normal installation to dracut

Changes v3:
- drop initramfs patch
- add examples
- add user_manual section

Changes v2:
- extract the initramfs-cmd from the cmdline
- increase version of enable-fsck
- add function to print an error in case a invalid package is installed

Quirin Gylstorff (12):
Add dracut to custom kernel builds
rootfs: Allow to overwrite the initramfs generation cmds
rootfs: Add isar-work directory to rootfs mounts
rootfs: Copy the newly created initrd.img to the work directory
rootfs: Add dracut to initramfs generator
initramfs: allow to set the generator command
Add class to generate custom dracut initramfs
rootfs: add flag to use dracut if it is not part of the package list
Add example dracut initramfs
Add dracut module helper
Use lighttpd as a example how to add a dracut module
user_manual: Add dracut for initramfs generation

doc/user_manual.md | 73 ++++++++++++++-
.../dracut-example-lighttpd_0.1.bb | 44 ++++++++++
.../dracut-example-lighttpd/files/install.sh | 20 +++++
.../files/lighttpd.conf | 52 +++++++++++
.../files/lighttpd.service | 13 +++
.../files/sysuser-lighttpd.conf | 2 +
.../recipes-initramfs/images/isar-dracut.bb | 25 ++++++
meta/classes/initramfs.bbclass | 19 +++-
meta/classes/initrd-dracut.bbclass | 58 ++++++++++++
meta/classes/rootfs.bbclass | 41 ++++++---
.../dracut-module/dracut-module.inc | 88 +++++++++++++++++++
.../dracut-module/files/module-setup.sh.tmpl | 42 +++++++++
meta/recipes-kernel/linux/linux-custom.inc | 2 +-
13 files changed, 461 insertions(+), 18 deletions(-)
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/dracut-example-lighttpd_0.1.bb
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.conf
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.service
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/files/sysuser-lighttpd.conf
create mode 100644 meta-isar/recipes-initramfs/images/isar-dracut.bb
create mode 100644 meta/classes/initrd-dracut.bbclass
create mode 100644 meta/recipes-initramfs/dracut-module/dracut-module.inc
create mode 100644 meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl

--
2.51.0

Quirin Gylstorff

unread,
5:45 AM (13 hours ago) 5:45 AM
to isar-...@googlegroups.com, jan.k...@siemens.com, felix.mo...@siemens.com, cedric.h...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

This change makes it possible to install dracut without initramfs tools.

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
meta/recipes-kernel/linux/linux-custom.inc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc
index f2892921..c909d30b 100644
--- a/meta/recipes-kernel/linux/linux-custom.inc
+++ b/meta/recipes-kernel/linux/linux-custom.inc
@@ -31,7 +31,7 @@ KBUILD_DEPENDS ?= "build-essential:native, \
linux-image-${KERNEL_NAME_PROVIDED}:${DISTRO_ARCH} <kbuild !kernel>, \
rsync,"

-KERNEL_DEBIAN_DEPENDS ?= "initramfs-tools | linux-initramfs-tool, \
+KERNEL_DEBIAN_DEPENDS ?= "initramfs-tools | linux-initramfs-tool | dracut, \
kmod, \
linux-base (>= 4.3~),"

--
2.51.0

Quirin Gylstorff

unread,
5:45 AM (13 hours ago) 5:45 AM
to isar-...@googlegroups.com, jan.k...@siemens.com, felix.mo...@siemens.com, cedric.h...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

This allows to change the permissions of the initrd to 0644. And
all followup steps do not need sudo.

This is necessary as dracut creates the initrd with 0600 permissions.

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
meta/classes/rootfs.bbclass | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index 1f2ad80b..6b30744b 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -594,17 +594,11 @@ rootfs_generate_initramfs() {
echo "Total number of modules: $mods_total"
echo "Generating initrd for kernel version: $kernel_version"
sudo -E chroot "${ROOTFSDIR}" sh -c ' \
- ${ROOTFS_INITRAMFS_GENERATOR_CMDLINE};'
+ ${ROOTFS_INITRAMFS_GENERATOR_CMDLINE}; \
+ find /boot -name "initrd.img-$kernel_version*" -exec install --mode 0644 {} /isar-work/initrd.img \; \
+ '
done
- if [ -n "${INITRD_DEPLOY_FILE}" ]; then
- if [ -f "${ROOTFSDIR}/initrd.img" ]; then
- # debian (mkinitramfs)
- cp ${ROOTFSDIR}/initrd.img ${DEPLOYDIR}/${INITRD_DEPLOY_FILE}
- else
- # ubuntu (dracut)
- cp ${ROOTFSDIR}/boot/initrd.img ${DEPLOYDIR}/${INITRD_DEPLOY_FILE}
- fi
- fi
+ install --owner $(id -u) --group $(id -g) ${WORKDIR}/initrd.img ${DEPLOYDIR}/${INITRD_DEPLOY_FILE}
else
echo "no kernel in this rootfs, do not generate initrd"
fi
--
2.51.0

Quirin Gylstorff

unread,
5:45 AM (13 hours ago) 5:45 AM
to isar-...@googlegroups.com, jan.k...@siemens.com, felix.mo...@siemens.com, cedric.h...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

This allows to exchange the initramfs generator.

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---

Quirin Gylstorff

unread,
5:45 AM (13 hours ago) 5:45 AM
to isar-...@googlegroups.com, jan.k...@siemens.com, felix.mo...@siemens.com, cedric.h...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
.../recipes-initramfs/images/isar-dracut.bb | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 meta-isar/recipes-initramfs/images/isar-dracut.bb

diff --git a/meta-isar/recipes-initramfs/images/isar-dracut.bb b/meta-isar/recipes-initramfs/images/isar-dracut.bb
new file mode 100644

Quirin Gylstorff

unread,
5:45 AM (13 hours ago) 5:45 AM
to isar-...@googlegroups.com, jan.k...@siemens.com, felix.mo...@siemens.com, cedric.h...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

This class allows to customize a dracut initramfs by using
configuration files add addition modules and drivers.

It is recommended to use the addition of modules and drivers
sparely and prefer dracut configuration files.

This class has the option to add custom modules automatically to
the initramfs if:
- The modules are provided by the ISAR build system
- The module name is part of the package name, valid names are
- dracut-<module-name>
- <module-name>-dracut
- <something>-dracut-<module-name>

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
meta/classes/initrd-dracut.bbclass | 58 ++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 meta/classes/initrd-dracut.bbclass

diff --git a/meta/classes/initrd-dracut.bbclass b/meta/classes/initrd-dracut.bbclass
new file mode 100644
index 00000000..0602c364
--- /dev/null
+++ b/meta/classes/initrd-dracut.bbclass
@@ -0,0 +1,58 @@
+# This software is a part of ISAR.
+# This class provides the necessary options to
+# customize a dracut based initramfs.
+#
+# This class should not provide every dracut cmdline
+# option possible. Use the dracut configuration files.
+
+INITRAMFS_GENERATOR_PKG = "dracut"
+
+# The preferred way to configure dracut is to
+# provide dracut-config-<your-config> package which
+# contains all necessary config options
+DRACUT_CONFIG_PATH ??= ""
+
+# Variable to add additional kernel driver to the initrd
+DRACUT_EXTRA_DRIVERS ??= ""
+
+# Variable to add additional dracut modules to the initrd
+DRACUT_EXTRA_MODULES ??= ""
+
+# This option does not work with some of the dracut modules in Debian
+# as there is no standardized mapping between module name and package name
+DRACUT_EXTRACT_MODULES_FROM_PACKAGE_NAMES ??= "False"
+
+def extend_dracut_cmdline(d):
+ config_path = d.getVar('DRACUT_CONFIG_PATH') or ''
+ extra_drivers = d.getVar('DRACUT_EXTRA_DRIVERS') or ''
+ extra_modules = d.getVar('DRACUT_EXTRA_MODULES') or ''
+ enable_module_extraction = bb.utils.to_boolean(d.getVar('DRACUT_EXTRACT_MODULES_FROM_PACKAGE_NAMES'))
+ROOTFS_INITRAMFS_GENERATOR_CMDLINE:append = " ${@ extend_dracut_cmdline(d)}"
+
+inherit initramfs
--
2.51.0

Quirin Gylstorff

unread,
5:45 AM (13 hours ago) 5:45 AM
to isar-...@googlegroups.com, jan.k...@siemens.com, felix.mo...@siemens.com, cedric.h...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

This adds a helper similar to initramfs-hook to generate a dracut
module.

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
.../dracut-module/dracut-module.inc | 88 +++++++++++++++++++
.../dracut-module/files/module-setup.sh.tmpl | 42 +++++++++
2 files changed, 130 insertions(+)
create mode 100644 meta/recipes-initramfs/dracut-module/dracut-module.inc
create mode 100644 meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl

diff --git a/meta/recipes-initramfs/dracut-module/dracut-module.inc b/meta/recipes-initramfs/dracut-module/dracut-module.inc
new file mode 100644
index 00000000..a5f5ab51
--- /dev/null
+++ b/meta/recipes-initramfs/dracut-module/dracut-module.inc
@@ -0,0 +1,88 @@
+#
+# Copyright (c) Siemens AG, 2025
+#
+# Authors:
+# Quirin Gylstorff <quirin.g...@siemens.com>
+#
+# SPDX-License-Identifier: MIT
+#
+
+inherit dpkg-raw
+
+FILESPATH:append := ":${FILE_DIRNAME}/files"
+
+DPKG_ARCH = "all"
+
+DRACUT_MODULE_SETUP = "module-setup.sh"
+SRC_URI += "file://${DRACUT_MODULE_SETUP}.tmpl"
+
+DRACUT_MODULE_NO ??= "50"
+DRACUT_MODULE_NAME ?= "${@ d.getVar('PN')[7:] if d.getVar('PN').startswith('dracut-') else d.getVAR('PN')}"
+
+DEBIAN_DEPENDS = "dracut-core"
+DRACUT_MODULE_PATH = "${D}/usr/lib/dracut/modules.d/${DRACUT_MODULE_NO}${DRACUT_MODULE_NAME}/"
+
+DRACUT_REQUIRED_BINARIES ??= ""
+DRACUT_MODULE_DEPENDENCIES ??= ""
+DRACUT_CHECK_CONTENT_FILE_NAME ??= ""
+DRACUT_DEPENDS_CONTENT_FILE_NAME ??= ""
+DRACUT_CMDLINE_CONTENT_FILE_NAME ??= ""
+DRACUT_INSTALL_CONTENT_FILE_NAME ??= ""
+DRACUT_INSTALLKERNEL_CONTENT_FILE_NAME ??= ""
+
+def add_file_if_variable_is_set(d, variable_name, prefix):
+ variable = d.getVar(variable_name) or ''
+ if variable:
+ return f"{prefix}{variable}"
+ return ''
+
+def replace_marker_with_file_content(template_file, content_file, marker):
+ with open(template_file, 'r') as template_fd:
+ tmpl_content = template_fd.read()
+
+ with open(content_file, 'r') as content_fd:
+ content = content_fd.read()
+
+ new_tpml_content = tmpl_content.replace(marker, content)
+ with open(template_file, 'w') as tmpl_fd:
+ tmpl_fd.write(new_tpml_content)
+
+SRC_URI += "${@ add_file_if_variable_is_set(d, 'DRACUT_CHECK_CONTENT_FILE_NAME', 'file://')} \
+ ${@ add_file_if_variable_is_set(d, 'DRACUT_DEPENDS_CONTENT_FILE_NAME', 'file://')} \
+ ${@ add_file_if_variable_is_set(d, 'DRACUT_CMDLINE_CONTENT_FILE_NAME', 'file://')} \
+ ${@ add_file_if_variable_is_set(d, 'DRACUT_INSTALL_CONTENT_FILE_NAME', 'file://')} \
+ ${@ add_file_if_variable_is_set(d, 'DRACUT_INSTALLKERNEL_CONTENT_FILE_NAME', 'file://')}"
+
+TEMPLATE_FILES:append = " \
+ ${DRACUT_MODULE_SETUP}.tmpl \
+ "
+
+TEMPLATE_VARS:append = " \
+ DRACUT_REQUIRED_BINARIES \
+ DRACUT_MODULE_DEPENDENCIES \
+ "
+python do_add_additional_dracut_configuration() {
+ workdir = os.path.normpath(d.getVar('WORKDIR'))
+ module_setup = d.getVar('DRACUT_MODULE_SETUP')
+ module_setup_tpml = f"{module_setup}.tmpl"
+ content_file_name_to_marker = {
+ "DRACUT_CHECK_CONTENT_FILE_NAME" : "# ISAR_DRACUT_CHECK",
+ "DRACUT_DEPENDS_CONTENT_FILE_NAME" : "# ISAR_DRACUT_DEPENDS",
+ "DRACUT_CMDLINE_CONTENT_FILE_NAME" : "# ISAR_DRACUT_CMDLINE",
+ "DRACUT_INSTALL_CONTENT_FILE_NAME" : "# ISAR_DRACUT_INSTALL",
+ "DRACUT_INSTALLKERNEL_CONTENT_FILE_NAME" : "# ISAR_DRACUT_KERNELINSTALL"
+ }
+
+ for var_name, marker in content_file_name_to_marker.items():
+ file_name = d.getVar(var_name) or ''
+ if file_name:
+ replace_marker_with_file_content(f"{workdir}/{module_setup_tpml}",
+ f"{workdir}/{file_name}", marker)
+}
+addtask add_additional_dracut_configuration before do_transform_template after do_patch
+
+do_install[cleandirs] += "${DRACUT_MODULE_PATH}"
+do_install:append() {
+ install -m 770 ${WORKDIR}/${DRACUT_MODULE_SETUP} ${DRACUT_MODULE_PATH}
+
+}
diff --git a/meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl b/meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl
new file mode 100644
index 00000000..be0f4c54
--- /dev/null
+++ b/meta/recipes-initramfs/dracut-module/files/module-setup.sh.tmpl
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+# called by dracut
+check() {
+
+ # If the binary(s) requirements are not fulfilled the module can't be installed.
+ require_binaries \
+ ${DRACUT_REQUIRED_BINARIES} \
+ || return 1
+ # ISAR_DRACUT_CHECK
+ return 0
+
+}
+
+# Module dependency requirements.
+depends() {
+ echo "${DRACUT_MODULE_DEPENDENCIES}"
+ # ISAR_DRACUT_DEPENDS
+ return 0
+
+}
+installkernel() {
+ # ISAR_DRACUT_KERNELINSTALL
+ return 0
+}
+
+cmdline() {
+ # ISAR_DRACUT_CMDLINE
+ return 0
+}
+
+install() {
+ for executable in ${DRACUT_REQUIRED_BINARIES}; do
+ if exec_path=$(command -v $executable 2>/dev/null); then
+ inst_binary "$exec_path"
+ else
+ echo "(ERROR): Unable to copy $executable" >&2
+ exit 1
+ fi
+ done
+ # ISAR_DRACUT_INSTALL
+}
--
2.51.0

Quirin Gylstorff

unread,
5:45 AM (13 hours ago) 5:45 AM
to isar-...@googlegroups.com, jan.k...@siemens.com, felix.mo...@siemens.com, cedric.h...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

This in preparation for dracut. `dracut` creates the initrd.img with
0600 permission. These permission makes it necessary to copy
the initrd.img from the sudo context to the deploy dir.

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
meta/classes/rootfs.bbclass | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index 98da62fb..1f2ad80b 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -138,6 +138,12 @@ rootfs_do_mounts() {
mount -o bind,private '${REPO_ISAR_DIR}/${DISTRO}' '${ROOTFSDIR}/isar-apt'
fi

+ if [ ! -e '$ROOTFSDIR'/isar-work ]; then
+ mkdir -p '${ROOTFSDIR}/isar-work'
+ mountpoint -q '${ROOTFSDIR}/isar-work' || \
+ mount -o bind,private '${WORKDIR}' '${ROOTFSDIR}/isar-work'
+ fi
+
# Mount base-apt if 'ISAR_USE_CACHED_BASE_REPO' is set
if [ "${@repr(bb.utils.to_boolean(d.getVar('ISAR_USE_CACHED_BASE_REPO')))}" = 'True' ]
then
@@ -162,6 +168,11 @@ rootfs_do_umounts() {
rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/base-apt
fi

+ if mountpoint -q '${ROOTFSDIR}/isar-work'; then
+ umount '${ROOTFSDIR}/isar-work'
+ rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/isar-work
+ fi
+
if mountpoint -q '${ROOTFSDIR}/dev/pts'; then
umount '${ROOTFSDIR}/dev/pts'
fi
--
2.51.0

Quirin Gylstorff

unread,
5:45 AM (13 hours ago) 5:45 AM
to isar-...@googlegroups.com, jan.k...@siemens.com, felix.mo...@siemens.com, cedric.h...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

This is intend for version where dracut is the default initramfs where
dracut is part of the dependency tree and not explicit requested.

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
meta/classes/rootfs.bbclass | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index 512ba021..0502bf45 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -6,9 +6,14 @@ inherit deb-dl-dir
ROOTFS_ARCH ?= "${DISTRO_ARCH}"
ROOTFS_DISTRO ?= "${DISTRO}"

+# This variable is intended to be set if dracut is
+# the default initramfs generator and it is not
+# possible to derive the value in another way
+ROOTFS_USE_DRACUT ??= ""
+
def initramfs_generator_cmdline(d):
rootfs_packages = d.getVar('ROOTFS_PACKAGES') or ''
- if 'dracut' in rootfs_packages:
+ if 'dracut' in rootfs_packages or bb.utils.to_boolean(d.getVar('ROOTFS_USE_DRACUT')):
return "dracut --force --kver \"$kernel_version\""
return "update-initramfs -u -v -k \"$kernel_version\""

--
2.51.0

Quirin Gylstorff

unread,
5:45 AM (13 hours ago) 5:45 AM
to isar-...@googlegroups.com, jan.k...@siemens.com, felix.mo...@siemens.com, cedric.h...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
meta/classes/rootfs.bbclass | 3 +++
1 file changed, 3 insertions(+)

diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index 6b30744b..512ba021 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -7,6 +7,9 @@ ROOTFS_ARCH ?= "${DISTRO_ARCH}"
ROOTFS_DISTRO ?= "${DISTRO}"

def initramfs_generator_cmdline(d):
+ rootfs_packages = d.getVar('ROOTFS_PACKAGES') or ''
+ if 'dracut' in rootfs_packages:
+ return "dracut --force --kver \"$kernel_version\""
return "update-initramfs -u -v -k \"$kernel_version\""

ROOTFS_PACKAGES ?= ""
--
2.51.0

Quirin Gylstorff

unread,
5:45 AM (13 hours ago) 5:45 AM
to isar-...@googlegroups.com, jan.k...@siemens.com, felix.mo...@siemens.com, cedric.h...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

This example allows to add the lighttpd webserver to the
initrd. The example shows the following use cases:
- add a own service to the initrd
- add a user via systemd
- add file to configure a service

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
.../dracut-example-lighttpd_0.1.bb | 44 ++++++++++++++++
.../dracut-example-lighttpd/files/install.sh | 20 +++++++
.../files/lighttpd.conf | 52 +++++++++++++++++++
.../files/lighttpd.service | 13 +++++
.../files/sysuser-lighttpd.conf | 2 +
.../recipes-initramfs/images/isar-dracut.bb | 8 +++
6 files changed, 139 insertions(+)
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/dracut-example-lighttpd_0.1.bb
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.conf
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.service
create mode 100644 meta-isar/recipes-initramfs/dracut-example-lighttpd/files/sysuser-lighttpd.conf

diff --git a/meta-isar/recipes-initramfs/dracut-example-lighttpd/dracut-example-lighttpd_0.1.bb b/meta-isar/recipes-initramfs/dracut-example-lighttpd/dracut-example-lighttpd_0.1.bb
new file mode 100644
index 00000000..5889a5ed
--- /dev/null
+++ b/meta-isar/recipes-initramfs/dracut-example-lighttpd/dracut-example-lighttpd_0.1.bb
@@ -0,0 +1,44 @@
+#
+# Copyright (c) Siemens AG, 2025
+#
+# Authors:
+# Quirin Gylstorff <quirin.g...@siemens.com>
+#
+# SPDX-License-Identifier: MIT
+#
+# This example adds the lighttpd server to the dracut initrd
+
+require recipes-initramfs/dracut-module/dracut-module.inc
+
+# Additional install instructions
+DRACUT_INSTALL_CONTENT_FILE_NAME = "install.sh"
+
+DEBIAN_DEPENDS:append = ",lighttpd, kbd, passwd, \
+ dracut-network, dbus-daemon, iproute2, \
+ dracut-example-lighttpd, systemd-sysv, systemd-resolved, systemd-timesyncd"
+
+DEBIAN_DEPENDS:append:trixie = ", systemd-cryptsetup"
+
+
+SRC_URI += "file://lighttpd.conf \
+ file://lighttpd.service \
+ file://sysuser-lighttpd.conf \
+ "
+
+# lighttpd binaries
+DRACUT_REQUIRED_BINARIES = "lighttpd \
+ lighttpd-angel \
+ lighttpd-disable-mod \
+ lighttpd-enable-mod \
+ lighty-enable-mod \
+ "
+# we need networking
+DRACUT_MODULE_DEPENDENCIES = "systemd-network-management"
+
+do_install[cleandirs] += "${D}/usr/lib/sysusers.d/"
+do_install() {
+ install -m 666 ${WORKDIR}/lighttpd.conf ${DRACUT_MODULE_PATH}
+ install -m 666 ${WORKDIR}/lighttpd.service ${DRACUT_MODULE_PATH}
+ # install sysuser to be used by dracut
+ install -m 666 ${WORKDIR}/sysuser-lighttpd.conf ${D}/usr/lib/sysusers.d/lighttpd.conf
+}
diff --git a/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh
new file mode 100644
index 00000000..b7295b94
--- /dev/null
+++ b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/install.sh
@@ -0,0 +1,20 @@
+inst_multiple -o /usr/lib/lighttpd/*.so
+inst_multiple -o /usr/share/lighttpd/*
+
+inst_simple "${moddir}/lighttpd.service" "$systemdsystemunitdir/lighttpd.service"
+inst_simple "${moddir}/lighttpd.conf" /etc/lighttpd/lighttpd.conf
+
+# use the sysuser lighttpd config to create the necessary user
+inst_sysusers lighttpd.conf
+
+mkdir -p -m 0700 "$initdir/etc/lighttpd/"
+mkdir -p -m 0700 "$initdir/var/cache/lighttpd/compress"
+mkdir -p -m 0700 "$initdir/var/cache/lighttpd/uploads"
+mkdir -p -m 0700 "$initdir/var/log/lighttpd/"
+mkdir -p -m 0755 "$initdir/var/www/html"
+
+/usr/bin/install -m 0644 /usr/share/lighttpd/index.html "$initdir/var/www/html/index.html"
+touch "$moddir"/error.log
+/usr/bin/install -m 0644 "$moddir"/error.log "$initdir/var/log/lighttpd/error.log"
+chown -R www-data:www-data "$initdir/var/log/lighttpd/"
+systemctl -q --root "$initdir" enable lighttpd
diff --git a/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.conf b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.conf
new file mode 100644
new file mode 100644
index 00000000..da8c9033
--- /dev/null
+++ b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/lighttpd.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Lighttpd Daemon
+DefaultDependencies=no
+
+[Service]
+Type=simple
+PIDFile=/run/lighttpd.pid
+ExecStartPre=/usr/sbin/lighttpd -tt -f /etc/lighttpd/lighttpd.conf
+ExecStart=/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
+ExecReload=/bin/kill -USR1 $MAINPID
+Restart=on-failure
+[Install]
+WantedBy=sysinit.target
diff --git a/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/sysuser-lighttpd.conf b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/sysuser-lighttpd.conf
new file mode 100644
index 00000000..37060a65
--- /dev/null
+++ b/meta-isar/recipes-initramfs/dracut-example-lighttpd/files/sysuser-lighttpd.conf
@@ -0,0 +1,2 @@
+g www-data - -
+u www-data - - /var/www /usr/sbin/nologin
diff --git a/meta-isar/recipes-initramfs/images/isar-dracut.bb b/meta-isar/recipes-initramfs/images/isar-dracut.bb
index 226fdeaa..aa55e360 100644
--- a/meta-isar/recipes-initramfs/images/isar-dracut.bb
+++ b/meta-isar/recipes-initramfs/images/isar-dracut.bb
@@ -14,4 +14,12 @@ INITRAMFS_PREINSTALL += " \

# Recipes that should be installed into the initramfs build rootfs.
INITRAMFS_INSTALL += " \
+ dracut-example-lighttpd \
"
+
+# This option does not work with some of the dracut modules in Debian
+# as there is no standardized mapping between module name and package name
+DRACUT_EXTRACT_MODULES_FROM_PACKAGE_NAMES = "True"
+
+# Alternative is to add the example module manually
+#DRACUT_EXTRA_MODULES += "example-lighttpd"
--
2.51.0

Quirin Gylstorff

unread,
5:45 AM (13 hours ago) 5:45 AM
to isar-...@googlegroups.com, jan.k...@siemens.com, felix.mo...@siemens.com, cedric.h...@siemens.com
From: Quirin Gylstorff <quirin.g...@siemens.com>

Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
---
doc/user_manual.md | 73 +++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 69 insertions(+), 4 deletions(-)

diff --git a/doc/user_manual.md b/doc/user_manual.md
index ecb1fb2c..7133b217 100644
--- a/doc/user_manual.md
+++ b/doc/user_manual.md
@@ -1682,13 +1682,36 @@ CONTAINER_DELETE_AFTER_LOAD = "1"
SRC_URI += "docker://debian;digest=sha256:f528891ab1aa484bf7233dbcc84f3c806c3e427571d75510a9d74bb5ec535b33;tag=bookworm-20240701-slim"
```

+
+## Switch from initramfs-tools to dracut
+
+To build a Isar image with dracut as the initramfs generator instead
+of initramfs-tools in Debian 13(trixie) or previous versions add dracut
+as a package to the image:
+
+```
+IMAGE_PREINSTALL += "dracut"
+```
+
+An dracut based initrd contains the file `/usr/lib/initrd-release`. In
+case of trixie the file has the following content:
+
+```bash
+NAME=dracut
+ID=dracut
+VERSION_ID="106-6"
+ANSI_COLOR="0;34"
+```
+
+
## Customize the initramfs

Isar supports the customization of initramfs images by providing an
-infrastructure for quickly creating hooks and by allowing to replace the
-Debian-generated image with a separately built one.
+infrastructure for quickly creating hooks in case of `initramfs-tools`
+or modules for `dracut` by allowing to replace the Debian-generated
+image with a separately built one.

-### Creating initramfs hooks
+### Creating initramfs-tools hooks

To create an initramfs hook that adds tools or modules to the image and may
also run custom scripts during boot, use the include file
@@ -1725,6 +1748,33 @@ initramfs.

See `initramfs-example` for an exemplary hook recipe.

+### Creating dracut modules
+
+To create a custom dracut module that adds tools, kernel-modules or services
+to the initrd, use the include file `recipes-initramfs/dracut-module/dracut-module.inc`.
+It is controlled by following variables:
+
+- `DRACUT_REQUIRED_BINARIES` defines the binaries required by the module.
+- `DRACUT_MODULE_DEPENDENCIES` defines dependencies to other dracut modules.
+- `DRACUT_MODULE_NO` defines the module number which prefixes the module name
+to define the execution order.The default is `50`.
+- `DRACUT_MODULE_NAME` the name of the module which is used to install the
+module in the initrd or as a dependency to other modules. It defaults to
+`${PN}` without the prefix `dracut-`.
+- `DRACUT_MODULE_PATH` contains the path to the installed module. It is set
+to `${D}/usr/lib/dracut/modules.d/${DRACUT_MODULE_NO}${DRACUT_MODULE_NAME}/`
+
+The `install()` function is added by storing the file `install.sh` in the
+files directory of the dracut module.
+
+Other files can by added to the module by coping them to the Module folder
+with:
+```bash
+install -m 666 ${WORKDIR}/lighttpd.service ${DRACUT_MODULE_PATH}
+```
+
+See `dracut-example-lighttpd` for an exemplary hook recipe.
+
### Creating an initramfs image aside the rootfs

To avoid shipping all tools and binaries needed to generate an initramfs, isar
@@ -1738,4 +1788,19 @@ self-built packages and `INITRAMFS_PREINSTALL` for prebuilt ones, analogously

Jan Kiszka

unread,
7:26 AM (11 hours ago) 7:26 AM
to Quirin Gylstorff, isar-...@googlegroups.com, felix.mo...@siemens.com, cedric.h...@siemens.com
On 30.10.25 10:44, Quirin Gylstorff wrote:
> From: Quirin Gylstorff <quirin.g...@siemens.com>
>
> This adds a helper similar to initramfs-hook to generate a dracut
> module.
>
> Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
> ---
> .../dracut-module/dracut-module.inc | 88 +++++++++++++++++++

Maybe we should start with a dracut-module.bbclass right from the beginning?

Quirin Gylstorff

unread,
7:53 AM (11 hours ago) 7:53 AM
to Jan Kiszka, isar-...@googlegroups.com, felix.mo...@siemens.com, cedric.h...@siemens.com


On 10/30/25 12:26, Jan Kiszka wrote:
> On 30.10.25 10:44, Quirin Gylstorff wrote:
>> From: Quirin Gylstorff <quirin.g...@siemens.com>
>>
>> This adds a helper similar to initramfs-hook to generate a dracut
>> module.
>>
>> Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
>> ---
>> .../dracut-module/dracut-module.inc | 88 +++++++++++++++++++
>
> Maybe we should start with a dracut-module.bbclass right from the beginning?

I would do that in v6 - it is a new API so there should be no issue :-D

Quirin>
> Jan
>

Quirin Gylstorff

unread,
8:04 AM (10 hours ago) 8:04 AM
to isar-...@googlegroups.com, jan.k...@siemens.com, felix.mo...@siemens.com, cedric.h...@siemens.com


On 10/30/25 10:44, 'Quirin Gylstorff' via isar-users wrote:
> From: Quirin Gylstorff <quirin.g...@siemens.com>
>
> This allows to change the permissions of the initrd to 0644. And
> all followup steps do not need sudo.
>
> This is necessary as dracut creates the initrd with 0600 permissions.
>
> Signed-off-by: Quirin Gylstorff <quirin.g...@siemens.com>
> ---
> meta/classes/rootfs.bbclass | 14 ++++----------
> 1 file changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
> index 1f2ad80b..6b30744b 100644
> --- a/meta/classes/rootfs.bbclass
> +++ b/meta/classes/rootfs.bbclass
> @@ -594,17 +594,11 @@ rootfs_generate_initramfs() {
> echo "Total number of modules: $mods_total"
> echo "Generating initrd for kernel version: $kernel_version"
> sudo -E chroot "${ROOTFSDIR}" sh -c ' \
> - ${ROOTFS_INITRAMFS_GENERATOR_CMDLINE};'
> + ${ROOTFS_INITRAMFS_GENERATOR_CMDLINE}; \
> + find /boot -name "initrd.img-$kernel_version*" -exec install --mode 0644 {} /isar-work/initrd.img \; \
> + '
This patch does not change the behavior:
- copy the last generated initrd to workdir

The loop was added to support mulitple kernel installations with commit
f6cd9f9ee.

Quirin> done
Reply all
Reply to author
Forward
0 new messages