Package: initramfs-tools
Version: 0.148.3
initramfs-tools 0.148.3+rpt2
initramfs-tools-bin 0.148.3+rpt2
initramfs-tools-core 0.148.3+rpt2
Hi,
I've observed that initramfs-tools scripts/functions::resolve_device()
can indicate success when the device does not exist. In one of our image
configurations we use a partitioned LUKS2 device which requires a
partprobe before the partitions (and their corresponding device nodes)
are visible to the kernel. In this configuration, we use an alias for
the root device, such as:
root=/dev/disk/by-slot/active/system
This symlink is created upon part probe when custom udev rules fire (the
rule looks at both dm and non-dm devices and uses the GPT part label and
bootloader information to establish if the device is the active or
inactive slot).
As far as initramfs-tools go, this scheme prevents the local-block phase
from ever executing because the resolve_device() ends with:
[ -e "$DEV" ] && echo "$DEV"
When the device doesn't exist, the test fails and the function falls off
the end, returning 0 (success) with no output.
The callers in local_device_setup use real_dev=$(resolve_device ...) and
check the exit code to decide whether to enter the wait loop. This bug
results in resolve_device returning 0, so the ! condition is false, the
wait loop is never entered, and local_block is never called - even
though the device is genuinely absent.
It's a trivial, but important fix - succeed only if the device exists
and echo its path, else fail. This can be achieved by the function
ending with the following rather than the expression above.
[ -e "$DEV" ] || return 1
echo "$DEV"
Please can this fix be applied?
In the partitioned LUKS scheme with the (udev created) root= alias, this
bug means that a later phase needs to be used to perform the probe, eg
local-premount. This is an acceptable workaround, but the logical place
to perform the probe is in local-block, since after the probe, the
device would be available. This is in accordance with the documentation:
local-block These scripts are called with the name of a local block
device. After these scripts have been executed, that
device node should be present. If the local-top or local-
block scripts fail to create the wanted device node, the
local-block scripts will be called periodically to try
again.
Thanks,
-- Matt