Grub 2 improperly escapes kernel options with spaces on RHEL 7

Solution Verified - Updated -

Issue

  • When adding any kernel option with spaces to linux kernel command line in grub, grub will escape spaces on it and the linux kernel will not recognize the option. For example in the following line at /boot/grub2/grub.cfg:
linux16 /vmlinuz-3.10.0-123.4.4.el7.x86_64 root=/dev/mapper/rhel-root ro rd.lvm.lv=rhel/root crashkernel=256M  rd.lvm.lv=rhel/swap vconsole.font=latarcyrheb-sun16 vconsole.keymap=us rhgb quiet LANG=en_US.UTF-8
  • Adding the option dyndbg="module cpufreq +p":
linux16 /vmlinuz-3.10.0-123.4.4.el7.x86_64 root=/dev/mapper/rhel-root ro rd.lvm.lv=rhel/root crashkernel=256M  rd.lvm.lv=rhel/swap vconsole.font=latarcyrheb-sun16 vconsole.keymap=us rhgb quiet LANG=en_US.UTF-8 dyndbg="module cpufreq +p"
  • On kernel boot up, grub2 will wrongly give the parameter with spaces escaped. In the example above, the string given to the linux kernel is "dyndbg=module\x20cpufreq\x20+p", and as a result the kernel doesn't recognize the option, as can bee seen on kernel command line and errors present when reading the kernel log after the boot:
$ dmesg
...
[    0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.10.0-123.4.4.el7.x86_64 root=/dev/mapper/rhel-root ro rd.lvm.lv=rhel/root crashkernel=256M rd.lvm.lv=rhel/swap vconsole.font=latarcyrheb-sun16 vconsole.keymap=us rhgb quiet LANG=en_US.UTF-8 "dyndbg=module\x20cpufreq\x20+p"
...
[    0.014607] dynamic_debug:ddebug_parse_flags: bad flag-op m, at start of module\x20cpufreq\x20+p
[    0.014966] dynamic_debug:ddebug_exec_query: flags parse failed
...

Environment

  • Red Hat Enterprise Linux 7
  • Grub 2 boot loader

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content