update: kernel-modules-hook-hardlinks: fix umount issue caused by udevd

This commit is contained in:
JerryXiao 2023-05-31 14:02:04 +08:00
parent 92d1a61ebf
commit d49e7113e2
Signed by: Jerry
GPG Key ID: 22618F758B5BE2E5
3 changed files with 7 additions and 5 deletions

View File

@ -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"

View File

@ -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

View File

@ -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
#