收起左侧

使用硬盘柜无法读取健康信息

3
回复
297
查看
[ 复制链接 ]

1

主题

1

回帖

0

牛值

江湖小虾

2025-5-22 17:59:52 显示全部楼层 阅读模式

设备环境:极摩客M5小主机(amd 5700u,32g) PVE安装飞牛0.9.2,USB直通 奥睿科 9558RU3阵列柜(JMS567+JMS575),clear模式,

BUG现象:无法读取硬盘健康信息,提示不支持检测,命令行 smartctl -a /dev/sda -d sat 可读取smart信息

出现频率:必现

联系方式:472群Leon

日志文件:无

无标题.jpg

收藏
送赞
分享

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

1

主题

1

回帖

0

牛值

江湖小虾

2025-5-26 09:50:35 楼主 显示全部楼层

求回复,这类问题有没有自行处理的方案啊?

55

主题

9167

回帖

0

牛值

管理员

2025-5-26 15:08:37 显示全部楼层
可能是硬件兼容问题,这个我们提报一下,技术看看

0

主题

2

回帖

0

牛值

江湖小虾

我的也是这个硬盘柜,目前只能写了个定时脚本来执行mad

#!/bin/bash

# 智能USB硬盘健康检查脚本
# 自动检测可用设备并检查健康状态

# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'

echo -e "${BLUE}智能USB硬盘健康检查工具${NC}"
echo "================================"

# 自动检测可用设备
echo "正在检测可用设备..."
available_devices=()

for device in /dev/sd[a-z]; do
    if [ -b "$device" ]; then
        echo -n "检测 $device: "
        # 尝试获取设备信息,即使返回码不为0
        smart_output=$(sudo smartctl -i "$device" -d sat 2>&1)
        if echo "$smart_output" | grep -q "Device Model:"; then
            model=$(echo "$smart_output" | grep "Device Model:" | cut -d: -f2 | xargs)
            if [ -n "$model" ]; then
                echo -e "${GREEN}可用${NC} (型号: $model)"
                available_devices+=("$device")
            else
                echo -e "${YELLOW}无法获取型号${NC}"
            fi
        else
            echo -e "${RED}无法访问${NC}"
        fi
    fi
done

