initial working
This commit is contained in:
111
scripts/diagnose-vm-storage.sh
Executable file
111
scripts/diagnose-vm-storage.sh
Executable file
@@ -0,0 +1,111 @@
|
||||
#!/bin/bash
|
||||
# diagnose-vm-storage.sh
|
||||
# Script per identificare dove sono i dischi delle VM
|
||||
|
||||
VM_ID=${1:-201}
|
||||
|
||||
echo "=== VM Storage Diagnostic Tool ==="
|
||||
echo "VM ID: $VM_ID"
|
||||
echo ""
|
||||
|
||||
# Check se la VM esiste
|
||||
if ! qm status $VM_ID &>/dev/null; then
|
||||
echo "❌ VM $VM_ID does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✓ VM $VM_ID exists"
|
||||
echo ""
|
||||
|
||||
# Mostra configurazione completa
|
||||
echo "📋 VM Configuration:"
|
||||
qm config $VM_ID
|
||||
echo ""
|
||||
|
||||
# Estrai info disco
|
||||
echo "💾 Disk Information:"
|
||||
DISK_LINE=$(qm config $VM_ID | grep -E "^(scsi|ide|virtio|sata)0:")
|
||||
echo "$DISK_LINE"
|
||||
echo ""
|
||||
|
||||
# Parse disk info
|
||||
STORAGE=$(echo "$DISK_LINE" | cut -d: -f2 | cut -d, -f1 | xargs)
|
||||
echo "Storage location: $STORAGE"
|
||||
echo ""
|
||||
|
||||
# Check tipo di storage
|
||||
if [[ $STORAGE == local-lvm:* ]]; then
|
||||
echo "🔍 Storage type: LVM"
|
||||
DISK_NAME=$(echo $STORAGE | cut -d: -f2)
|
||||
LVM_PATH="/dev/pve/$DISK_NAME"
|
||||
|
||||
echo "Expected LVM path: $LVM_PATH"
|
||||
|
||||
if [ -e "$LVM_PATH" ]; then
|
||||
echo "✓ LVM volume exists"
|
||||
lvs | grep vm-$VM_ID
|
||||
else
|
||||
echo "❌ LVM volume NOT found"
|
||||
echo "Available LVM volumes:"
|
||||
lvs
|
||||
fi
|
||||
|
||||
elif [[ $STORAGE == local:* ]]; then
|
||||
echo "🔍 Storage type: Directory/File"
|
||||
DISK_NAME=$(echo $STORAGE | cut -d: -f2)
|
||||
FILE_PATH="/var/lib/vz/images/$VM_ID/"
|
||||
|
||||
echo "Expected file path: $FILE_PATH"
|
||||
|
||||
if [ -d "$FILE_PATH" ]; then
|
||||
echo "✓ Directory exists"
|
||||
ls -lh "$FILE_PATH"
|
||||
|
||||
# Identifica tipo di file
|
||||
for FILE in "$FILE_PATH"/*; do
|
||||
if [ -f "$FILE" ]; then
|
||||
echo ""
|
||||
echo "File: $FILE"
|
||||
file "$FILE"
|
||||
du -h "$FILE"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "❌ Directory NOT found"
|
||||
fi
|
||||
|
||||
else
|
||||
echo "🔍 Unknown storage type: $STORAGE"
|
||||
echo ""
|
||||
echo "Available storages:"
|
||||
pvesm status
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== All available storages ==="
|
||||
pvesm status
|
||||
|
||||
echo ""
|
||||
echo "=== Possible disk locations ==="
|
||||
echo "Checking common paths..."
|
||||
|
||||
# Check LVM
|
||||
echo "LVM volumes:"
|
||||
lvs 2>/dev/null | grep -E "vm-?$VM_ID" || echo " None found"
|
||||
|
||||
# Check file-based
|
||||
echo ""
|
||||
echo "File-based images:"
|
||||
ls -lh /var/lib/vz/images/$VM_ID/ 2>/dev/null || echo " /var/lib/vz/images/$VM_ID/ not found"
|
||||
|
||||
# Check other common locations
|
||||
for DIR in /var/lib/vz/images /mnt/pve/*; do
|
||||
if [ -d "$DIR/$VM_ID" ]; then
|
||||
echo ""
|
||||
echo "Found in: $DIR/$VM_ID/"
|
||||
ls -lh "$DIR/$VM_ID/"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "=== Diagnostic complete ==="
|
||||
Reference in New Issue
Block a user