From cad39d44992582fadd043462a6c52e7e11537724 Mon Sep 17 00:00:00 2001 From: MacRimi <123239993+MacRimi@users.noreply.github.com> Date: Tue, 8 Apr 2025 09:37:53 +0200 Subject: [PATCH] Update disk-passthrough.sh --- scripts/disk-passthrough.sh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/scripts/disk-passthrough.sh b/scripts/disk-passthrough.sh index 830f04b..b127283 100644 --- a/scripts/disk-passthrough.sh +++ b/scripts/disk-passthrough.sh @@ -172,17 +172,13 @@ while read -r DISK; do -USED_BY="" -REAL_PATH=$(readlink -f "$DISK") + USED_BY="" + CONFIG_DATA=$(cat /etc/pve/qemu-server/*.conf /etc/pve/lxc/*.conf 2>/dev/null) + + if grep -Fq "$DISK" <<< "$CONFIG_DATA"; then + USED_BY="[in use ct or vm]" + fi -# Buscar el disco por su ruta real y por su symlink /by-id (si lo tiene) -DISK_BYID=$(find /dev/disk/by-id/ -xtype l -exec bash -c 'readlink -f "$1"' _ {} \; | grep -F "$REAL_PATH" | head -n1) - -CONFIG_DUMP=$(find /etc/pve/qemu-server /etc/pve/lxc -type f -exec cat {} + 2>/dev/null) - -if grep -qF "$REAL_PATH" <<< "$CONFIG_DUMP" || [[ -n "$DISK_BYID" && "$CONFIG_DUMP" == *"$DISK_BYID"* ]]; then - USED_BY="[en uso]" -fi