Skip to content

Instantly share code, notes, and snippets.

@COM8
Last active October 28, 2025 12:01
Show Gist options
  • Select an option

  • Save COM8/5084fdcc8afec5007c58c3b45cb2eaf3 to your computer and use it in GitHub Desktop.

Select an option

Save COM8/5084fdcc8afec5007c58c3b45cb2eaf3 to your computer and use it in GitHub Desktop.
Add Kernel Arguments With A `$` Sign In The Value To rpm-ostree Systems

Add Kernel Arguments With A $ Sign In The Value To rpm-ostree Systems

Let's say you want a kernel argument like memmap='1G$12G' to preallocate 1GiB of RAM starting from the 12GiB mark for later use e.g. for a DMA device. If you are on a rpm-ostree based system like Fedora Silverblue (Fedora Atomic Desktop) you might try this:

rpm-ostree kargs --append="memmap='1G$12G'"

Then you notice:

We have to escape the $ sign since else it would treat 1 as variable.

echo "memmap='1G$12G'"
# Prints:
# memmap='1G2G'

So you follow through and pass the following to it:

rpm-ostree kargs --append="memmap='1G\$12G'"

You double check your results if it got added correctly.

rpm-ostree kargs 
# Printing something like this:
# [...] memmap='1G$12G'

Then you reboot, but when you take a look at the kernel command line during boot (press e on the boot entry) you find just memmap='1G in there.

(╯°□°)╯︵ ┻━┻

Turns out it does not matter how many $ or \ you add in front of it, the $1 will always be treated as variable by The Boot Loader Specification.

Who Do We Get Around This?

The solution is a grub2 variable. Before adding the kernel argument add a new grub2 variable.

grub2-editenv - set "val_var='1G\$12G'"

Then add the kernel argument.

rpm-ostree kargs --append="memmap=\$val_var"

If you now reboot and take a look at the kernel command line arguments (press e on the boot entry) you will see the correct kernel argument there memmap='1G$12G'.

@AndhikaWB
Copy link

AndhikaWB commented Oct 14, 2025

I'm using Fedora Kinoite 42 and grub2-editenv - set doesn't work. It will say "environment block too small" when I try to set the variable.

grub2-editenv create doesn't seem to have any effect either (checked with grub2-editenv list). Do you have a solution/workaround for this?

My issue is the same as you (I need to use memmap due to corrupted RAM).

EDIT: It seems that grubenv file can only be 1024 bytes long max, my memmap is so long that it can't fit in that file

EDIT2: Late edit but grub2-2.12-32.fc42 fixed this issue (dollar sign won't be eaten anymore). This workaround is no longer needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment