I would like to be able to choose between alternative Linux command lines in my GRUB menu (specifically, I want a "selinux=0" option, but I can imagine that people might want other things). I could add an extra script to /etc/grub.d to do this, but then I have to copy the logic in 10_linux to detect what kernel versions are available, and they do not appear in the correct place in the menu. It would be simpler if you could specify variant command lines in /etc/default/grub and have them handled automatically in 10_linux.

The attached patch allows (for example) the following configuration in /etc/default/grub:
GRUB_LINUX_VARIANTS="noselinux kms"

GRUB_CMDLINE_LINUX_noselinux="selinux=0"
GRUB_LABEL_LINUX_noselinux="SELinux disabled"

GRUB_CMDLINE_LINUX_kms="i915.modesetting=1"
GRUB_LABEL_LINUX_kms="KMS enabled"

This patch is only intended as a demonstration: various details of the implementation still need to be sorted out, such as internationalization. Suggestions of wildly different approaches/configuration interfaces are welcome.

Best wishes,

--
Martin Orr
=== modified file 'util/grub-mkconfig.in'
--- util/grub-mkconfig.in	2009-12-12 00:43:32 +0000
+++ util/grub-mkconfig.in	2010-01-18 21:01:34 +0000
@@ -222,6 +222,11 @@
   GRUB_GFXMODE \
   GRUB_DISABLE_OS_PROBER
 
+export GRUB_LINUX_VARIANTS
+for i in $GRUB_LINUX_VARIANTS; do
+  export GRUB_CMDLINE_LINUX_${i} GRUB_LABEL_LINUX_${i}
+done
+
 if test "x${grub_cfg}" != "x"; then
   rm -f ${grub_cfg}.new
   exec > ${grub_cfg}.new

=== modified file 'util/grub.d/10_linux.in'
--- util/grub.d/10_linux.in	2010-01-14 14:04:44 +0000
+++ util/grub.d/10_linux.in	2010-01-18 21:01:34 +0000
@@ -53,11 +53,15 @@
   version="$2"
   recovery="$3"
   args="$4"
+  label="$5"
   if ${recovery} ; then
     title="$(gettext "%s, with Linux %s (recovery mode)")"
   else
     title="$(gettext "%s, with Linux %s")"
   fi
+  if [ "x$label" != "x" ]; then
+    title="${title} (${label})"
+  fi
   printf "menuentry \"${title}\" {\n" "${os}" "${version}"
   save_default_entry | sed -e "s/^/\t/"
   if [ -z "${prepare_boot_cache}" ]; then
@@ -111,11 +115,17 @@
   fi
 
   linux_entry "${OS}" "${version}" false \
-      "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+      "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" ""
   if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
     linux_entry "${OS}" "${version}" true \
-	"single ${GRUB_CMDLINE_LINUX}"
+	"single ${GRUB_CMDLINE_LINUX}" ""
   fi
+  for i in ${GRUB_LINUX_VARIANTS}; do
+    eval cmdline=\${GRUB_CMDLINE_LINUX_${i}}
+    eval label=\${GRUB_LABEL_LINUX_${i}}
+    linux_entry "${OS}" "${version}" false \
+        "${cmdline}" "${label}"
+  done
 
   list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
 done

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

Reply via email to