echo ""
if [ ${#available_devices[@]} -eq 0 ]; then
    echo -e "${RED}未找到可用的硬盘设备${NC}"
    echo ""
    echo "可能的原因:"
    echo "1. USB硬盘未连接"
    echo "2. 设备名称不是 /dev/sd*"
    echo "3. 需要不同的smartctl参数"
    echo "4. 权限问题"
    echo ""
    echo "请运行以下命令进行详细诊断:"
    echo "sudo ./device_check.sh"
    exit 1
fi

echo -e "${GREEN}找到 ${#available_devices[@]} 个可用设备${NC}"
echo ""

# 检查每个可用设备
for device in "${available_devices[@]}"; do
    echo -e "\n${BLUE}检查设备: $device${NC}"
    echo "----------------------------------------"
  
    # 获取SMART状态
    echo "获取SMART数据..."
    smart_output=$(sudo smartctl -a "$device" -d sat 2>&1)
  
    if [ -z "$smart_output" ] || ! echo "$smart_output" | grep -q "Device Model:"; then
        echo -e "${RED}无法获取 $device 的SMART数据${NC}"
        continue
    fi
  
    # 提取基本信息
    model=$(echo "$smart_output" | grep "Device Model:" | cut -d: -f2 | xargs)
    serial=$(echo "$smart_output" | grep "Serial Number:" | cut -d: -f2 | xargs)
    smart_status=$(echo "$smart_output" | grep "SMART overall-health self-assessment test result:" | cut -d: -f2 | xargs)
  
    echo "型号: $model"
    echo "序列号: $serial"
    echo -n "SMART状态: "
  
    if [ "$smart_status" = "PASSED" ]; then
        echo -e "${GREEN}PASSED${NC}"
    else
        echo -e "${RED}FAILED${NC}"
    fi
  
    # 提取关键指标
    echo "关键指标:"
  
    # 重分配扇区
    realloc=$(echo "$smart_output" | grep "Reallocated_Sector_Ct" | awk '{print $10}')
    if [ "$realloc" = "0" ] || [ -z "$realloc" ]; then
        echo -e "  重分配扇区: ${GREEN}0${NC}"
    else
        echo -e "  重分配扇区: ${RED}$realloc${NC}"
    fi
  
    # 待处理扇区
    pending=$(echo "$smart_output" | grep "Current_Pending_Sector" | awk '{print $10}')
    if [ "$pending" = "0" ] || [ -z "$pending" ]; then
        echo -e "  待处理扇区: ${GREEN}0${NC}"
    else
        echo -e "  待处理扇区: ${RED}$pending${NC}"
    fi
  
    # 不可纠正扇区
    uncorrectable=$(echo "$smart_output" | grep "Offline_Uncorrectable" | awk '{print $10}')
    if [ "$uncorrectable" = "0" ] || [ -z "$uncorrectable" ]; then
        echo -e "  不可纠正扇区: ${GREEN}0${NC}"
    else
        echo -e "  不可纠正扇区: ${RED}$uncorrectable${NC}"
    fi
  
    # 温度
    temp_line=$(echo "$smart_output" | grep "Temperature_Celsius")
    if [ -n "$temp_line" ]; then
        temp_raw=$(echo "$temp_line" | awk '{print $10}' | sed 's/(.*//')
        if [[ "$temp_raw" =~ ^[0-9]+$ ]] && [ "$temp_raw" -ge 0 ] 2>/dev/null; then
            if [ "$temp_raw" -le 45 ]; then
                echo -e "  温度: ${GREEN}${temp_raw}°C${NC}"
            elif [ "$temp_raw" -le 50 ]; then
                echo -e "  温度: ${YELLOW}${temp_raw}°C${NC}"
            else
                echo -e "  温度: ${RED}${temp_raw}°C${NC}"
            fi
        else
            echo -e "  温度: ${YELLOW}无法解析${NC}"
        fi
    else
        echo -e "  温度: ${YELLOW}未找到${NC}"
    fi
  
    # 使用时间
    power_line=$(echo "$smart_output" | grep "Power_On_Hours")
    if [ -n "$power_line" ]; then
        power_hours_raw=$(echo "$power_line" | awk '{print $10}')
        if [[ "$power_hours_raw" =~ ^[0-9]+$ ]] && [ "$power_hours_raw" -gt 0 ] 2>/dev/null; then
            years=$((power_hours_raw / 8760))
            if [ "$years" -le 3 ]; then
                echo -e "  使用时间: ${GREEN}${years}年${NC}"
            elif [ "$years" -le 5 ]; then
                echo -e "  使用时间: ${YELLOW}${years}年${NC}"
            else
                echo -e "  使用时间: ${RED}${years}年${NC}"
            fi
        else
            echo -e "  使用时间: ${YELLOW}无法获取${NC}"
        fi
    else
        echo -e "  使用时间: ${YELLOW}未找到${NC}"
    fi
  
    # UDMA CRC错误
    crc_line=$(echo "$smart_output" | grep "UDMA_CRC_Error_Count")
    if [ -n "$crc_line" ]; then
        crc_errors_raw=$(echo "$crc_line" | awk '{print $10}')
        if [[ "$crc_errors_raw" =~ ^[0-9]+$ ]] && [ "$crc_errors_raw" -ge 0 ] 2>/dev/null; then
            if [ "$crc_errors_raw" -le 10 ]; then
                echo -e "  UDMA CRC错误: ${GREEN}$crc_errors_raw${NC}"
            else
                echo -e "  UDMA CRC错误: ${YELLOW}$crc_errors_raw${NC}"
            fi
        else
            echo -e "  UDMA CRC错误: ${YELLOW}无法获取${NC}"
        fi
    else
        echo -e "  UDMA CRC错误: ${YELLOW}未找到${NC}"
    fi
  
    # 健康评估
    echo -n "健康评估: "
    if [ "$smart_status" = "PASSED" ] && [ "$realloc" = "0" ] && [ "$pending" = "0" ] && [ "$uncorrectable" = "0" ]; then
        echo -e "${GREEN}健康${NC}"
    elif [ "$smart_status" = "PASSED" ]; then
        echo -e "${YELLOW}需要注意${NC}"
    else
        echo -e "${RED}有问题${NC}"
    fi
  
    echo "----------------------------------------"
done

echo -e "\n${BLUE}检查完成${NC}"
echo "提示:"
echo "  - 绿色: 正常"
echo "  - **: 需要注意"
echo "  - 红色: 有问题"
echo ""
echo "建议定期运行此脚本监控硬盘健康状况" 
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则