]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
chore(dracut): switch to /usr/lib from /lib for hooks
authorVitaly Kuznetsov <vkuznets@redhat.com>
Thu, 5 Feb 2026 08:11:48 +0000 (09:11 +0100)
committerBenjamin Drung <bdrung@ubuntu.com>
Thu, 5 Feb 2026 17:21:35 +0000 (18:21 +0100)
The current tendency is to move towards "hermetic /usr" and not
introduce new things outside of it. For distro shipped hooks and
for the testsuite move the location from /lib to /usr/lib.

No (real) functional change intended.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
20 files changed:
doc_site/modules/ROOT/pages/developer/modules.adoc
man/dracut.modules.7.adoc
modules.d/77dracut-systemd/dracut-cmdline.service
modules.d/77dracut-systemd/dracut-mount.service
modules.d/77dracut-systemd/dracut-pre-mount.service
modules.d/77dracut-systemd/dracut-pre-pivot.service
modules.d/77dracut-systemd/dracut-pre-trigger.service
modules.d/77dracut-systemd/dracut-pre-udev.service
modules.d/80base/dracut-lib.sh
test/TEST-11-USR-MOUNT/test.sh
test/TEST-14-HOOKS/test.sh
test/TEST-20-STORAGE/test.sh
test/TEST-26-ENC-RAID-LVM/test.sh
test/TEST-40-SYSTEMD/test.sh
test/TEST-41-FULL-SYSTEMD/test.sh
test/TEST-60-NFS/test.sh
test/TEST-70-ISCSI/test.sh
test/TEST-71-ISCSI-MULTI/test.sh
test/TEST-72-NBD/test.sh
test/TEST-82-DRACUT-CPIO/test.sh

index f5637c3361a6f705790505746a4a619506ea5688..875e7a887b8d2029884489e562ae305e55e04582 100644 (file)
@@ -125,8 +125,8 @@ You are encouraged to provide a `README` that describes what the module is for.
 
 Dracut init looks for custom hook scripts in the following locations
 (`HOOKDIR` below): `/var/lib/dracut/hooks`, `/etc/dracut/hooks`, and
-`/lib/dracut/hooks`. The intended use of these locations is: standard,
-distribution shipped scripts are put to `/lib/dracut/hooks`;
+`/usr/lib/dracut/hooks`. The intended use of these locations is: standard,
+distribution shipped scripts are put to `/usr/lib/dracut/hooks`;
 `/etc/dracut/hooks` is used as a local override; dracut modules create
 (and remove) scripts in runtime in `/var/lib/dracut/hooks` (and `$hookdir`
 variable is provided). The following hook points to inject scripts are
index af5fc03934191d4c74f70234b3ae8b4ae838fae2..fc31af6b9b3fb93ea3062fe71b7764e6cf2c45d2 100644 (file)
@@ -50,13 +50,13 @@ Common used functions are in _dracut-lib.sh_, which can be sourced by any script
 dracut looks for custom hook scripts in subdirectories (cmdline, pre-udev,
 pre-trigger, initqueue, pre-mount, mount, pre-pivot, cleanup) of the following
 locations:  _/var/lib/dracut/hooks_, _/etc/dracut/hooks_, and
-_/lib/dracut/hooks_. The intended use of these locations is: standard,
-distribution shipped scripts are put to _/lib/dracut/hooks_; _/etc/dracut/hooks_
-is used as a local override; dracut modules create (and remove) scripts in
-runtime in _/var/lib/dracut/hooks_. If a hook with the same name exists in
-multiple locations simultaneously, the most privileged location
+_/usr/lib/dracut/hooks_. The intended use of these locations is: standard,
+distribution shipped scripts are put to _/usr/lib/dracut/hooks_;
+_/etc/dracut/hooks_ is used as a local override; dracut modules create (and
+remove) scripts in runtime in _/var/lib/dracut/hooks_. If a hook with the same
+name exists in multiple locations simultaneously, the most privileged location
 (_/var/lib/dracut/hooks_, then _/etc/dracut/hooks_, and then
-_/lib/dracut/hooks_) wins and only one instance of the hook is executed.
+_/usr/lib/dracut/hooks_) wins and only one instance of the hook is executed.
 
 === Hook: cmdline
 
