From 836af32a423cf5d49206aab687165fde610c6345 Mon Sep 17 00:00:00 2001 From: Thierry Laurion Date: Mon, 20 Jan 2025 12:14:42 -0500 Subject: [PATCH] BUGFIX >2tb drives: replace all fdisk -l calls with stderr suppression (workaround) Signed-off-by: Thierry Laurion --- initrd/bin/config-gui.sh | 4 ++-- initrd/bin/root-hashes-gui.sh | 2 +- initrd/etc/functions | 6 +++--- initrd/etc/gui_functions | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/initrd/bin/config-gui.sh b/initrd/bin/config-gui.sh index 2f411771..2531cd6e 100755 --- a/initrd/bin/config-gui.sh +++ b/initrd/bin/config-gui.sh @@ -113,7 +113,7 @@ while true; do ;; "b") CURRENT_OPTION="$(load_config_value CONFIG_BOOT_DEV)" - if ! fdisk -l | grep "Disk /dev/" | cut -f2 -d " " | cut -f1 -d ":" >/tmp/disklist.txt; then + if ! fdisk -l 2>/dev/null | grep "Disk /dev/" | cut -f2 -d " " | cut -f1 -d ":" >/tmp/disklist.txt; then whiptail_error --title 'ERROR: No bootable devices found' \ --msgbox " $ERROR\n\n" 0 80 exit 1 @@ -208,7 +208,7 @@ while true; do ;; "R") CURRENT_OPTION="$(load_config_value CONFIG_ROOT_DEV)" - fdisk -l | grep "Disk /dev/" | cut -f2 -d " " | cut -f1 -d ":" >/tmp/disklist.txt + fdisk -l 2>/dev/null | grep "Disk /dev/" | cut -f2 -d " " | cut -f1 -d ":" >/tmp/disklist.txt # filter out extraneous options >/tmp/root_device_list.txt for i in $(cat /tmp/disklist.txt); do diff --git a/initrd/bin/root-hashes-gui.sh b/initrd/bin/root-hashes-gui.sh index cd3c750d..67881f55 100755 --- a/initrd/bin/root-hashes-gui.sh +++ b/initrd/bin/root-hashes-gui.sh @@ -367,7 +367,7 @@ detect_root_device() fi # generate list of possible boot devices - fdisk -l | grep "Disk /dev/" | cut -f2 -d " " | cut -f1 -d ":" > /tmp/disklist + fdisk -l 2>/dev/null | grep "Disk /dev/" | cut -f2 -d " " | cut -f1 -d ":" > /tmp/disklist # filter out extraneous options > /tmp_root_device_list diff --git a/initrd/etc/functions b/initrd/etc/functions index 4bf449b0..e4a73508 100644 --- a/initrd/etc/functions +++ b/initrd/etc/functions @@ -645,7 +645,7 @@ device_has_partitions() { # This check covers that: [ $(fdisk -l "$b" | wc -l) -eq 5 ] # In both cases the output is 5 lines: 3 about device info, 1 empty line # and the 5th will be the table header or the invalid message. - local DISK_DATA=$(fdisk -l "$DEVICE") + local DISK_DATA=$(fdisk -l "$DEVICE" 2>/dev/null) if echo "$DISK_DATA" | grep -q "doesn't contain a valid partition table" || [ "$(echo "$DISK_DATA" | wc -l)" -eq 5 ]; then # No partition table @@ -1066,7 +1066,7 @@ is_gpt_bios_grub() { # Now we know the device and partition number, get the type. This is # specific to GPT disks, MBR disks are shown differently by fdisk. TRACE "$PART_DEV is partition $NUMBER of $DEVICE" - if [ "$(fdisk -l "/dev/$DEVICE" | awk '$1 == '"$NUMBER"' {print $5}')" == grub ]; then + if [ "$(fdisk -l "/dev/$DEVICE" 2>/dev/null | awk '$1 == '"$NUMBER"' {print $5}')" == grub ]; then return 0 fi return 1 @@ -1139,7 +1139,7 @@ detect_boot_device() { fi # generate list of possible boot devices - fdisk -l | grep "Disk /dev/" | cut -f2 -d " " | cut -f1 -d ":" >/tmp/disklist + fdisk -l 2>/dev/null | grep "Disk /dev/" | cut -f2 -d " " | cut -f1 -d ":" >/tmp/disklist # Check each possible boot device for i in $(cat /tmp/disklist); do diff --git a/initrd/etc/gui_functions b/initrd/etc/gui_functions index 38958b1a..3566cc2a 100755 --- a/initrd/etc/gui_functions +++ b/initrd/etc/gui_functions @@ -181,7 +181,7 @@ show_system_info() kernel=$(uname -s -r) whiptail_type $BG_COLOR_MAIN_MENU --title 'System Info' \ - --msgbox "${BOARD_NAME}\n\nFW_VER: ${FW_VER}\nKernel: ${kernel}\n\nCPU: ${cpustr}\nRAM: ${memtotal} GB\n$battery_status\n$(fdisk -l | grep -e '/dev/sd.:' -e '/dev/nvme.*:' | sed 's/B,.*/B/')" 0 80 + --msgbox "${BOARD_NAME}\n\nFW_VER: ${FW_VER}\nKernel: ${kernel}\n\nCPU: ${cpustr}\nRAM: ${memtotal} GB\n$battery_status\n$(fdisk -l 2>/dev/null | grep -e '/dev/sd.:' -e '/dev/nvme.*:' | sed 's/B,.*/B/')" 0 80 } # Get "Enable" or "Disable" to display in the configuration menu, based on a