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.
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'
.