summaryrefslogtreecommitdiffstats
path: root/modules.d
diff options
context:
space:
mode:
authorSimon Rettberg2025-04-17 16:29:12 +0200
committerSimon Rettberg2025-04-17 16:29:12 +0200
commit1de61eb72d3957ea6a035b7206d2700e214fba5b (patch)
treec1edabf9dd3ff56019efdb87476ef872c56611bb /modules.d
parent[slx-ntfsfree] Add missing "\" (diff)
downloadsystemd-init-1de61eb72d3957ea6a035b7206d2700e214fba5b.tar.gz
systemd-init-1de61eb72d3957ea6a035b7206d2700e214fba5b.tar.xz
systemd-init-1de61eb72d3957ea6a035b7206d2700e214fba5b.zip
[slx-drm] Build separate initrd for nvidia drivers
As those make up for biggest chunk regarding the size of our initrd, split them out into a separate initrd that can be loaded on demand. Our bwLehrpool main initrd is now 92MB, the nvidia addon is 145MB. The same idea might be viable for amdgpu, which is also relatively large considering its kmod + firmware.
Diffstat (limited to 'modules.d')
-rwxr-xr-xmodules.d/slx-drm/hooks/s3-activate-nvidia-drivers.sh3
-rwxr-xr-xmodules.d/slx-drm/module-setup.sh34
2 files changed, 33 insertions, 4 deletions
diff --git a/modules.d/slx-drm/hooks/s3-activate-nvidia-drivers.sh b/modules.d/slx-drm/hooks/s3-activate-nvidia-drivers.sh
index c33a4913..77efa097 100755
--- a/modules.d/slx-drm/hooks/s3-activate-nvidia-drivers.sh
+++ b/modules.d/slx-drm/hooks/s3-activate-nvidia-drivers.sh
@@ -6,6 +6,9 @@ if ! [ -d "/drm.cfg.d" ] && [ -n "$cards" ]; then
echo "Failed to find '/drm.cfg.d', but have nvidia cards - will try nouveau."
exit 1
fi
+
+[ -d "/drm.cfg.d" ] || exit 0
+
for card in $cards; do
driver="$(awk '$1 = /'"$card"'/ {print $2; exit}' /drm.cfg.d/*)"
[ -z "$driver" ] && continue
diff --git a/modules.d/slx-drm/module-setup.sh b/modules.d/slx-drm/module-setup.sh
index 336062d3..a7169044 100755
--- a/modules.d/slx-drm/module-setup.sh
+++ b/modules.d/slx-drm/module-setup.sh
@@ -11,12 +11,38 @@ installkernel() {
instmods acpi_ipmi
}
install() {
+ local fw try trydir
+ local tmpd=$( mktemp -d )
+ declare -a fwlist
+ [ -d "$tmpd" ] || derror "mktemp -d didn't work"
+ [ -d "$tmpd" ] || derror "Not a tempdir: '$tmpd'"
+ [ -z "$outdir" ] && derror "outdir not set"
# grab what mltk produced, to externalize this part!
- for dir in "/drm.cfg.d" "/lib/modules/nvidia"; do
- [ -d "$dir" ] || continue
- mkdir -p "${initdir}/${dir%/*}"
- cp -ar "$dir" "${initdir}/${dir%/*}"
+ # find the required firmware
+ dinfo "Searching for nvidia firmware in ${fw_dir}"
+ for fw in $( find /lib/modules/nvidia/ -name "*.ko*" -type f -exec modinfo {} \; \
+ | grep ^firmware: | awk '{print $2}' ); do
+ for trydir in ${fw_dir}; do
+ try="$trydir/$fw"
+ [ -f "$try" ] || continue
+ fwlist+=( "./lib/firmware/$fw" )
+ mkdir -p "$tmpd/lib/firmware/$( dirname "$fw" )"
+ cp -a "$try" "$tmpd/lib/firmware/$fw" || derror "Cannot cp '$try' to '$tmpd/lib/firmware/$fw'"
+ continue 2
+ done
+ dwarn "***** MISSING NVIDIA FIRMWARE *****"
+ dwarn "* $fw"
+ dwarn "***********************************"
done
+ # Put everything into cpio
+ cd "$tmpd" || derror "Cannot cd to '$tmpd'"
+ find "/drm.cfg.d" "/lib/modules/nvidia" "${fwlist[@]}" -print0 \
+ | sort -z | cpio --null -R 0:0 -H newc -o --quiet \
+ | ${compress:-cat} > "$outdir/addon-nvidia_pci-v10de-dxxxx" \
+ || derror "Cannot create nvidia cpio"
+ # cleanup
+ cd - || derror "Cannot cd back"
+ rm -rf -- "$tmpd"
# Prepare /lib/modules and depmod for nvidia if applicable
slx_service "s3-activate-nvidia-drivers" "Enable loading of nVidia drivers if a suitable GPU is found" \
--wafter "dracut-cmdline.service" \