index d991619e8f55f8019d90dda7678f7dddd572aa34..2bf95a1267ce402590a5d089a4375184febb635a 100644 (file)
@@ -11,7 +11,7 @@ ConditionPathExists=/usr/lib/initrd-release
 ConditionPathExistsGlob=|/etc/cmdline.d/*.conf
 ConditionDirectoryNotEmpty=|/var/lib/dracut/hooks/cmdline
 ConditionDirectoryNotEmpty=|/etc/dracut/hooks/cmdline
-ConditionDirectoryNotEmpty=|/lib/dracut/hooks/cmdline
+ConditionDirectoryNotEmpty=|/usr/lib/dracut/hooks/cmdline
 ConditionKernelCommandLine=|rd.break=cmdline
 Conflicts=shutdown.target emergency.target
 
index dd5e2cb212814f3512309ed7ac59b41e973c46b7..6809e104780267f99a51d22cabe082f29e0b3cfd 100644 (file)
@@ -8,7 +8,7 @@ After=dracut-initqueue.service dracut-pre-mount.service
 ConditionPathExists=/usr/lib/initrd-release
 ConditionDirectoryNotEmpty=|/var/lib/dracut/hooks/mount
 ConditionDirectoryNotEmpty=|/etc/dracut/hooks/mount
-ConditionDirectoryNotEmpty=|/lib/dracut/hooks/mount
+ConditionDirectoryNotEmpty=|/usr/lib/dracut/hooks/mount
 ConditionKernelCommandLine=|rd.break=mount
 DefaultDependencies=no
 Conflicts=shutdown.target emergency.target
index 3c76ff5e68f9728708f450c53fe8efbbacb4def4..db74194a500f99d18f5b0d4436861d5fd80c44f7 100644 (file)
@@ -9,7 +9,7 @@ After=dracut-initqueue.service cryptsetup.target
 ConditionPathExists=/usr/lib/initrd-release
 ConditionDirectoryNotEmpty=|/var/lib/dracut/hooks/pre-mount
 ConditionDirectoryNotEmpty=|/etc/dracut/hooks/pre-mount
-ConditionDirectoryNotEmpty=|/lib/dracut/hooks/pre-mount
+ConditionDirectoryNotEmpty=|/usr/lib/dracut/hooks/pre-mount
 ConditionKernelCommandLine=|rd.break=pre-mount
 Conflicts=shutdown.target emergency.target
 
index 8194ee254e140da4095b1623359ca851786d5261..e77da2480d59a62b14459a961fdcdc66dda24205 100644 (file)
@@ -12,10 +12,10 @@ After=remote-fs.target
 ConditionPathExists=/usr/lib/initrd-release
 ConditionDirectoryNotEmpty=|/var/lib/dracut/hooks/pre-pivot
 ConditionDirectoryNotEmpty=|/etc/dracut/hooks/pre-pivot
-ConditionDirectoryNotEmpty=|/lib/dracut/hooks/pre-pivot
+ConditionDirectoryNotEmpty=|/usr/lib/dracut/hooks/pre-pivot
 ConditionDirectoryNotEmpty=|/var/lib/dracut/hooks/cleanup
 ConditionDirectoryNotEmpty=|/etc/dracut/hooks/cleanup
-ConditionDirectoryNotEmpty=|/lib/dracut/hooks/cleanup
+ConditionDirectoryNotEmpty=|/usr/lib/dracut/hooks/cleanup
 ConditionKernelCommandLine=|rd.break=pre-pivot
 ConditionKernelCommandLine=|rd.break=cleanup
 ConditionKernelCommandLine=|rd.break
index b99837b31f838029f5f84a5cf199ee28d4bd5210..25f020b2bce3ba049f16f2ff534e26d3aa7b5d48 100644 (file)
@@ -10,7 +10,7 @@ Wants=dracut-pre-udev.service systemd-udevd.service
 ConditionPathExists=/usr/lib/initrd-release
 ConditionDirectoryNotEmpty=|/var/lib/dracut/hooks/pre-trigger
 ConditionDirectoryNotEmpty=|/etc/dracut/hooks/pre-trigger
-ConditionDirectoryNotEmpty=|/lib/dracut/hooks/pre-trigger
+ConditionDirectoryNotEmpty=|/usr/lib/dracut/hooks/pre-trigger
 ConditionKernelCommandLine=|rd.break=pre-trigger
 Conflicts=shutdown.target emergency.target
 
index 8a803697ca3738a299fd7205fb8931e2b07b7b3a..a4b781c1fe6ae318cf3342a51683b844dabb48c1 100644 (file)
@@ -10,7 +10,7 @@ Wants=dracut-cmdline.service
 ConditionPathExists=/usr/lib/initrd-release
 ConditionDirectoryNotEmpty=|/var/lib/dracut/hooks/pre-udev
 ConditionDirectoryNotEmpty=|/etc/dracut/hooks/pre-udev
-ConditionDirectoryNotEmpty=|/lib/dracut/hooks/pre-udev
+ConditionDirectoryNotEmpty=|/usr/lib/dracut/hooks/pre-udev
 ConditionKernelCommandLine=|rd.break=pre-udev
 ConditionKernelCommandLine=|rd.driver.blacklist
 ConditionKernelCommandLine=|rd.driver.pre
index 2710347bf82f184163f57918a002ed10d2e74926..21322d7b3212a7c545b6dc6b72c6034f66eeb352 100755 (executable)
@@ -375,7 +375,7 @@ list_hooks() {
 
     # It is allowed to override hooks by creating a file with the same name
     # in a directory which has higher priority. '/var/lib/dracut/hooks' gets top
-    # priority, '/etc/dracut/hooks' comes after and '/lib/dracut/hooks' is the
+    # priority, '/etc/dracut/hooks' comes after and '/usr/lib/dracut/hooks' is the
     # least priviliged location.
     for hook in "/var/lib/dracut/hooks/$dir/"$pattern; do
         [ -f "$hook" ] && echo "$hook"
@@ -383,7 +383,7 @@ list_hooks() {
     for hook in "/etc/dracut/hooks/$dir/"$pattern; do
         [ -f "$hook" ] && [ ! -f "/var/lib/dracut/hooks/$dir/${hook##*/}" ] && echo "$hook"
     done
