Ubuntu

grub2: needed (undocumented) character escape for kernel parameters

Reported by Raphael Gradenwitz on 2009-10-08
44
This bug affects 6 people
Affects Status Importance Assigned to Milestone
grub
Unknown
Unknown
grub2 (Debian)
Confirmed
Unknown
grub2 (Ubuntu)
High
Unassigned

Bug Description

Binary package hint: grub-pc

I need to start my Kernel on a Sony Vaio Z-Series Laptop with Argument:
acpi_osi="!Windows 2006"

Under grub-legacy I could simply add this in the /boot/grub/menu.lst and it worked:
cat /proc/cmdline
... ... acpi_osi="!Windows 2006" ... ...

Now, with grub2, I have entered this in /etc/default/grub:

GRUB_CMDLINE_LINUX="acpi_osi=\"!Windows 2006\""

and tried it as well with

GRUB_CMDLINE_LINUX="acpi_osi=\\\"!Windows 2006\\\""

after executing

    sudo /usr/sbin/grub-mkconfig

it creates a correct /boot/grub/grub.cfg

BUT
===

when I boot, in /proc/cmdline only arrives

... ... acpi_osi=!Windows 2006 ... ...

(without the quotes that should protect the space between Windows and 2006)

The only way to start and get this comandline as needed, is pressing the 'e' (edit) button after boot while the kernel-list is visible and edit the kernel comandline by hand in the way that I put a backslash in front of those quote-signs.

More is discussed here
Mailing list: https://launchpad.net/~sony-vaio-z-series

Norbert Preining (preining) wrote :

Debian bug: http://bugs.debian.org/550319

upstream bug report: http://savannah.gnu.org/bugs/?27641

Best Norbert

shemgp (shemgp) wrote :

testing@hidden:~$ uname -ra
Linux notelf 2.6.31-13-generic #43-Ubuntu SMP Fri Oct 9 17:42:36 UTC 2009 i686 GNU/Linux

testing@hidden:~$ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-2.6.31-13-generic root=UUID=2d36e902-cd10-47a1-af4d-3eb85b8d97d6 ro memmap=0x100000$0x38900000 acpi_osi="!Windows 2006" splash

testing@hidden:~$ cat /etc/default/grub | grep GRUB_CMDLINE_LINUX
GRUB_CMDLINE_LINUX_DEFAULT="splash"
GRUB_CMDLINE_LINUX='memmap=0x100000\$0x38900000 '"acpi_osi=\\\"!Windows 2006\\\""

testing@hidden:~$ sudo cat /boot/grub/grub.cfg | grep memmap | head -n 1
[sudo] password for testing:
 linux /boot/vmlinuz-2.6.31-13-generic root=UUID=2d36e902-cd10-47a1-af4d-3eb85b8d97d6 ro memmap=0x100000\$0x38900000 acpi_osi=\"!Windows 2006\" splash

testing@hidden:~$ dmesg | grep ACPI | grep -i windows
[ 0.000000] ACPI: Deleted _OSI(Windows 2006)

I guess it's working?

shemgp (shemgp) wrote :

Btw, after editing /etc/default/grub and adding the "acpi_osi=\\\"!Windows 2006\\\"", i used update-grub to update the grub.cfg, I'm not sure if that made the difference.

Colin Watson (cjwatson) on 2009-10-12
Changed in grub2 (Ubuntu):
importance: Undecided → High
Changed in grub2 (Debian):
status: Unknown → Confirmed
bvk (bvk) wrote :

As shemgp said, executing update-grub after update as per below quoting works.

GRUB_CMDLINE_LINUX=" foo=\\\"bar baz\\\" "

Eward Schippers (eward) wrote :

Would this also work for the GRUB_TERMINAL=serial command?
As it is now I do get the kernel messages on my serial console but not on the main console.
The way I see it that line needs the console added to it but then you have a space in it
GRUB_TERMINAL="serial console"

Also see duplicate https://bugs.launchpad.net/bugs/486051
I'm still not sure this is indeed a duplicate?

Changed in grub2 (Ubuntu):
status: New → Confirmed
Jean-Louis (jean-louis) wrote :
Download full text (3.9 KiB)

jean-louis@desktop:~$ apt-show-versions | grep grub
grub-common 1.97~beta4-1ubuntu5 newer than version in archive
grub-pc 1.97~beta4-1ubuntu5 newer than version in archive

jean-louis@desktop:~$ uname -a
Linux desktop 2.6.31-21-generic #59-Ubuntu SMP Wed Mar 24 07:28:56 UTC 2010 i686 GNU/Linux

Hi, sorry for my bad english.

I have similar problem: due to bad ram, I have to start my kernel with memmap parameter;
in accordance with kernel-parameters.txt, the exact string is (in my case) memmap=64k$0x24190000

