Skip to contentSkip to conversation

Support dropin files for Linux kernel parameters

PATCH In review Simon Rowe 3 participants 6 messages Mar 1, 2024 – May 2, 2024

lore
Share & tools
lore

Simon Rowe

author
#0 lore raw

PATCH 1/1 Support dropin files for Linux kernel parameters

Kernel parameters actually cover a range of purposes, including userspace like systemd. They also need setting for a variety of reasons:

* as distro defaults
* to provide configuration for a package
* for an admin to set desired behaviour

Having these all combined in a single line (like GRUB_CMDLINE_LINUX) is unwieldy, it is hard to make changes without impacting another usecase.

Add optional support for dropin files in the directories:

* /usr/lib/kernel.d/
* /etc/kernel.d/

where the contents of each file with the '.conf' suffix is evaluated (excluding comments) and appended to any other kernel parameters defined via GRUB_CMDLINE_LINUX etc. Files in /etc/kernel.d/ completely replace those of the same name in /usr/lib/kernel.d/. This allows a distro or installer to set parameters but then for an admin to override them.

---
 util/grub-mkconfig_lib.in   | 18 ++++++++++++++++++
 util/grub.d/10_linux.in     |  8 +++++---
 util/grub.d/20_linux_xen.in |  8 +++++---
 3 files changed, 28 insertions(+), 6 deletions(-)
util/grub-mkconfig_lib.in +18 -0
index 08953287c..7aaa747f1 100644
@@ -348,3 +348,21 @@ grub_add_tab () {
   sed -e "s/^/$grub_tab/"
 }
 
