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.
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'.
I'm using Fedora Kinoite 42 and
grub2-editenv - setdoesn't work. It will say "environment block too small" when I try to set the variable.grub2-editenv createdoesn't seem to have any effect either (checked withgrub2-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.