Update disk-passthrough.sh

This commit is contained in:
MacRimi 2025-04-08 09:20:47 +02:00 committed by GitHub
parent ae1bd16f07
commit 81952226bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -172,11 +172,17 @@ while read -r DISK; do
USED_BY=""
REAL_PATH=$(readlink -f "$DISK")
USED_BY="" # Buscar el disco por su ruta real y por su symlink /by-id (si lo tiene)
if grep -q "$DISK" <(find /etc/pve/qemu-server /etc/pve/lxc -type f -exec cat {} +); then DISK_BYID=$(find /dev/disk/by-id/ -xtype l -exec bash -c 'readlink -f "$1"' _ {} \; | grep -F "$REAL_PATH" | head -n1)
USED_BY="[in use ct or vm]"
fi 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