#1086530 installation-reports: memmap kernel option containing '$' makes installed system unbootable

#1086530#5
Date:
2024-10-31 23:28:17 UTC
From:
To:
Boot method: USB
Image version: debian-12.7.0-amd64-netinst.iso downloaded from
https://www.debian.org/ (Download button) on 30-Oct-2024
Date: Wed Oct 30 00:05:20 GMT 2024

Machine: Intel Compute Stick STK1AW32SC (Intel Atom x5-Z8330)
Partitions:

Filesystem                 Type     1K-blocks    Used Available Use%
Mounted on
udev                       devtmpfs    937596       0    937596   0% /dev
tmpfs                      tmpfs       192492     916    191576   1% /run
/dev/mapper/stick--vg-root ext4      27868092 1923196  24503924   8% /
tmpfs                      tmpfs       962456       0    962456   0%
/dev/shm
tmpfs                      tmpfs         5120       0      5120   0%
/run/lock
/dev/mmcblk1p2             ext2        466026  103246    337795  24% /boot
/dev/mmcblk1p1             vfat        523248    5984    517264   2%
/boot/efi
tmpfs                      tmpfs       192488       0    192488   0%
/run/user/0
tmpfs                      tmpfs       192488       0    192488   0%
/run/user/1000


Base System Installation Checklist:
[O] = OK, [E] = Error (please elaborate below), [ ] = didn't try it

Initial boot:           [O]
Detect network card:    [O]
Configure network:      [O]
Detect media:           [O]
Load installer modules: [O]
Clock/timezone setup:   [O]
User/password setup:    [O]
Detect hard drives:     [O]
Partition hard drives:  [O]
Install base system:    [O]
Install tasks:          [O]
Install boot loader:    [E]
Overall install:        [E]

Comments/Problems:

I am installing Debian on an Intel Compute Stick with some bad RAM. I
use memmap= kernel parameter to exclude two RAM regions. I've edited
GRUB menu when booting the Installer, adding the following after
tripple-dash:

memmap=0x1000\$0x2f1ac000,0x1000\$0x6af53000

Note the back-slashes: they are required, otherwise GRUB "eats" the
dollar sign and everything that goes after it, and the kernel does not
boot.

When installer creates /etc/grub/defaults in the installed system,
it copies kernel parameters written after '---' to the variable
GRUB_CMDLINE_LINUX, not properly escaping the dollar sign.

When boot loader is configured, 'update-grub' removes the back-slash and
writes bare dollar sign to /boot/grub/grub.cfg.
As a result, the installed system fails to boot.

Proposed solution: backslash ('\') and dollar sign ('$') should be
properly escaped when copying kernel parameters from /proc/cmd to
/etc/grub/defaults.

For example, this parameter from /proc/cmd

	memmap=0x1000$0x2f1ac000,0x1000$0x6af53000

can be written in /etc/grub/defaults as follows:

	GRUB_CMDLINE_LINUX="memmap=0x1000\\\$0x2f1ac000,0x1000\\\$0x6af53000"

#1086530#10
Date:
2024-11-01 13:52:02 UTC
From:
To:
AFAIK grub-installer only writes the kernel parameters into debconf
database and grub-<platform> postinst script reads them from debconf and
writes them into /etc/default/grub. I wonder if '$' escaping should be
done by grub-installer or by grub-<platform> package postinst script.
IMO the latter would be best, so that the plain unescaped kernel
parameters are registered in debconf.