From 1e15fc9385241e09817367b84bf9a56e51b18094 Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Tue, 1 Aug 2023 17:50:17 +0100 Subject: [PATCH] Add fallback of removing systemd mount unit masks directly (!116) On RHEL / CentOS 8 GParted reports this error to the terminal when it is closed: # gparted GParted 1.5.0-git configuration --enable-online-resize libparted 3.2 >> --runtime cannot be used with unmask # $? 0 and leaves mount units masked: # systemctl list-units '*.mount' UNIT LOAD ACTIVE SUB DESCRIPTION ------------------------------------------------------------------ * -.mount masked active mounted Root Mount * boot.mount masked active mounted boot.mount ... This is because of this change [1] released in systemd 239. Systemd bug 9393 [2] was raised and the change was reverted [3] in systemd 240. According to repology.org only RHEL / CentOS 8 (and clones) and Fedora 29 shipped with systemd 239 [4]. Fix by detecting non-zero exit status from systemctl and falling back to directly removing the runtime mount unit mask files instead. Then have to use systemctl daemon-reload to inform systemd to reload it's configuration from disk to discover the masks have been removed. [1] systemctl: when removing enablement or mask symlinks, cover both /run and /etc https://github.com/systemd/systemd/commit/4910b35078ad24dcbc63f372b2fee087640201d0 [2] systemctl no longer allows unmask in combination with --runtime #9393 https://github.com/systemd/systemd/issues/9393 [3] Revert "systemctl: when removing enablement or mask symlinks, cover both /run and /etc" https://github.com/systemd/systemd/commit/1830ac51a4ad1d82a198e587207df451b581c821 [4] Versions for systemd https://repology.org/project/systemd/versions Closes !116 - Systemd mount masking and udev rule location updates --- gparted.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gparted.in b/gparted.in index 9a4e65f2..d8ea385d 100755 --- a/gparted.in +++ b/gparted.in @@ -231,10 +231,15 @@ for rule in $UDEV_TEMP_RULES; do done # -# Use systemctl to restore that status of any mount points changed above +# Use systemctl to unmask those mount points masked above # if test "x$HAVE_SYSTEMCTL" = "xyes"; then - systemctl --runtime unmask --quiet -- $MOUNTLIST + systemctl --runtime unmask --quiet -- $MOUNTLIST 2> /dev/null || \ + { + cd /run/systemd/system && + rm -f -- $MOUNTLIST && + systemctl daemon-reload + } fi exit $status