Skip to content

Instantly share code, notes, and snippets.

@COM8
Last active April 18, 2025 14:13
Show Gist options
  • Save COM8/5084fdcc8afec5007c58c3b45cb2eaf3 to your computer and use it in GitHub Desktop.
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: One sec I have to escape the $ sign since else it would treat the 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 are grub2 variables. 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'.

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