diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-ignition/coreos-boot-edit.sh b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-ignition/coreos-boot-edit.sh index 3b16813b46..66fd1f2a81 100755 --- a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-ignition/coreos-boot-edit.sh +++ b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-ignition/coreos-boot-edit.sh @@ -33,3 +33,50 @@ root=$(karg root) if [ -z "${root}" ]; then /usr/bin/rdcore rootmap /sysroot --boot-mount ${bootmnt} fi + +# Generate the boot mount unit for the real root. Allow an Ignition config to +# override it. +mntfile=/etc/systemd/system/boot.mount +if [ ! -f "/sysroot/${mntfile}" ]; then + # 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 + # TODO add equivalent of getargbool() so we handle rd.multipath=0 + if [ -n "$(karg rd.multipath)" ]; then + bootdev=/dev/disk/by-label/dm-mpath-boot + fi + + devservice=$(systemd-escape -p "${bootdev}" --suffix=service) + + # We mount read-only by default mostly to protect + # against accidental damage. Only a few things + # owned by CoreOS should be touching /boot or the ESP. + # Use nodev,nosuid because some hardening guides want + # that even though it's of minimal value. + options=ro,nodev,nosuid + + cat > "/sysroot/${mntfile}" </dev/null; then - exit 0 -fi - -# Don't create mount units for /boot on live systems. -# ConditionPathExists won't work here because conditions don't affect -# the dependency on the underlying device unit. -if [ -f /run/ostree-live ]; then - exit 0 -fi - -add_wants() { - local name="$1"; shift - local wants_dir="${UNIT_DIR}/local-fs.target.wants" - mkdir -p "${wants_dir}" - ln -sf "../${name}" "${wants_dir}/${name}" -} - -# Generate mount units that work with device mapper. The traditional -# device unit (dev-disk-by\x2dlabel...) does not work since it is not the -# device that systemd will fsck. This code ensures that if the label -# is backed by a device-mapper target the dev-mapper.*.device is used. -mk_mount() { - local mount_pt="${1}"; shift - local path="${1}"; shift - local options="${1}"; shift - - local devservice=$(systemd-escape -p ${path} --suffix=service) - local unit_name=$(systemd-escape -p ${mount_pt} --suffix=mount) - - cat > "${UNIT_DIR}/${unit_name}" <