From f4a0d9b4a7dfde51324ccba9c62c8f6549cdfe12 Mon Sep 17 00:00:00 2001 From: Eric Curtin Date: Wed, 12 Jun 2024 15:45:20 +0100 Subject: [PATCH] /proc/mounts is a clearly defined format This is a more solid check for if "/" is "btrfs". Signed-off-by: Eric Curtin --- scripts/guess_rootfs.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/guess_rootfs.sh b/scripts/guess_rootfs.sh index cc61e26..c3b1550 100755 --- a/scripts/guess_rootfs.sh +++ b/scripts/guess_rootfs.sh @@ -12,11 +12,12 @@ set_lvm () { } check_btrfs () { - fs=$(lsblk -f | grep "$(awk '/ \/ / {print $1}' /etc/fstab | grep -oP '(?<=UUID=)[^ ]*')" | awk '{print $2}') - if [ "$fs" = "btrfs" ] - then - set_btrfs - fi + while read -r device mountpoint fstype options dump pass; do + if [ "$mountpoint" = "/" ] && [ "$fstype" = "btrfs"]; then + set_btrfs + break + fi + done < /proc/mounts } set_btrfs () {