if I put in /etc/default/grub:
  GRUB_CMDLINE_LINUX="memmap=64$0x24190000"
or press the 'e' (edit) button after boot and add manually:
  memmap=64$0x24190000
the pc don't boots and show only a blinking cursor...

instead if I put in /etc/default/grub:
 GRUB_CMDLINE_LINUX="memmap=64\\\$0x24190000"
or press the 'e' (edit) button after boot and add manually:
  memmap=64\$0x24190000
the pc boots correctly.

if I press F6 in cd live and add kernel parameter:
  memmap=64$0x24190000
the pc boots correctly.

There are 2 differents, but similar, problems:

[1]

if I put in /etc/default/grub:
  GRUB_CMDLINE_LINUX="memmap=64$0x24190000"

jean-louis@desktop:~$ sudo update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.31-21-generic
Found initrd image: /boot/initrd.img-2.6.31-21-generic
done

jean-louis@desktop:~$ cat /boot/grub/grub.cfg | grep vmlinuz
 linux /vmlinuz-2.6.31-21-generic root=UUID=e1b91314-5934-4c3e-ab0a-a2137ac93a91 ro memmap=64/usr/sbin/grub-mkconfigx24190000 quiet splash
 linux /vmlinuz-2.6.31-21-generic root=UUID=e1b91314-5934-4c3e-ab0a-a2137ac93a91 ro single memmap=64/usr/sbin/grub-mkconfigx24190000

the problem [1] is that GRUB_CMDLINE_LINUX and GRUB_CMDLINE_LINUX_DEFAULT is "expanded" without a reason...

for solve this problem, enclose those variable inside single-quote rather than double-quote

GRUB_CMDLINE_LINUX_DEFAULT='quiet splash'
GRUB_CMDLINE_LINUX='memmap=64$0x24190000'

(if kernel parameters require quote, use duble-quote: i.e.
 GRUB_CMDLINE_LINUX='acpi_osi="!Windows 2006" memmap=64$0x24190000'
)

jean-louis@desktop:~$ sudo update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.31-21-generic
Found initrd image: /boot/initrd.img-2.6.31-21-generic
done

jean-louis@desktop:~$ cat /boot/grub/grub.cfg | grep vmlinuz
 linux /vmlinuz-2.6.31-21-generic root=UUID=e1b91314-5934-4c3e-ab0a-a2137ac93a91 ro memmap=64$0x24190000 quiet splash
 linux /vmlinuz-2.6.31-21-generic root=UUID=e1b91314-5934-4c3e-ab0a-a2137ac93a91 ro single memmap=64$0x24190000

now grub.cfg is correct, but pc don't boot due to problem 2

[2] (there is also when manually edits kernel parameter after boot)

if the parser find $ or " change state, but this don't have meaning for kernel parameters.

I have single-quoted the parameters of command 'linux' all together (except kernel name), because the initial parser must don't touch those parameters

for version 1.97~beta4-1ubuntu5 (karmic-proposed)

edit /etc/grub.d/10_linux search:

linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro $2

and replace with:

linux ${rel_dirname}/${basename} 'root=${linux_root_device_thisversion} ro $2'

jean-louis@de...

Read more...

Jean-Louis (jean-louis) on 2010-05-06
summary: - grub2 does not work with kernel comandline arguments containing spaces
+ grub2: needed (undocumented) character escape for kernel parameters
Jean-Louis (jean-louis) wrote :

For FIX karmic-proposed, I have created a PPA, but is still building

this is my first ppa, I don't know if it's ok

IMHO, this isn't a GRUB2 (grub-pc) bug, it is the documented behavior of the shell used to generate the configuration file (default grub.cfg). So-called here-documents (used extensively in the distributed default scripts) are documented to interpolate shell variables, consume quoting, etc. Perhaps what is not particularly clear is that the /etc/default/grub and /etc/grub.d/* files are sourced, therefore backslashes, quotes, and apostrophes within it must be used judiciously (because levels of quoting will be consumed).

In the example of the memmap case, $0, the name of the program, is being substituted. That's why using the apostrophe method of quoting works. Similarly, it has been a long standing voodoo of sorts to know how to escape with backslashes so that the proper number will be stripped off at the final evaluation, and get the character one is trying to escape (such as "). That's also why sometimes it's easier to use the apostrophe for quoting to include spaces, dollar, and double quotes. Consider it's also possible to use a hybrid quoting approach too, such as:

GRUB_CMDLINE_LINUX='nolapic memmap=64$0x24190000 console='"$GRUB_TERMINAL"' console=tty2'

(of course, that wouldn't quite work in reality, as the console device names for GRUB and Linux differ).

tags: added: natty
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.