Package: grub-common
Version: 1.98+20100804-14
Severity: wishlist
Tags: patch

Hello,

I need to pass different options for Linux and Xen Linux kernels on my
server. Please look at the exemplary menu entries below:

menuentry 'Debian GNU/Linux, with Linux 2.6.32-5-xen-amd64 and XEN
4.0-amd64' --class debian --class gnu-linux --class gnu --class os
--class xen {
        insmod raid
        insmod mdraid
        insmod lvm
        insmod part_gpt
        insmod part_gpt
        insmod ext2
        set root='(lvm0-dom0)'
        search --no-floppy --fs-uuid --set
5e6467b4-b670-4ea7-9fb3-9f45b94c93fe
        echo    'Loading Linux 2.6.32-5-xen-amd64 ...'
        multiboot       /boot/xen-4.0-amd64.gz placeholder com1=9600,8n1
console=com1,vga dom0_mem=1024M
        module  /boot/vmlinuz-2.6.32-5-xen-amd64 placeholder
root=/dev/mapper/lvm0-dom0 ro console=tty0 console=hvc0 3
        echo    'Loading initial ramdisk ...'
        module  /boot/initrd.img-2.6.32-5-xen-amd64
}

menuentry 'Debian GNU/Linux, with Linux 2.6.32-5-xen-amd64' --class
debian --class gnu-linux --class gnu --class os {
        insmod raid
        insmod mdraid
        insmod lvm
        insmod part_gpt
        insmod part_gpt
        insmod ext2
        set root='(lvm0-dom0)'
        search --no-floppy --fs-uuid --set
5e6467b4-b670-4ea7-9fb3-9f45b94c93fe
        echo    'Loading Linux 2.6.32-5-xen-amd64 ...'
        linux   /boot/vmlinuz-2.6.32-5-xen-amd64
root=/dev/mapper/lvm0-dom0 ro console=tty0 console=ttyS0,9600n8 2
        echo    'Loading initial ramdisk ...'
        initrd  /boot/initrd.img-2.6.32-5-xen-amd64
}

As you can see I use different consoles for these kernels. I can't set
them in only one GRUB_CMDLINE_LINUX variable in /etc/default/grub file,
because grub-update command will use it for any my Linux kernels...

So I've patched 20_linux_xen and grub-mkconfig scripts and added new
GRUB_CMDLINE_LINUX_XEN variable for options of Xen Linux kernels:

GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,9600n8 2"
GRUB_CMDLINE_LINUX_XEN="console=tty0 console=hvc0 3"

Of course, GRUB_CMDLINE_LINUX_XEN is optional variable. grub-update will
use GRUB_CMDLINE_LINUX if the new variable is unset or empty.

I believe that now GRUB_CMDLINE_XEN and GRUB_CMDLINE_LINUX_XEN is the
same pair like xenhopt and xenopt for old Grub.

I'm attaching my simple patch. Feel free to use it if you want.

--- 20_linux_xen.orig	2011-05-18 08:13:35.000000000 +0000
+++ 20_linux_xen	2011-05-18 19:37:58.000000000 +0000
@@ -132,11 +132,15 @@
 	    linux_root_device_thisversion=${GRUB_DEVICE}
 	fi
 
+	args=${GRUB_CMDLINE_LINUX}
+	if [ "x${GRUB_CMDLINE_LINUX_XEN}" != "x" ]; then
+	    args=${GRUB_CMDLINE_LINUX_XEN}
+	fi
 	linux_entry "${OS}" "${version}" "${xen_version}" false \
-	    "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
+	    "${args} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
 	if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
 	    linux_entry "${OS}" "${version}" "${xen_version}" true \
-		"single ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}"
+		"single ${args}" "${GRUB_CMDLINE_XEN}"
 	fi
 
 	list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
--- grub-mkconfig.orig	2011-05-18 08:30:41.000000000 +0000
+++ grub-mkconfig	2011-05-18 19:38:11.000000000 +0000
@@ -257,6 +257,7 @@
   GRUB_BUTTON_CMOS_ADDRESS \
   GRUB_DISTRIBUTOR \
   GRUB_CMDLINE_LINUX \
+  GRUB_CMDLINE_LINUX_XEN \
   GRUB_CMDLINE_LINUX_DEFAULT \
   GRUB_CMDLINE_XEN \
   GRUB_CMDLINE_XEN_DEFAULT \

Reply via email to