]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
refactor(overlayfs): move legacy option handing into a cmdline hook
authorBenjamin Drung <benjamin.drung@canonical.com>
Tue, 3 Feb 2026 11:34:14 +0000 (12:34 +0100)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Wed, 4 Feb 2026 09:53:00 +0000 (04:53 -0500)
Reading the code and understanding the logic gets complicated by
supporting legacy kernel command line options. This will be especially
be true once `rd.overlayfs` gets merged into `rd.overlay`.

So move all the legacy kernel command line option handling into the
separate `parse-legacy-overlayfs-options.sh` script that is executed
during the cmdline stage.

Check that no legacy option is queried directly:

```
git grep getarg -- modules.d/ | grep -w -- -d | grep live
```

modules.d/70dmsquash-live-autooverlay/create-overlay.sh
modules.d/70dmsquash-live/dmsquash-generator.sh
modules.d/70dmsquash-live/dmsquash-live-root.sh
modules.d/70livenet/livenet-generator.sh
modules.d/70overlayfs/module-setup.sh
modules.d/70overlayfs/mount-overlayfs.sh
modules.d/70overlayfs/parse-legacy-overlayfs-options.sh [new file with mode: 0755]
modules.d/70overlayfs/prepare-overlayfs.sh

index 01a5760661def8fb9392a818ef3380e45d17f7a4..d86fc288f49a13f3dffe8db2383eff56aab80dbc 100755 (executable)
@@ -9,7 +9,7 @@ if getargbool 0 rd.live.debug; then
 fi
 
 gatherData() {
-    overlay=$(getarg rd.overlay -d rd.live.overlay)
+    overlay=$(getarg rd.overlay)
     if [ -z "$overlay" ]; then
         info "Skipping overlay creation: kernel command line parameter 'rd.overlay' is not set"
         exit 0
index ef6b072b7770bf7386db2e4ce010d48f36ab2826..1e321bf68f25d00a24faa669d599948e519e526a 100755 (executable)
@@ -45,8 +45,8 @@ GENERATOR_DIR="$2"
 [ -z "$GENERATOR_DIR" ] && exit 1
 [ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR"
 
-getargbool 0 rd.overlay.readonly -d rd.live.overlayfs.readonly && readonly_overlay="--readonly" || readonly_overlay=""
-getargbool 0 rd.overlayfs -d rd.live.overlay.overlayfs && overlayfs="yes"
+getargbool 0 rd.overlay.readonly && readonly_overlay="--readonly" || readonly_overlay=""
+getargbool 0 rd.overlayfs && overlayfs="yes"
 [ -e /xor_overlayfs ] && xor_overlayfs="yes"
 [ -e /xor_readonly ] && xor_readonly="--readonly"
 ROOTFLAGS="$(getarg rootflags)"
index 9829f0a998aa90ef8d3c0b9a45ff4d3abbbd441e..db8b2ef8c3a83a186070fff85e0f5e474bbc0f2e 100755 (executable)
@@ -23,16 +23,16 @@ squash_image=$(getarg rd.live.squashimg)
 [ -z "$squash_image" ] && squash_image="squashfs.img"
 
 getargbool 0 rd.live.ram && live_ram="yes"
-getargbool 0 rd.overlay.reset -d rd.live.overlay.reset && reset_overlay="yes"
-getargbool 0 rd.overlay.readonly -d rd.live.overlay.readonly && readonly_overlay="--readonly" || readonly_overlay=""
+getargbool 0 rd.overlay.reset && reset_overlay="yes"
+getargbool 0 rd.overlay.readonly && readonly_overlay="--readonly" || readonly_overlay=""
 getargbool 0 rd.live.overlay.nouserconfirmprompt && overlay_no_user_confirm_prompt="--noprompt" || overlay_no_user_confirm_prompt=""
-overlay=$(getarg rd.overlay -d rd.live.overlay)
+overlay=$(getarg rd.overlay)
 getargbool 0 rd.writable.fsimg && writable_fsimg="yes"
 overlay_size=$(getarg rd.live.overlay.size=)
 [ -z "$overlay_size" ] && overlay_size=32768
 
 getargbool 0 rd.live.overlay.thin && thin_snapshot="yes"
-getargbool 0 rd.overlayfs -d rd.live.overlay.overlayfs && overlayfs="yes"
+getargbool 0 rd.overlayfs && overlayfs="yes"
 
 # Take a path to a disk label and return the parent disk if it is a partition
 # Otherwise returns the original path
index 3980bf811b563bc027575e66d0b2e1b52c1be0e0..84b05fa3730d190476e2ed3672ed3e97fd2bee97 100755 (executable)
@@ -49,8 +49,8 @@ GENERATOR_DIR="$2"
 
 [ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR"
 
-getargbool 0 rd.overlay.readonly -d rd.live.overlay.readonly && readonly_overlay="--readonly" || readonly_overlay=""
-getargbool 0 rd.overlayfs -d rd.live.overlay.overlayfs && overlayfs="yes"
+getargbool 0 rd.overlay.readonly && readonly_overlay="--readonly" || readonly_overlay=""
+getargbool 0 rd.overlayfs && overlayfs="yes"
 [ -e /xor_overlayfs ] && xor_overlayfs="yes"
 [ -e /xor_readonly ] && xor_readonly="--readonly"
 ROOTFLAGS="$(getarg rootflags)"
index 50e35aa5c25bc787cfcd4d60fd9d03cef0a393d6..a023aaa3b1290dffbe32d9ae8bedb832df58371d 100755 (executable)
@@ -14,6 +14,7 @@ installkernel() {
 }
 
 install() {
+    inst_hook cmdline 70 "$moddir/parse-legacy-overlayfs-options.sh"
     inst_hook pre-mount 01 "$moddir/prepare-overlayfs.sh"
     inst_hook mount 01 "$moddir/mount-overlayfs.sh"       # overlay on top of block device
     inst_hook pre-pivot 00 "$moddir/prepare-overlayfs.sh" # prepare for network root (e.g. nfs)
index 379d03f645d2cbf1a7a7d046f7a52ad5407597c6..136d5a746599a93800eb8e314cae1638b2fb15a1 100755 (executable)
@@ -2,9 +2,9 @@
 
 command -v getarg > /dev/null || . /lib/dracut-lib.sh
 
-getargbool 0 rd.overlayfs -d rd.live.overlay.overlayfs && overlayfs="yes"
-getargbool 0 rd.overlay.readonly -d rd.live.overlayfs.readonly && readonly_overlay="--readonly" || readonly_overlay=""
-overlay=$(getarg rd.overlay -d rd.live.overlay)
+getargbool 0 rd.overlayfs && overlayfs="yes"
+getargbool 0 rd.overlay.readonly && readonly_overlay="--readonly" || readonly_overlay=""
+overlay=$(getarg rd.overlay)
 
 [ -n "$overlayfs" ] || [ -n "$overlay" ] || return 0
 
diff --git a/modules.d/70overlayfs/parse-legacy-overlayfs-options.sh b/modules.d/70overlayfs/parse-legacy-overlayfs-options.sh
new file mode 100755 (executable)
index 0000000..55ec02b
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+command -v getarg > /dev/null || . /lib/dracut-lib.sh
+
+set_new_option() {
+    local old="$1"
+    local new="$2"
+    local value="$3"
+
+    warn "Kernel command line option '$old' is deprecated, use '$new' instead."
+    echo "${new}${value:+=$value}" >> /run/initramfs/cmdline.d/70-overlayfs.conf
+}
+
+map_option() {
+    local old="$1"
+    local new="$2"
+
+    if getarg "$new" > /dev/null; then
+        return 0
+    fi
+
+    value=$(getarg "$old") || return 0
+    set_new_option "$old" "$new" "$value"
+}
+
+map_option rd.live.overlay rd.overlay
+map_option rd.live.overlay.overlayfs rd.overlayfs
+map_option rd.live.overlay.readonly rd.overlay.readonly
+map_option rd.live.overlay.reset rd.overlay.reset
index c9439ea00bddcac533ab87274e8da11656fd697d..522c3250975f03a1a599a1e948c37ee073375f8e 100755 (executable)
@@ -2,9 +2,9 @@
 
 command -v getarg > /dev/null || . /lib/dracut-lib.sh
 
-getargbool 0 rd.overlayfs -d rd.live.overlay.overlayfs && overlayfs="yes"
-getargbool 0 rd.overlay.reset -d rd.live.overlay.reset && reset_overlay="yes"
-overlay=$(getarg rd.overlay -d rd.live.overlay)
+getargbool 0 rd.overlayfs && overlayfs="yes"
+getargbool 0 rd.overlay.reset && reset_overlay="yes"
+overlay=$(getarg rd.overlay)
 
 [ -n "$overlayfs" ] || [ -n "$overlay" ] || return 0