Dracut module: fix parsing of root= kernel command-line argument #13589
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some Dracut modules may read the
root=
kernel command-line argument and rewrite it; in particular,rootfs-block
installs a command-line hook that to canonicalize arguments that specify block devices. If thezfs
module is added to an initramfs (which it is, by default, as long as the core ZFS utilities are available) on a system that does not use a ZFS root filesystem, thezfs
module will overwrite theroot
shell variable with the contents of the kernel command-line in the process of determining if it should control mounting the root. This breaks the initramfs.Motivation and Context
If the
zfs
dracut module will be automatically included in initramfs images, it should avoid corruptingroot
arguments when those arguments refer to non-ZFS filesystems.This bug was identified in void-linux/void-packages#37667 and should be fixed by this patch.
Description
Simply check if the
root
shell variable is non-empty, which means it has already been parsed (and possibly rewritten); prefer a previously parsed version if possible. Otherwise, parse the kernel command-line directly to populate theroot
shell variable. Subsequent decisions about rewritingroot
based on the existence of ZFS indicators remain unchanged.How Has This Been Tested?
I have no systems without ZFS roots, so this was "tested" by reasoning in a thought experiment.
Types of changes
Checklist:
Signed-off-by
.