Skip to content

Commit e9ed44c

Browse files
liutgnuaafeijoo-suse
authored andcommitted
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>
1 parent 6b592f5 commit e9ed44c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

dracut-functions.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ find_block_device() {
383383
} && return 0
384384
fi
385385
# fall back to /etc/fstab
386+
[[ ! -f "$dracutsysrootdir"/etc/fstab ]] && return 1
386387
387388
findmnt -e --fstab -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt" | {
388389
while read -r _majmin _dev || [ -n "$_dev" ]; do
@@ -433,6 +434,8 @@ find_mp_fstype() {
433434
} && return 0
434435
fi
435436
437+
[[ ! -f "$dracutsysrootdir"/etc/fstab ]] && return 1
438+
436439
findmnt --fstab -e -v -n -o 'FSTYPE' --target "$1" | {
437440
while read -r _fs || [ -n "$_fs" ]; do
438441
[[ $_fs ]] || continue
@@ -473,6 +476,8 @@ find_dev_fstype() {
473476
} && return 0
474477
fi
475478
479+
[[ ! -f "$dracutsysrootdir"/etc/fstab ]] && return 1
480+
476481
findmnt --fstab -e -v -n -o 'FSTYPE' --source "$_find_dev" | {
477482
while read -r _fs || [ -n "$_fs" ]; do
478483
[[ $_fs ]] || continue
@@ -499,6 +504,8 @@ find_mp_fsopts() {
499504
findmnt -e -v -n -o 'OPTIONS' --target "$1" 2> /dev/null && return 0
500505
fi
501506
507+
[[ ! -f "$dracutsysrootdir"/etc/fstab ]] && return 1
508+
502509
findmnt --fstab -e -v -n -o 'OPTIONS' --target "$1"
503510
}
504511
@@ -522,6 +529,8 @@ find_dev_fsopts() {
522529
findmnt -e -v -n -o 'OPTIONS' --source "$_find_dev" 2> /dev/null && return 0
523530
fi
524531
532+
[[ ! -f "$dracutsysrootdir"/etc/fstab ]] && return 1
533+
525534
findmnt --fstab -e -v -n -o 'OPTIONS' --source "$_find_dev"
526535
}
527536

0 commit comments

Comments
 (0)