-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make handling of boot=
and root=
kargs idempotent
#2141
Changes from 2 commits
6f7197a
df01601
7b4d459
d01094a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,60 @@ copy_file_if_exists() { | |
destination=/usr/lib/ignition | ||
mkdir -p $destination | ||
|
||
karg() { | ||
local name="$1" value="${2:-}" | ||
local cmdline=( $(</proc/cmdline) ) | ||
for arg in "${cmdline[@]}"; do | ||
if [[ "${arg%%=*}" == "${name}" ]]; then | ||
value="${arg#*=}" | ||
fi | ||
done | ||
echo "${value}" | ||
} | ||
|
||
# Copied from | ||
# https://github.com/dracutdevs/dracut/blob/9491e599282d0d6bb12063eddbd192c0d2ce8acf/modules.d/99base/dracut-lib.sh#L586 | ||
# rather than sourcing it. | ||
label_uuid_to_dev() { | ||
local _dev | ||
_dev="${1#block:}" | ||
case "$_dev" in | ||
LABEL=*) | ||
echo "/dev/disk/by-label/$(echo "${_dev#LABEL=}" | sed 's,/,\\x2f,g;s, ,\\x20,g')" | ||
;; | ||
PARTLABEL=*) | ||
echo "/dev/disk/by-partlabel/$(echo "${_dev#PARTLABEL=}" | sed 's,/,\\x2f,g;s, ,\\x20,g')" | ||
;; | ||
UUID=*) | ||
echo "/dev/disk/by-uuid/$(echo "${_dev#UUID=}" | tr "[:upper:]" "[:lower:]")" | ||
;; | ||
PARTUUID=*) | ||
echo "/dev/disk/by-partuuid/$(echo "${_dev#PARTUUID=}" | tr "[:upper:]" "[:lower:]")" | ||
;; | ||
esac | ||
} | ||
|
||
# This is copied from coreos-boot-mount-generator which we should likely run | ||
# in the initramfs too | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think that'd be a safer path. This seems to be trying to undo the assumption that |
||
bootdev=/dev/disk/by-label/boot | ||
bootkarg=$(karg boot) | ||
mpath=$(karg rd.multipath) | ||
if [ -n "${mpath}" ] && [ "${mpath}" != 0 ]; then | ||
bootdev=/dev/disk/by-label/dm-mpath-boot | ||
# Newer nodes inject boot=UUID=..., but we support a larger subset of the dracut/fips API | ||
elif [ -n "${bootkarg}" ]; then | ||
# Adapted from https://github.com/dracutdevs/dracut/blob/9491e599282d0d6bb12063eddbd192c0d2ce8acf/modules.d/01fips/fips.sh#L17 | ||
case "$bootkarg" in | ||
LABEL=* | UUID=* | PARTUUID=* | PARTLABEL=*) | ||
bootdev="$(label_uuid_to_dev "$bootkarg")";; | ||
/dev/*) bootdev=$bootkarg;; | ||
*) echo "Unknown boot karg '${bootkarg}'; falling back to ${bootdev}";; | ||
esac | ||
# This is used for the first boot only | ||
elif [ -f /run/coreos/bootfs_uuid ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is written by |
||
bootdev=/dev/disk/by-uuid/$(cat /run/coreos/bootfs_uuid) | ||
fi | ||
|
||
if is-live-image; then | ||
# Live image. If the user has supplied a config.ign via an appended | ||
# initrd, put it in the right place. | ||
|
@@ -27,6 +81,6 @@ else | |
mkdir -p $bootmnt | ||
# mount as read-only since we don't strictly need write access and we may be | ||
# running alongside other code that also has it mounted ro | ||
mount -o ro /dev/disk/by-label/boot $bootmnt | ||
mount -o ro $bootdev $bootmnt | ||
copy_file_if_exists "${bootmnt}/ignition/config.ign" "${destination}/user.ign" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should move to rdcore or so?