From 99b66bddd02c7401cc10255de328fbbd95715799 Mon Sep 17 00:00:00 2001 From: "Oritorius(Denis Rykov)" Date: Thu, 10 Jul 2025 00:00:48 +0500 Subject: [PATCH] Update CHECK-IOMMU.sh feat(script): add IOMMU enablement check with kernel log analysis - Introduced check-iommu-enabled.sh to verify if IOMMU is enabled in the current system - Parses 'dmesg' output for common Intel (VT-d), AMD (SVM), and DMAR/IOMMU entries - Displays diagnostic result with a helpful recommendation if IOMMU is not active - Includes root privilege warning and user-friendly output with ANSI color codes - Useful for verifying virtualization passthrough readiness (e.g., PCIe, GPU) --- tools/CHECK-IOMMU.sh | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/tools/CHECK-IOMMU.sh b/tools/CHECK-IOMMU.sh index 453f2b7..a2bc5e5 100755 --- a/tools/CHECK-IOMMU.sh +++ b/tools/CHECK-IOMMU.sh @@ -1,16 +1,43 @@ #!/bin/bash # # Script: check-iommu-enabled.sh -# Goal: Check if IOMMU are Enabled in your system +# Goal: Check if IOMMU is enabled in the system # # Author: Gabriel Luchina -# https://luchina.com.br +# https://luchina.com.br # 20220128T1112 +# Updated: 2025-04-06 +# -if [ `dmesg | grep -e DMAR -e IOMMU | wc -l` -gt 0 ] -then - echo "IOMMU Enabled" -else - echo "IOMMU NOT Enabled" - echo "Check file /etc/default/grub contains 'intel_iommu=on' in 'GRUB_CMDLINE_LINUX_DEFAULT' line" +# ANSI Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + +# Check for root +if [ "$EUID" -ne 0 ]; then + echo -e "${YELLOW}Предупреждение: Рекомендуется запускать от root для полного доступа.${NC}" +fi + +echo "Checking if IOMMU is enabled..." + +# Check dmesg output for IOMMU-related messages +iommu_check=$(dmesg | grep -i -E 'iommu|DMAR|amd-vi') + +if [[ -n "$iommu_check" ]]; then + echo -e "${GREEN}✅ IOMMU активирован в ядре!${NC}" + echo + echo "Найденные записи:" + echo "$iommu_check" +else + echo -e "${RED}❌ IOMMU не обнаружен или выключен.${NC}" + echo + echo -e "${YELLOW}Возможные причины:${NC}" + echo "1. В BIOS/UEFI отключена поддержка IOMMU (SVM Mode для AMD / VT-d для Intel)" + echo "2. Не добавлен параметр загрузки ядра:" + echo " Для Intel: intel_iommu=on" + echo " Для AMD: amd_iommu=on" + echo " Добавьте их в GRUB_CMDLINE_LINUX_DEFAULT в /etc/default/grub" + echo " Затем выполните: update-grub" fi