]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
feat(dracut): print the computed configuration and exit
authorJo Zzsi <jozzsicsataban@gmail.com>
Tue, 16 Sep 2025 11:47:45 +0000 (07:47 -0400)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Mon, 22 Sep 2025 13:36:17 +0000 (09:36 -0400)
Dracut is able to inspect the host and auto-determine the best
configuration and compine the computed configurtion with the
distribution and user configuration.

Since dracut does not have a dry-run option, there is no good
option for an external tool to determine if a dracut invocaton
will result in creating initramfs in hostonly or non-hostonly mode.

Add a command line option that is meant to just compute the
current dracut configuration, print it out and exit.

dracut.sh
man/dracut.8.adoc
shell-completion/bash/dracut

index 53c572982ba4a7b3f0b56a9dbf38e7916f70f4ce..7208441c61ce0de01c4a7cd25a010a48f3599268 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -276,6 +276,7 @@ Creates initial ramdisk images for preloading modules
                          build.
   --keep                Keep the temporary initramfs for debugging purposes.
   --printsize           Print out the module install size.
+  --printconfig         Print the computed configuration and exit.
   --sshkey [SSHKEY]     Add SSH key to initramfs (use with ssh-client module).
   --logfile [FILE]      Logfile to use (overrides configuration setting).
   --reproducible        Create reproducible images.
@@ -467,6 +468,7 @@ rearrange_params() {
             --long show-modules \
             --long keep \
             --long printsize \
+            --long printconfig \
             --long regenerate-all \
             --long parallel \
             --long noimageifnotneeded \
@@ -881,6 +883,7 @@ while :; do
             ;;
         --keep) keep="yes" ;;
         --printsize) printsize="yes" ;;
+        --printconfig) printconfig="yes" ;;
         --regenerate-all) regenerate_all_l="yes" ;;
         -p | --parallel) parallel_l="yes" ;;
         --noimageifnotneeded) noimageifnotneeded="yes" ;;
@@ -1965,6 +1968,42 @@ export initdir dracutbasedir \
     hostonly_cmdline loginstall \
     squashdir squash_compress
 
+if [[ $printconfig ]]; then
+    for v in add_dracutmodules \
+        add_fstab \
+        debug \
+        dracutmodules \
+        drivers \
+        fileloglvl \
+        filesystems \
+        force_add_dracutmodules \
+        fscks \
+        fw_dir \
+        hostonly_cmdline \
+        kernel_only \
+        kmsgloglvl \
+        libdirs \
+        logfile \
+        loginstall \
+        lvmconf \
+        mdadmconf \
+        no_kernel \
+        nofscks \
+        omit_dracutmodules \
+        omit_drivers \
+        prefix \
+        ro_mnt \
+        squash_compress \
+        sshkey \
+        use_fstab; do
+        if [[ -n ${!v} ]]; then
+            echo "dracutconfig: $v=${!v}"
+        fi
+    done
+
+    exit 0
+fi
+
 mods_to_load=""
 # check all our modules to see if they should be sourced.
 # This builds a list of modules that we will install next.
index af62238d76651ed915bb949c011f5a41cd5a021f..4c9c5c13ab43e7339bb0dd9ad4386fa0fe706390 100644 (file)
@@ -578,6 +578,9 @@ will not be able to boot. Equivalent to "--compress=zstd -15 -q -T0".
 **--keep**::
     Keep the initramfs temporary directory for debugging purposes.
 
+**--printconfig**::
+    Print the computed configuration and exit.
+
 **--printsize**::
     Print out the module install size.
 
index 8313bf46493a31828e3a0a1c140940483c41106d..51bd33c7b8bc11dc7f3da26ac8f6a69e43af270b 100644 (file)
@@ -37,7 +37,7 @@ _dracut() {
             --enhanced-cpio --rebuild --aggressive-strip --hostonly-cmdline
             --no-hostonly-cmdline --no-hostonly-default-device --nofscks
             --hostonly-i18n --no-hostonly-i18n --lzo --lz4 --no-reproducible
-            --no-uefi --no-machineid --version --parallel
+            --no-uefi --no-machineid --version --parallel --printconfig
             '
         [ARG]='-a -m -o -d -I -k -c -L -r -i
             --kver --add --force-add --add-drivers --force-drivers