gongxiangp2/check-truenas-iscsi.sh

74 lines
2.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 检查TrueNAS是否支持iSCSI的脚本
echo "=========================================="
echo "TrueNAS iSCSI支持检查"
echo "=========================================="
echo ""
# 检查iSCSI服务
echo "🔍 检查iSCSI服务..."
if systemctl list-units | grep -q "iscsi"; then
echo "✅ 找到iSCSI相关服务"
systemctl list-units | grep iscsi
else
echo "❌ 未找到iSCSI服务"
fi
echo ""
# 检查iSCSI工具
echo "🔍 检查iSCSI工具..."
if command -v targetcli &> /dev/null; then
echo "✅ targetcli可用"
targetcli --version 2>&1 | head -1
elif command -v tgtadm &> /dev/null; then
echo "✅ tgtadm可用"
tgtadm --version 2>&1 | head -1
else
echo "❌ 未找到iSCSI工具"
fi
echo ""
# 检查iSCSI配置目录
echo "🔍 检查iSCSI配置..."
if [ -d "/etc/tgt" ] || [ -d "/etc/target" ] || [ -d "/sys/kernel/config/target" ]; then
echo "✅ 找到iSCSI配置目录"
ls -la /etc/tgt /etc/target /sys/kernel/config/target 2>/dev/null | head -10
else
echo "❌ 未找到iSCSI配置目录"
fi
echo ""
# 检查middleware配置
echo "🔍 检查TrueNAS middleware配置..."
if [ -d "/usr/share/truenas/middleware" ]; then
echo "✅ 找到middleware目录"
if find /usr/share/truenas/middleware -name "*iscsi*" 2>/dev/null | head -5; then
echo "✅ 找到iSCSI相关配置"
else
echo "⚠️ 未找到iSCSI相关配置"
fi
else
echo "❌ 未找到middleware目录"
fi
echo ""
# 检查Web界面API
echo "🔍 检查TrueNAS API..."
if curl -k -s -u root:$(cat /etc/freenas-v1.db 2>/dev/null | grep -i password | head -1 | cut -d: -f2) https://localhost/api/v2.0/iscsi 2>&1 | grep -q "iscsi"; then
echo "✅ iSCSI API可用"
else
echo "⚠️ 无法通过API检查(需要Web界面确认)"
fi
echo ""
echo "=========================================="
echo "检查完成"
echo "=========================================="
echo ""
echo "💡 建议:"
echo " 1. 登录TrueNAS Web界面"
echo " 2. 查看 Sharing → Block Shares (iSCSI)"
echo " 3. 如果存在iSCSI选项,说明支持iSCSI"
echo ""