+kernel_params_from_files () {
+  # Read Linux kernel parameters from dropin files.
+
+  file_bases=""
+
+  for f in /etc/kernel.d/*.conf /usr/lib/kernel.d/*.conf; do
+    [ -r $f ] || continue
+    file_bases="$file_bases $(basename $f)"
+  done
+
+  for b in $(echo $file_bases | tr ' ' '\n' | sort -u); do
+    if [ -r /etc/kernel.d/$b ]; then
+      grep -v '^#' /etc/kernel.d/$b | tr '\n' ' '
+    elif [ -r /usr/lib/kernel.d/$b ]; then
+      grep -v '^#' /usr/lib/kernel.d/$b | tr '\n' ' '
+    fi
+  done
+}
util/grub.d/10_linux.in +5 -3
index cc393be7e..fba3775f9 100644
@@ -275,6 +275,8 @@ for linux in ${reverse_sorted_list}; do
     fi
   fi
 
+  extra_kernel_params=$(kernel_params_from_files)
+
   # The GRUB_DISABLE_SUBMENU option used to be different than others since it was
   # mentioned in the documentation that has to be set to 'y' instead of 'true' to
   # enable it. This caused a lot of confusion to users that set the option to 'y',
@@ -285,7 +287,7 @@ for linux in ${reverse_sorted_list}; do
 
   if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
     linux_entry "${OS}" "${version}" simple \
-    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${extra_kernel_params}"
 
     submenu_indentation="$grub_tab"
     
@@ -298,10 +300,10 @@ for linux in ${reverse_sorted_list}; do
   fi
 
   linux_entry "${OS}" "${version}" advanced \
-              "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+              "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${extra_kernel_params}"
   if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
     linux_entry "${OS}" "${version}" recovery \
-                "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}"
+                "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX} ${extra_kernel_params}"
   fi
 done
 
util/grub.d/20_linux_xen.in +5 -3
index 94dd8be13..089f6de43 100644
@@ -336,6 +336,8 @@ for current_xen in ${reverse_sorted_xen_list}; do
 	    fi
 	fi
 
+	extra_kernel_params=$(kernel_params_from_files)
+
 	# The GRUB_DISABLE_SUBMENU option used to be different than others since it was
 	# mentioned in the documentation that has to be set to 'y' instead of 'true' to
 	# enable it. This caused a lot of confusion to users that set the option to 'y',
@@ -346,7 +348,7 @@ for current_xen in ${reverse_sorted_xen_list}; do
 
 	if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
 	    linux_entry "${OS}" "${version}" "${xen_version}" simple \
-		"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
+		"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT} ${extra_kernel_params}"
 
 	    submenu_indentation="$grub_tab$grub_tab"
     
@@ -360,10 +362,10 @@ for current_xen in ${reverse_sorted_xen_list}; do
 	fi
 
 	linux_entry "${OS}" "${version}" "${xen_version}" advanced \
-	    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
+	    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT} ${extra_kernel_params}"
 	if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
 	    linux_entry "${OS}" "${version}" "${xen_version}" recovery \
-		"${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}"
+		"${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN} ${extra_kernel_params}"
 	fi
     done
     if [ x"$is_top_level" != xtrue ]; then
Signature · 7 lines
2.22.3


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#1 lore raw
Quoted 17 lines · Simon Rowe

Kernel parameters actually cover a range of purposes, including userspace like systemd. They also need setting for a variety of reasons:

* as distro defaults
* to provide configuration for a package
* for an admin to set desired behaviour

Having these all combined in a single line (like GRUB_CMDLINE_LINUX) is unwieldy, it is hard to make changes without impacting another usecase.

Add optional support for dropin files in the directories:

* /usr/lib/kernel.d/
* /etc/kernel.d/

Quoted 7 lines

where the contents of each file with the '.conf' suffix is evaluated (excluding comments) and appended to any other kernel parameters defined via GRUB_CMDLINE_LINUX etc. Files in /etc/kernel.d/ completely replace those of the same name in /usr/lib/kernel.d/. This allows a distro or installer to set parameters but then for an admin to override them.

Would it be better to have the kernel command line args in GRUB config override the ones in any drop-ins? At least for me it would be surprising behavior if my distro set something in /usr/lib/kernel.d/ and changing that value in my GRUB config didn't have an effect.

Quoted 47 lines
---
 util/grub-mkconfig_lib.in   | 18 ++++++++++++++++++
 util/grub.d/10_linux.in     |  8 +++++---
 util/grub.d/20_linux_xen.in |  8 +++++---
 3 files changed, 28 insertions(+), 6 deletions(-)
util/grub-mkconfig_lib.in +18 -0
index 08953287c..7aaa747f1 100644
@@ -348,3 +348,21 @@ grub_add_tab () {
   sed -e "s/^/$grub_tab/"
 }
 
+kernel_params_from_files () {
+  # Read Linux kernel parameters from dropin files.
+
+  file_bases=""
+
+  for f in /etc/kernel.d/*.conf /usr/lib/kernel.d/*.conf; do
+    [ -r $f ] || continue
+    file_bases="$file_bases $(basename $f)"
+  done
+
+  for b in $(echo $file_bases | tr ' ' '\n' | sort -u); do
+    if [ -r /etc/kernel.d/$b ]; then
+      grep -v '^#' /etc/kernel.d/$b | tr '\n' ' '
+    elif [ -r /usr/lib/kernel.d/$b ]; then
+      grep -v '^#' /usr/lib/kernel.d/$b | tr '\n' ' '
+    fi
+  done
+}
util/grub.d/10_linux.in +2 -0
index cc393be7e..fba3775f9 100644
@@ -275,6 +275,8 @@ for linux in ${reverse_sorted_list}; do
     fi
   fi
 
+  extra_kernel_params=$(kernel_params_from_files)
+
   # The GRUB_DISABLE_SUBMENU option used to be different than others since it was
   # mentioned in the documentation that has to be set to 'y' instead of 'true' to
   # enable it. This caused a lot of confusion to users that set the option to 'y',

util/grub.d/10_linux.in for linux in ${reverse_sorted_list}; do · line 291

Quoted 6 lines
util/grub.d/10_linux.in +1 -1
@@ -285,7 +287,7 @@ for linux in ${reverse_sorted_list}; do
 
   if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
     linux_entry "${OS}" "${version}" simple \
-    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${extra_kernel_params}"
 

In other words, should this instead be:

    "${extra_kernel_params} ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"

Similarly for the other instances below.

- Oskari

Quoted 58 lines
util/grub.d/10_linux.in +2 -2
     submenu_indentation="$grub_tab"
 
@@ -298,10 +300,10 @@ for linux in ${reverse_sorted_list}; do
   fi
 
   linux_entry "${OS}" "${version}" advanced \
-              "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+              "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${extra_kernel_params}"
   if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
     linux_entry "${OS}" "${version}" recovery \
-                "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}"
+                "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX} ${extra_kernel_params}"
   fi
 done
 
util/grub.d/20_linux_xen.in +5 -3
index 94dd8be13..089f6de43 100644
@@ -336,6 +336,8 @@ for current_xen in ${reverse_sorted_xen_list}; do
 	    fi
 	fi
 
+	extra_kernel_params=$(kernel_params_from_files)
+
 	# The GRUB_DISABLE_SUBMENU option used to be different than others since it was
 	# mentioned in the documentation that has to be set to 'y' instead of 'true' to
 	# enable it. This caused a lot of confusion to users that set the option to 'y',
@@ -346,7 +348,7 @@ for current_xen in ${reverse_sorted_xen_list}; do
 
 	if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
 	    linux_entry "${OS}" "${version}" "${xen_version}" simple \
-		"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
+		"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT} ${extra_kernel_params}"
 
 	    submenu_indentation="$grub_tab$grub_tab"
 
@@ -360,10 +362,10 @@ for current_xen in ${reverse_sorted_xen_list}; do
 	fi
 
 	linux_entry "${OS}" "${version}" "${xen_version}" advanced \
-	    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
+	    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT} ${extra_kernel_params}"
 	if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
 	    linux_entry "${OS}" "${version}" "${xen_version}" recovery \
-		"${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}"
+		"${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN} ${extra_kernel_params}"
 	fi
     done
     if [ x"$is_top_level" != xtrue ]; then
Signature · 7 lines
2.22.3


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

author
#2 lore raw
Quoted 3 lines · Oskari Pirhonen

Would it be better to have the kernel command line args in GRUB config override the ones in any drop-ins? At least for me it would be surprising behavior if my distro set something in /usr/lib/kernel.d/ and changing that value in my GRUB config didn't have an effect.

That then makes it impossible for an admin to override any parameter present in GRUB_CMDLINE_LINUX as that takes priority over files in either /etc/kernel.d/ or /usr/lib/kernel.d/

In my hubris I imagine that distros would move all static or install-time config to /usr/lib/kernel.d/ and GRUB_CMDLINE_LINUX would be left just for backward compatibility.

If a distro carries this change then the docs telling users how to set their own parameters would need updating to mention /etc/kernel.d/ instead of GRUB_CMDLINE_LINUX.

I can switch the order if that's the preferred behaviour, but I feel it diminishes the usefulness of the feature.

Regards
Simon

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw
Quoted 6 lines · Simon Rowe
Quoted 3 lines · Oskari Pirhonen

Would it be better to have the kernel command line args in GRUB config override the ones in any drop-ins? At least for me it would be surprising behavior if my distro set something in /usr/lib/kernel.d/ and changing that value in my GRUB config didn't have an effect.

Quoted 8 lines

That then makes it impossible for an admin to override any parameter present in GRUB_CMDLINE_LINUX as that takes priority over files in either /etc/kernel.d/ or /usr/lib/kernel.d/

In my hubris I imagine that distros would move all static or install-time config to /usr/lib/kernel.d/ and GRUB_CMDLINE_LINUX would be left just for backward compatibility.

I imagine such a distro would ship their GRUB config with nothing set in GRUB_CMDLINE_LINUX and only use /usr/lib/kernel.d/ for that. Then the admin doesn't have to worry about overriding things in GRUB directly and can use /etc/kernel.d/ instead.

If the distro makes use of GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX_RECOVERY to create different command lines, the admin may still have to edit those by hand if they want custom options specific to normal and "recovery" entries. After all, this behavior isn't replicated by just slurping the files from {/usr/lib,/etc}/kernel.d/ and tacking them on to the end.

Quoted 7 lines

If a distro carries this change then the docs telling users how to set their own parameters would need updating to mention /etc/kernel.d/ instead of GRUB_CMDLINE_LINUX.

I can switch the order if that's the preferred behaviour, but I feel it diminishes the usefulness of the feature.

The main points that I currently disagree with are:

1. GRUB_CMDLINE_LINUX [should] be left just for backward compatibility
2. [switching the order] diminishes the usefulness of the feature

I believe they can both coexist if a distro documents their preferred/supported way of setting the kernel command line (if they have one). This can even be added as a comment in the installed /etc/default/grub so that anyone going to edit the file will run across it and (hopefully) adapt accordingly.

Diverging from the distro's policy is always at the discretion of the system administrator, and I believe that the friendliest option for GRUB is to maintain existing behavior as much as possible in these cases.

But feel free to wait for additional comments before sending a v2 with the order changed.

- Oskari

PS: I was unable to find references to either /usr/lib/kernel.d/ or /etc/kernel.d/ being used after a brief search online, so I presume that they are to be provided by the distro's kernel package(s).

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

author
#4 lore raw
In reply to Simon Rowe

Ping?

On 01/03/2024, 15:43, "Simon Rowe" <[email protected]> wrote:

Kernel parameters actually cover a range of purposes, including userspace like systemd. They also need setting for a variety of reasons:

* as distro defaults
* to provide configuration for a package
* for an admin to set desired behaviour

Having these all combined in a single line (like GRUB_CMDLINE_LINUX) is unwieldy, it is hard to make changes without impacting another usecase.

Add optional support for dropin files in the directories:

* /usr/lib/kernel.d/
* /etc/kernel.d/

where the contents of each file with the '.conf' suffix is evaluated (excluding comments) and appended to any other kernel parameters defined via GRUB_CMDLINE_LINUX etc. Files in /etc/kernel.d/ completely replace those of the same name in /usr/lib/kernel.d/. This allows a distro or installer to set parameters but then for an admin to override them.

---
 util/grub-mkconfig_lib.in   | 18 ++++++++++++++++++
 util/grub.d/10_linux.in     |  8 +++++---
 util/grub.d/20_linux_xen.in |  8 +++++---
 3 files changed, 28 insertions(+), 6 deletions(-)
util/grub-mkconfig_lib.in +18 -0
index 08953287c..7aaa747f1 100644
@@ -348,3 +348,21 @@ grub_add_tab () {
   sed -e "s/^/$grub_tab/"
 }
 
+kernel_params_from_files () {
+  # Read Linux kernel parameters from dropin files.
+
+  file_bases=""
+
+  for f in /etc/kernel.d/*.conf /usr/lib/kernel.d/*.conf; do
+    [ -r $f ] || continue
+    file_bases="$file_bases $(basename $f)"
+  done
+
+  for b in $(echo $file_bases | tr ' ' '\n' | sort -u); do
+    if [ -r /etc/kernel.d/$b ]; then
+      grep -v '^#' /etc/kernel.d/$b | tr '\n' ' '
+    elif [ -r /usr/lib/kernel.d/$b ]; then
+      grep -v '^#' /usr/lib/kernel.d/$b | tr '\n' ' '
+    fi
+  done
+}
util/grub.d/10_linux.in +5 -3
index cc393be7e..fba3775f9 100644
@@ -275,6 +275,8 @@ for linux in ${reverse_sorted_list}; do
     fi
   fi
 
+  extra_kernel_params=$(kernel_params_from_files)
+
   # The GRUB_DISABLE_SUBMENU option used to be different than others since it was
   # mentioned in the documentation that has to be set to 'y' instead of 'true' to
   # enable it. This caused a lot of confusion to users that set the option to 'y',
@@ -285,7 +287,7 @@ for linux in ${reverse_sorted_list}; do
 
   if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
     linux_entry "${OS}" "${version}" simple \
-    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${extra_kernel_params}"
 
     submenu_indentation="$grub_tab"
 
@@ -298,10 +300,10 @@ for linux in ${reverse_sorted_list}; do
   fi
 
   linux_entry "${OS}" "${version}" advanced \
-              "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+              "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${extra_kernel_params}"
   if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
     linux_entry "${OS}" "${version}" recovery \
-                "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}"
+                "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX} ${extra_kernel_params}"
   fi
 done
 
util/grub.d/20_linux_xen.in +5 -3
index 94dd8be13..089f6de43 100644
@@ -336,6 +336,8 @@ for current_xen in ${reverse_sorted_xen_list}; do
             fi
         fi
 
+       extra_kernel_params=$(kernel_params_from_files)
+
         # The GRUB_DISABLE_SUBMENU option used to be different than others since it was
         # mentioned in the documentation that has to be set to 'y' instead of 'true' to
         # enable it. This caused a lot of confusion to users that set the option to 'y',
@@ -346,7 +348,7 @@ for current_xen in ${reverse_sorted_xen_list}; do
 
         if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
             linux_entry "${OS}" "${version}" "${xen_version}" simple \
-               "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
+               "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT} ${extra_kernel_params}"
 
             submenu_indentation="$grub_tab$grub_tab"
 
@@ -360,10 +362,10 @@ for current_xen in ${reverse_sorted_xen_list}; do
         fi
 
         linux_entry "${OS}" "${version}" "${xen_version}" advanced \
-           "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
+           "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT} ${extra_kernel_params}"
         if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
             linux_entry "${OS}" "${version}" "${xen_version}" recovery \
-               "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}"
+               "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN} ${extra_kernel_params}"
         fi
     done
     if [ x"$is_top_level" != xtrue ]; then

--
2.22.3

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#5 lore raw
In reply to Simon Rowe
Quoted 17 lines · Simon Rowe

Kernel parameters actually cover a range of purposes, including userspace like systemd. They also need setting for a variety of reasons:

* as distro defaults
* to provide configuration for a package
* for an admin to set desired behaviour

Having these all combined in a single line (like GRUB_CMDLINE_LINUX) is unwieldy, it is hard to make changes without impacting another usecase.

Add optional support for dropin files in the directories:

* /usr/lib/kernel.d/
* /etc/kernel.d/

Quoted 6 lines

where the contents of each file with the '.conf' suffix is evaluated (excluding comments) and appended to any other kernel parameters defined via GRUB_CMDLINE_LINUX etc. Files in /etc/kernel.d/ completely replace those of the same name in /usr/lib/kernel.d/. This allows a distro or installer to set parameters but then for an admin to override them.

I'm -1 on this particular design choice given that it conflicts with existing consensus in the wider Linux world around storing the kernel command line in

/etc/kernel/cmdline, /usr/lib/kernel/cmdline, /proc/cmdline

(the first of these files is to be used)

And it is misaligned with already having a /etc/kernel directory in the first place, a .d should be extending a file. Hence the expectation here is that such drop-ins would go into a cmdline.d directory.

Of course, you first are going to have to implement reading /etc/kernel/cmdline and coordinate with other users like systemd's kernel-install (or canonical/nullboot also uses it) to add support for cmdline.d to our kernel installation scripts.

Generally speaking with drop-ins here I would expect this to work by merging the dropins from /etc and /usr and then doing:

- /etc/kernel/cmdline if available
- /usr/lib/kernel/cmdline if available
- merged drop-ins
- /proc/cmdline

i.e. /usr/lib/kernel/cmdline.d would be completely replaced by creating an /etc/kernel/cmdline.

Signature · 7 lines
debian developer - deb.li/jak | jak-linux.org - free software dev
ubuntu core developer                              i speak de, en

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel