Bug#514837: grub-pc fails to fully migrate kopt from /boot/grub/menu.lst

Marcus Obst marcus.obst at s2003.tu-chemnitz.de
Wed Feb 11 10:22:52 UTC 2009


Package: grub-pc
Version: 1.96+20080724-14
Tags: patch                                                                           
                                                                                      
While upgrading from grub (v1) to grub-pc (v2) the debconf script
(grub-pc.config) tries to migrate existing kopt arguments from
/boot/grub/menu.lst.

In my case kopt looked like this:

  kopt=root=/dev/sda2 resume=/dev/sda1 acpi_sleep=s3_bios vga=0x0368 ro

The responsible code snippet from grub-pc.config

1	if [ "$RET" = "fillme" ] ; then
2	    kopt=`sed -ne "s/^# kopt=//p" /boot/grub/menu.lst | tr -s " " "\n" |
3	    grep -vx "\(ro\|root=[^ ]*\)"` || true
4	        db_set grub-pc/linux_cmdline "${kopt}" || true

removes root= and ro options, so afterwards kopt contains

  resume=/dev/sda1
  acpi_sleep=s3_bios
  vga=0x0368

(Take care there are really newlines in, since this was requested
through the preceding tr operation from line 2.)

In line 4 the contents of $kopt are committed to debconf which silently
fails.

Since the quotes around ${kopt} expand the string as it is (newlines are
keept), db_set gets an argument with newlines resulting in
grub-pc/linux_cmdline only containing the first parameter
(resume=/dev/sda1).  The remaining kernel options are lost.

So please remove the quotes from line 4 to profit from bash's word
splitting, which works find in this case. The $kopt var will be split at
all characters from IFS and concatenated with spaces.

  Best regards from Dresden/Germany!                                                 
  Marcus Obst                 
-------------- next part --------------
diff -r a47bcf8fd823 grub-pc.config
--- a/grub-pc.config	Wed Feb 11 11:20:48 2009 +0100
+++ b/grub-pc.config	Wed Feb 11 11:21:38 2009 +0100
@@ -9,7 +9,7 @@
   # this check ensures we only do this once
   if [ "$RET" = "fillme" ] ; then
     kopt=`sed -ne "s/^# kopt=//p" /boot/grub/menu.lst | tr -s " " "\n" | grep -vx "\(ro\|root=[^ ]*\)"` || true
-    db_set grub-pc/linux_cmdline "${kopt}" || true
+    db_set grub-pc/linux_cmdline ${kopt} || true
     if [ "${kopt}" == "" ] ; then
       # something smells bad.  give user a chance to correct it.
       priority=high
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/pkg-grub-devel/attachments/20090211/ba162d9b/attachment.pgp 


More information about the Pkg-grub-devel mailing list