-    for hook in "/lib/dracut/hooks/$dir/"$pattern; do
+    for hook in "/usr/lib/dracut/hooks/$dir/"$pattern; do
         [ -f "$hook" ] && [ ! -f "/var/lib/dracut/hooks/$dir/${hook##*/}" ] \
             && [ ! -f "/etc/dracut/hooks/$dir/${hook##*/}" ] && echo "$hook"
     done
index 778f7b59531fa6ce8535a7aeee65d064b37ab0c3..0a232fcfba10678bfb8f7b9510501e3a2947c03d 100755 (executable)
@@ -53,7 +53,7 @@ test_setup() {
     call_dracut -i "$TESTDIR"/overlay / \
         --add-confdir test-makeroot \
         -I "mkfs.btrfs" \
-        -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \
+        -i ./create-root.sh /usr/lib/dracut/hooks/initqueue/01-create-root.sh \
         -f "$TESTDIR"/initramfs.makeroot
 
     # Create the blank file to use as a root filesystem
index 677b82e04fbca83c3e89580693801ada0fc9fbf5..baf25adef46ddfab4024503af7c254ec4713ef1a 100755 (executable)
@@ -33,32 +33,32 @@ test_setup() {
         # Create hooks with different names. All of them must execute.
         add_hook "/var/lib/dracut/hooks/$hookdir/testhook-difname-var.sh"
         add_hook "/etc/dracut/hooks/$hookdir/testhook-difname-etc.sh"
-        add_hook "/lib/dracut/hooks/$hookdir/testhook-difname-lib.sh"
+        add_hook "/usr/lib/dracut/hooks/$hookdir/testhook-difname-lib.sh"
         expected_hooks_run+=(
             "/var/lib/dracut/hooks/$hookdir/testhook-difname-var.sh"
             "/etc/dracut/hooks/$hookdir/testhook-difname-etc.sh"
-            "/lib/dracut/hooks/$hookdir/testhook-difname-lib.sh"
+            "/usr/lib/dracut/hooks/$hookdir/testhook-difname-lib.sh"
         )
 
         # Create hooks with the same name. Only the highest priority ones must execute.
         add_hook "/var/lib/dracut/hooks/$hookdir/testhook-samename3.sh"
         add_hook "/etc/dracut/hooks/$hookdir/testhook-samename3.sh"
-        add_hook "/lib/dracut/hooks/$hookdir/testhook-samename3.sh"
+        add_hook "/usr/lib/dracut/hooks/$hookdir/testhook-samename3.sh"
         expected_hooks_run+=(
             "/var/lib/dracut/hooks/$hookdir/testhook-samename3.sh"
         )
         expected_hooks_not_run+=(
             "/etc/dracut/hooks/$hookdir/testhook-samename3.sh"
-            "/lib/dracut/hooks/$hookdir/testhook-samename3.sh"
+            "/usr/lib/dracut/hooks/$hookdir/testhook-samename3.sh"
         )
 
         add_hook "/etc/dracut/hooks/$hookdir/testhook-samename2.sh"
-        add_hook "/lib/dracut/hooks/$hookdir/testhook-samename2.sh"
+        add_hook "/usr/lib/dracut/hooks/$hookdir/testhook-samename2.sh"
         expected_hooks_run+=(
             "/etc/dracut/hooks/$hookdir/testhook-samename2.sh"
         )
         expected_hooks_not_run+=(
-            "/lib/dracut/hooks/$hookdir/testhook-samename2.sh"
+            "/usr/lib/dracut/hooks/$hookdir/testhook-samename2.sh"
         )
     done
 
index 942f38b266df4750378464a10b06d3cfc55c38cb..551cfc329c6dcb1f3e6a919a43e63bcd89a61a0f 100755 (executable)
@@ -127,7 +127,7 @@ test_setup() {
         $(if command -v mdadm > /dev/null; then echo "-a mdraid"; fi) \
         $(if command -v cryptsetup > /dev/null; then echo "-a crypt -I cryptsetup"; fi) \
         $(if [ "$TEST_FSTYPE" = "zfs" ]; then echo "-a zfs"; else echo "-I mkfs.${TEST_FSTYPE} --add-drivers ${TEST_FSTYPE}"; fi) \
-        -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \
+        -i ./create-root.sh /usr/lib/dracut/hooks/initqueue/01-create-root.sh \
         -f "$TESTDIR"/initramfs.makeroot
 
     # LVM
index d5c79524c890b372518c6466088938abf1965ca6..657be912bd81f489b5931a76d4484931e58d0723 100755 (executable)
@@ -58,7 +58,7 @@ test_setup() {
         --add-confdir test-makeroot \
         -a "bash crypt lvm mdraid" \
         -I "grep cryptsetup" \
-        -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \
+        -i ./create-root.sh /usr/lib/dracut/hooks/initqueue/01-create-root.sh \
         -f "$TESTDIR"/initramfs.makeroot
 
     # Create the blank files to use as a root filesystem
index 3430304db0549df5f3cafccff885afb8f1438457..053ac8bdcdd38378a843d3617af62a9fcd5aa823 100755 (executable)
@@ -34,7 +34,7 @@ test_setup() {
         --omit "fido2 initqueue" \
         --omit-drivers 'a b c d e f g h i j k l m n o p q r s t u v w x y z' \
         -I systemd-analyze \
-        -i ./systemd-analyze.sh /lib/dracut/hooks/pre-pivot/00-systemd-analyze.sh \
+        -i ./systemd-analyze.sh /usr/lib/dracut/hooks/pre-pivot/00-systemd-analyze.sh \
         -i "/bin/true" "/usr/bin/man"
 
     # shellcheck disable=SC2144 # We're not installing multilib libfido2, so
index a19ad9a3a429feb289e5760a147585d862c7973e..f5751e0b9479814d4b843f5bf3bde199bba2304d 100755 (executable)
@@ -86,7 +86,7 @@ test_setup() {
         --add-confdir test-makeroot \
         -a "btrfs crypt" \
         -I "mkfs.btrfs cryptsetup" \
-        -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \
+        -i ./create-root.sh /usr/lib/dracut/hooks/initqueue/01-create-root.sh \
         -f "$TESTDIR"/initramfs.makeroot
 
     KVERSION=$(determine_kernel_version "$TESTDIR"/initramfs.makeroot)
index 0638fdcc4d0adab98b16d0501ec375b8afedc356..ec1f00d3a10afb1764041295b3363303e31deeef 100755 (executable)
@@ -266,7 +266,7 @@ test_setup() {
     call_dracut \
         -a "bash qemu-net $USE_NETWORK ${SERVER_DEBUG:+debug}" \
         --include ./server.link /etc/systemd/network/01-server.link \
-        --include ./wait-if-server.sh /lib/dracut/hooks/pre-mount/99-wait-if-server.sh \
+        --include ./wait-if-server.sh /usr/lib/dracut/hooks/pre-mount/99-wait-if-server.sh \
         -N \
         -f "$TESTDIR"/initramfs.server
 }
index 6b7528ea9b891ea1ed3cc078b17608a10e6285a5..43cb16e1e7cb76289b7c0bf253a68932d903d391 100755 (executable)
@@ -137,7 +137,7 @@ test_setup() {
         --add-confdir test-makeroot \
         -a "crypt lvm mdraid" \
         -I "setsid blockdev" \
-        -i ./create-client-root.sh /lib/dracut/hooks/initqueue/01-create-client-root.sh \
+        -i ./create-client-root.sh /usr/lib/dracut/hooks/initqueue/01-create-client-root.sh \
         -f "$TESTDIR"/initramfs.makeroot
     rm -rf -- "$TESTDIR"/overlay
 
@@ -177,7 +177,7 @@ test_setup() {
         -a "qemu-net $USE_NETWORK" \
         --add-confdir test \
         -i "./server.link" "/etc/systemd/network/01-server.link" \
-        -i ./wait-if-server.sh /lib/dracut/hooks/pre-mount/99-wait-if-server.sh \
+        -i ./wait-if-server.sh /usr/lib/dracut/hooks/pre-mount/99-wait-if-server.sh \
         -N \
         -f "$TESTDIR"/initramfs.server
 
index 197fc307af4b6785ec1262cc9c2f08a87de72d4a..e04b3a557d6f74840b6aff2e03fdfdc35a470b67 100755 (executable)
@@ -146,7 +146,7 @@ test_setup() {
         --add-confdir test-makeroot \
         -a "crypt lvm mdraid" \
         -I "setsid blockdev" \
-        -i ./create-client-root.sh /lib/dracut/hooks/initqueue/01-create-client-root.sh \
+        -i ./create-client-root.sh /usr/lib/dracut/hooks/initqueue/01-create-client-root.sh \
         -f "$TESTDIR"/initramfs.makeroot
     rm -rf -- "$TESTDIR"/overlay
 
@@ -195,7 +195,7 @@ test_setup() {
         --add-confdir test \
         -a "qemu-net $USE_NETWORK ${SERVER_DEBUG:+debug}" \
         -i "./server.link" "/etc/systemd/network/01-server.link" \
-        -i "./wait-if-server.sh" "/lib/dracut/hooks/pre-mount/99-wait-if-server.sh" \
+        -i "./wait-if-server.sh" "/usr/lib/dracut/hooks/pre-mount/99-wait-if-server.sh" \
         -N \
         -f "$TESTDIR"/initramfs.server
 }
index c9b9c759b2f5ab7332b24e0bbc61e7eebdb014e1..d1ddff395bcd6dbb3ecbe19d0132537c995cbb52 100755 (executable)
@@ -185,7 +185,7 @@ make_encrypted_root() {
         --add-confdir test-makeroot \
         -a "crypt lvm mdraid" \
         -I "cryptsetup" \
-        -i ./create-encrypted-root.sh /lib/dracut/hooks/initqueue/01-create-encrypted-root.sh \
+        -i ./create-encrypted-root.sh /usr/lib/dracut/hooks/initqueue/01-create-encrypted-root.sh \
         -f "$TESTDIR"/initramfs.makeroot
     rm -rf -- "$TESTDIR"/overlay
 
@@ -272,7 +272,7 @@ test_setup() {
         --add-confdir test \
         -a "qemu-net $USE_NETWORK ${SERVER_DEBUG:+debug}" \
         -i "./server.link" "/etc/systemd/network/01-server.link" \
-        -i "./wait-if-server.sh" "/lib/dracut/hooks/pre-mount/99-wait-if-server.sh" \
+        -i "./wait-if-server.sh" "/usr/lib/dracut/hooks/pre-mount/99-wait-if-server.sh" \
         -f "$TESTDIR"/initramfs.server
 }
 
index b303841922367930929f5fd6ad44603904a681fe..25e900587bceabad0d6e61344f24d18d4696ccda 100755 (executable)
@@ -31,7 +31,7 @@ EOF
         --no-kernel --drivers "" \
         --add-confdir "test" \
         "${dracut_cpio_params[@]}" \
-        --include "$tdir/init.sh" /lib/dracut/hooks/emergency/00-init.sh \
+        --include "$tdir/init.sh" /usr/lib/dracut/hooks/emergency/00-init.sh \
         --install "poweroff" \
         "$tdir/initramfs"