From 8fd41b13150a8a6cb0f46051753e382d04ad4f81 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Tue, 3 Nov 2026 21:16:47 +0100 Subject: [PATCH] Clean up the capture initramfs config on Ubuntu sources Capture copies an initramfs-tools hook and conf.d/confluent.conf into the source to build the deployment initramfs, but only ever removed the EL dracut module afterwards. With MODULES=list left in place, the source's next initramfs update was limited to the hook's driver list, and a source captured again carried both files into the image, where rebuilding the initramfs on install to disk shrank the clones' initramfs the same way. Remove them after capture and leave them out of the image. --- imgutil/imgutil | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/imgutil/imgutil b/imgutil/imgutil index e8187531..4d6e5f4e 100644 --- a/imgutil/imgutil +++ b/imgutil/imgutil @@ -150,6 +150,11 @@ class FileMasker(): secontext = secontext.split(b'\x00', 1)[0].decode('utf8') subprocess.check_call(['chcon', secontext, tmaskwith]) +# What capture adds to an Ubuntu source to build the deployment initramfs. +# MODULES=list in there would also shrink the initramfs of the source and of +# installed clones to the hook's driver list. +CAPTURE_BOOT_FILES = ('/etc/initramfs-tools/hooks/confluent', + '/etc/initramfs-tools/conf.d/confluent.conf') # Directories whose contents are host specific leftovers (scratch space, # crash dumps, logs, caches, cached credentials). The directories themselves # are kept so their mode, ownership and labels survive. @@ -171,7 +176,7 @@ CAPTURE_DROP_FILES = ( # identity and stable privacy IPv6 addresses '/var/lib/dhcpcd/*.lease*', '/var/lib/dhcpcd/duid', '/var/lib/dhcpcd/secret', '/var/lib/NetworkManager/secret_key', - '/root/.*_history', '/root/.lesshst', '/root/.viminfo') + '/root/.*_history', '/root/.lesshst', '/root/.viminfo') + CAPTURE_BOOT_FILES # Network profiles with static addresses of the source, which would come up # on interfaces confignet does not configure (deployment writes the node's # own, as with the netplan files masked in capture_fs). Profiles without @@ -291,6 +296,11 @@ def capture_local_cleanup(): shutil.rmtree('/usr/lib/dracut/modules.d/97confluent') except Exception: pass + for bootfile in CAPTURE_BOOT_FILES: + try: + os.remove(bootfile) + except FileNotFoundError: + pass subprocess.check_call(['umount', '/run/imgutil/capout']) def build_boot_tree(targpath):