-
Notifications
You must be signed in to change notification settings - Fork 158
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
boot.mount: mount by UUID instead #1256
Changes from all commits
e159c81
5cfcea2
1107f90
644372b
09a2b1f
89066d5
ce08c51
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 |
---|---|---|
|
@@ -61,15 +61,50 @@ EOF | |
add_wants "${unit_name}" | ||
} | ||
|
||
# Copied from | ||
# https://github.com/dracutdevs/dracut/blob/9491e599282d0d6bb12063eddbd192c0d2ce8acf/modules.d/99base/dracut-lib.sh#L586 | ||
# rather than sourcing it. | ||
label_uuid_to_dev() { | ||
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. Another thing we could put in rdcore in the future? 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. Maybe. This runs in the real root, and so far Though in this case, since we want to just implement the same API as dracut/fips, it seems simpler to just copy-paste the API implementation itself. If there are bugs in there, at least we'll have the same bugs as dracut. :) |
||
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 | ||
} | ||
|
||
# If the root device is multipath, hook up /boot to use that too, | ||
# based on our custom udev rules in 90-coreos-device-mapper.rules | ||
# that creates "label found on mpath" links. | ||
# Otherwise, use the usual by-label symlink. | ||
# See discussion in https://github.com/coreos/fedora-coreos-config/pull/1022 | ||
bootdev=/dev/disk/by-label/boot | ||
# TODO add equivalent of getargbool() so we handle rd.multipath=0 | ||
if have_karg rd.multipath; then | ||
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 | ||
bootdev=/dev/disk/by-uuid/$(cat /run/coreos/bootfs_uuid) | ||
fi | ||
|
||
# We mount read-only by default mostly to protect | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
set -xeuo pipefail | ||
# kola: {"platforms": "qemu"} | ||
|
||
# These are read-only not-necessarily-related checks that verify default system | ||
# configuration both on first and subsequent boots. | ||
|
||
ok() { | ||
echo "ok" "$@" | ||
} | ||
|
||
fatal() { | ||
echo "$@" >&2 | ||
exit 1 | ||
} | ||
|
||
# /var | ||
varsrc=$(findmnt -nvr /var -o SOURCE) | ||
rootsrc=$(findmnt -nvr / -o SOURCE) | ||
[[ $(realpath "$varsrc") == $(realpath "$rootsrc") ]] | ||
ok "/var is backed by rootfs" | ||
|
||
# sanity-check that boot is mounted by UUID | ||
if ! systemctl cat boot.mount | grep -q What=/dev/disk/by-uuid; then | ||
systemctl cat boot.mount | ||
fatal "boot mounted not by UUID" | ||
fi | ||
ok "boot mounted by UUID" | ||
|
||
case "${AUTOPKGTEST_REBOOT_MARK:-}" in | ||
"") | ||
ok "first boot" | ||
/tmp/autopkgtest-reboot rebooted | ||
;; | ||
|
||
rebooted) | ||
# check for expected default kargs | ||
grep root=UUID= /proc/cmdline | ||
ok "found root karg" | ||
|
||
grep boot=UUID= /proc/cmdline | ||
ok "found boot karg" | ||
|
||
ok "second boot" | ||
;; | ||
*) fatal "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}";; | ||
esac |
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.
E.g. in FIPS mode, we'll already have a
boot=
karg there. (We should change that code to useboot=UUID
too.)