From 93fba63150972d7c5501dc311f37f67f66743a0d Mon Sep 17 00:00:00 2001 From: Petr Stodulka Date: Wed, 17 Apr 2024 09:58:00 +0200 Subject: [PATCH] Upgrade dracut module: Update /usr mounting solution Originally we had implemented our own mount_usr.sh script, which took care about mounting the /usr when it is present on separate partition / mountpoint. It took care also about LVM activation. However, it has been problematic in various cases (e.g. when device needed more time for initialisation - e.g. when connected using FC). Let's use instead existing system solutions, starting the upgrade.target after initrd-fs.target (instead of just basic.target). jira: RHEL-3344 --- .../85sys-upgrade-redhat/module-setup.sh | 1 - .../dracut/85sys-upgrade-redhat/mount_usr.sh | 84 ------------------- .../files/dracut/90sys-upgrade/upgrade.target | 3 +- 3 files changed, 2 insertions(+), 86 deletions(-) delete mode 100755 repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/mount_usr.sh diff --git a/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/module-setup.sh b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/module-setup.sh index d73060cb91..45f9814806 100755 --- a/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/module-setup.sh +++ b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/module-setup.sh @@ -102,7 +102,6 @@ install() { inst_binary grep # script to actually run the upgrader binary - inst_hook upgrade 49 "$_moddir/mount_usr.sh" inst_hook upgrade 50 "$_moddir/do-upgrade.sh" #NOTE: some clean up?.. ideally, everything should be inside the leapp* diff --git a/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/mount_usr.sh b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/mount_usr.sh deleted file mode 100755 index 3c52652f32..0000000000 --- a/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/85sys-upgrade-redhat/mount_usr.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/sh -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh - -type info >/dev/null 2>&1 || . /lib/dracut-lib.sh - -export NEWROOT=${NEWROOT:-"/sysroot"} - -filtersubvol() { - _oldifs="$IFS" - IFS="," - set "$@" - IFS="$_oldifs" - while [ $# -gt 0 ]; do - case $1 in - subvol=*) :;; - *) printf '%s' "${1}," ;; - esac - shift - done -} - -mount_usr() -{ - # check, if we have to mount the /usr filesystem - while read -r _dev _mp _fs _opts _freq _passno; do - [ "${_dev%%#*}" != "$_dev" ] && continue - if [ "$_mp" = "/usr" ]; then - case "$_dev" in - LABEL=*) - _dev="$(echo "$_dev" | sed 's,/,\\x2f,g')" - _dev="/dev/disk/by-label/${_dev#LABEL=}" - ;; - UUID=*) - _dev="${_dev#block:}" - _dev="/dev/disk/by-uuid/${_dev#UUID=}" - ;; - esac - - # shellcheck disable=SC2154 # Variable root is assigned by dracut - _root_dev=${root#block:} - - if strstr "$_opts" "subvol=" && \ - [ "$(stat -c '%D:%i' "$_root_dev")" = "$(stat -c '%D:%i' "$_dev")" ] && \ - [ -n "$rflags" ]; then - # for btrfs subvolumes we have to mount /usr with the same rflags - rflags=$(filtersubvol "$rflags") - rflags=${rflags%%,} - _opts="${_opts:+${_opts},}${rflags}" - elif getargbool 0 ro; then - # if "ro" is specified, we want /usr to be mounted read-only - _opts="${_opts:+${_opts},}ro" - elif getargbool 0 rw; then - # if "rw" is specified, we want /usr to be mounted read-write - _opts="${_opts:+${_opts},}rw" - fi - echo "$_dev ${NEWROOT}${_mp} $_fs ${_opts} $_freq $_passno" - _usr_found="1" - break - fi - done < "${NEWROOT}/etc/fstab" >> /etc/fstab - - if [ "$_usr_found" != "" ]; then - info "Mounting /usr with -o $_opts" - mount "${NEWROOT}/usr" 2>&1 | vinfo - mount -o remount,rw "${NEWROOT}/usr" - - if ! ismounted "${NEWROOT}/usr"; then - warn "Mounting /usr to ${NEWROOT}/usr failed" - warn "*** Dropping you to a shell; the system will continue" - warn "*** when you leave the shell." - action_on_fail - fi - fi -} - -if [ -f "${NEWROOT}/etc/fstab" ]; then - # In case we have the LVM command available try make it activate all partitions - if command -v lvm 2>/dev/null 1>/dev/null; then - lvm vgchange -a y - fi - - mount_usr -fi diff --git a/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/upgrade.target b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/upgrade.target index 366b5cabc2..66e5a50353 100644 --- a/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/upgrade.target +++ b/repos/system_upgrade/common/actors/commonleappdracutmodules/files/dracut/90sys-upgrade/upgrade.target @@ -2,7 +2,8 @@ Description=System Upgrade Documentation=man:upgrade.target(7) # ##sysinit.target sockets.target initrd-root-fs.target initrd-root-device.target initrd-fs.target +# # NOTE: maybeeeee add: initrd-parse-etc.service Wants=initrd-root-fs.target initrd-root-device.target initrd-fs.target initrd-usr-fs.target Requires=basic.target sysroot.mount -After=basic.target sysroot.mount +After=basic.target sysroot.mount initrd-fs.target AllowIsolate=yes