Update disk-passthrough.sh

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

View File

@ -173,19 +173,15 @@ while read -r DISK; do
USED_BY="" USED_BY=""
REAL_PATH=$(readlink -f "$DISK") CONFIG_DATA=$(cat /etc/pve/qemu-server/*.conf /etc/pve/lxc/*.conf 2>/dev/null)
# Buscar el disco por su ruta real y por su symlink /by-id (si lo tiene) if grep -Fq "$DISK" <<< "$CONFIG_DATA"; 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]"
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 fi
if $IS_RAID && grep -q "$DISK" <<< "$(cat /proc/mdstat)"; then if $IS_RAID && grep -q "$DISK" <<< "$(cat /proc/mdstat)"; then
if grep -q "active raid" /proc/mdstat; then if grep -q "active raid" /proc/mdstat; then
SHOW_DISK=false SHOW_DISK=false