From d49e7113e283159fc3448acca875e4091b4c064e Mon Sep 17 00:00:00 2001 From: Jerry Date: Wed, 31 May 2023 14:02:04 +0800 Subject: [PATCH] update: kernel-modules-hook-hardlinks: fix umount issue caused by udevd --- kernel-modules-hook-hardlinks/PKGBUILD | 4 ++-- kernel-modules-hook-hardlinks/linux-modules-restore | 5 +++-- kernel-modules-hook-hardlinks/linux-modules-save | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/kernel-modules-hook-hardlinks/PKGBUILD b/kernel-modules-hook-hardlinks/PKGBUILD index 83762f6..23ac823 100644 --- a/kernel-modules-hook-hardlinks/PKGBUILD +++ b/kernel-modules-hook-hardlinks/PKGBUILD @@ -18,8 +18,8 @@ source=("linux-modules-cleanup.conf" sha256sums=('950f851eba08dac4d0b93ff62b3fb16ddacd4f8ebb98a2435f80bf05f2ea5a29' '087e5ed70b2fc512d814fbded9e873955b1da5b6bf1e31975174d704ad143156' 'fc4d53dec520c80fe97dfda65b238c7d678e7ef26aaebffc5b43f924477ea4f4' - 'a6e3013f04f45e6d1ed63b4545fb0d4f102d230db582bec76568dbf40c529fbb' - '36a8ab6bcb3e0bf8c82324877471ec8798e5ae273b26bdfbc4b6f59035af0351') + 'a902b49c67df16ba69c246b589b89598dff3edd5fe9965c107140e4e7e98110a' + 'af7df16af22dd759495518e6d28484ff656458e505f04cf5aacfc6d7d3935d82') package() { install -Dm644 'linux-modules-cleanup.conf' "${pkgdir}/usr/lib/tmpfiles.d/linux-modules-cleanup.conf" diff --git a/kernel-modules-hook-hardlinks/linux-modules-restore b/kernel-modules-hook-hardlinks/linux-modules-restore index 89d06c4..3450b2c 100644 --- a/kernel-modules-hook-hardlinks/linux-modules-restore +++ b/kernel-modules-hook-hardlinks/linux-modules-restore @@ -3,9 +3,10 @@ kver=$(uname -r) while read -r line; do # We only care about the running kernel - if [[ "$line" == usr/lib/modules/$kver/vmlinuz && -d usr/lib/modules/running-kernel ]];then - mount --mkdir --bind --options ro /usr/lib/modules/{running-kernel,$kver} + if [[ "$line" == usr/lib/modules/$kver/vmlinuz && -d /usr/lib/modules/running-kernel ]];then + systemd-mount --quiet --options=bind,ro --property=LazyUnmount=1 /usr/lib/modules/{running-kernel,$kver} # Mounting read-only since the only modification here should be unmounting # when rebooting or reinstalling the running kernel + # LazyUnmount at shutdown in case udevd is blocking us fi done diff --git a/kernel-modules-hook-hardlinks/linux-modules-save b/kernel-modules-hook-hardlinks/linux-modules-save index 90069dd..cc206c4 100644 --- a/kernel-modules-hook-hardlinks/linux-modules-save +++ b/kernel-modules-hook-hardlinks/linux-modules-save @@ -9,7 +9,8 @@ while read -r line; do # This means we already ran that hook during 'remove case' # # Remove the mount so we can reinstall the kernel - umount ${line%vmlinuz} + # Most of the time udevd would block the umount, so suppress the first error message + umount ${line%vmlinuz} 2>/dev/null || umount --lazy ${line%vmlinuz} elif [[ -f "$line" && ! -d "/usr/lib/modules/running-kernel/" ]];then # Kernel install is present and we do not have a copy #