dracut/backport-fix-dracut-functions.sh-suppress-findmnt-error-msg-if-etc-fstab-not-exist.patch
hongjinghao 2663ebded8 backport patchs from upstream
(cherry picked from commit e37aecb42764d47b923dd3280385bd5438f466b6)
2024-02-22 14:56:32 +08:00

84 lines
2.7 KiB
Diff

From e9ed44c8864445d85018e31064cd888c358f1daf Mon Sep 17 00:00:00 2001
From: Tao Liu <ltao@redhat.com>
Date: Thu, 3 Nov 2022 17:21:25 +0800
Subject: [PATCH] fix(dracut-functions.sh): suppress findmnt error msg if
/etc/fstab not exist
When the rootfs of a virtual machine is virtiofs shared folder,
the /etc/fstab file may not exist. As a result, the "findmnt --fstab"
will complain "findmnt: can't read (null): No such file or directory"
when trying to rebuild kdump initramfs within the vm.
This patch checks if /etc/fstab exist before calling "findmnt --fstab"
to suppress the error message.
Before:
$ kdumpctl rebuild
kdump: Rebuilding /boot/initramfs-5.14.0-182.el9.x86_64kdump.img
findmnt: can't read (null): No such file or directory
findmnt: can't read (null): No such file or directory
findmnt: can't read (null): No such file or directory
After:
$ kdumpctl rebuild
kdump: Rebuilding /boot/initramfs-5.14.0-182.el9.x86_64kdump.img
Signed-off-by: Tao Liu <ltao@redhat.com>
Conflict:require adaption
Reference:https://github.com/dracutdevs/dracut/commit/e9ed44c8864445d85018e31064cd888c358f1daf
---
dracut-functions.sh | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/dracut-functions.sh b/dracut-functions.sh
index 9220c34..b0e9fa8 100755
--- a/dracut-functions.sh
+++ b/dracut-functions.sh
@@ -357,6 +357,7 @@ find_block_device() {
done; return 1; } && return 0
fi
# fall back to /etc/fstab
+ [[ ! -f "$dracutsysrootdir"/etc/fstab ]] && return 1
findmnt -e --fstab -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt" | { \
while read _majmin _dev || [ -n "$_dev" ]; do
@@ -403,6 +404,8 @@ find_mp_fstype() {
done; return 1; } && return 0
fi
+ [[ ! -f "$dracutsysrootdir"/etc/fstab ]] && return 1
+
findmnt --fstab -e -v -n -o 'FSTYPE' --target "$1" | { \
while read _fs || [ -n "$_fs" ]; do
[[ $_fs ]] || continue
@@ -439,6 +442,8 @@ find_dev_fstype() {
done; return 1; } && return 0
fi
+ [[ ! -f "$dracutsysrootdir"/etc/fstab ]] && return 1
+
findmnt --fstab -e -v -n -o 'FSTYPE' --source "$_find_dev" | { \
while read _fs || [ -n "$_fs" ]; do
[[ $_fs ]] || continue
@@ -463,6 +468,8 @@ find_mp_fsopts() {
findmnt -e -v -n -o 'OPTIONS' --target "$1" 2>/dev/null && return 0
fi
+ [[ ! -f "$dracutsysrootdir"/etc/fstab ]] && return 1
+
findmnt --fstab -e -v -n -o 'OPTIONS' --target "$1"
}
@@ -484,6 +491,8 @@ find_dev_fsopts() {
findmnt -e -v -n -o 'OPTIONS' --source "$_find_dev" 2>/dev/null && return 0
fi
+ [[ ! -f "$dracutsysrootdir"/etc/fstab ]] && return 1
+
findmnt --fstab -e -v -n -o 'OPTIONS' --source "$_find_dev"
}
--
2.23.0