使用 hd-idle / hdparm 设置 noatime 和驱动器空闲时间后,zfs 池在启动时不可用

使用 hd-idle / hdparm 设置 noatime 和驱动器空闲时间后,zfs 池在启动时不可用

首先,我RHEL7-x64使用以下命令设置使 zfs 驱动器休眠,, 和。我相信hd-idle当问题开始时我首先尝试了。

我写了一个脚本idle_drives_enable来处理@rebootcrontab -e (在当前使用该方法的状态下hdparm,作为我的最新努力)

#!/bin/bash

# idle_drives_enable
# Sets idle times to drives, usually needed at boot

# Default idle time covers all drives, including zfs drives, unless otherwise specified
DEFAULT_IDLE_TIME=120;

# Root drive we want to increase a bit, so specify separately
ROOT_IDLE_TIME=360;

#------------------------------------------------------------------
# Using hd-idle
# @dependency sudo yum install hd-idle
#
## 120 seconds is 10 minutes, 360 is 30 minutes
## Set default idle time on all.
#/sbin/hd-idle -i $DEFAULT_IDLE_TIME;

## Set root drive idle time longer, incase doing work, dont want to continually be waking it up

## sdb is current root, but sometimes changes
##/sbin/hd-idle -a /dev/sdb

## Use uuid instead because it never changes.  Specifying the root partition is enough to trigger the whole drive.
#/sbin/hd-idle -a /dev/disk/by-uuid/bbc69fc6-12fa-499a-a0c6-e0f65e248ce2 -i $ROOT_IDLE_TIME;

#echo "/usr/local/bin/idle_drives_enable complete! Default idle time of $DEFAULT_IDLE_TIME seconds was set. Additionally, the root drive is set to idle after $ROOT_IDLE_TIME seconds.";


#------------------------------------------------------------------------
# hd-idle is not allowing wake, are these considered scsi??
# testing with hdparm instead

echo "executing /usr/local/bin/idle_drives_enable..."
echo "using hdparm"
echo "Here is the output of the current hdparm -C"
/sbin/hdparm -C /dev/sd?

echo "setting idle times now..."
/sbin/hdparm -q -S  $DEFAULT_IDLE_TIME -y /dev/sd?

echo "done settting idle times. to default idle time ($DEFAULT_IDLE_TIME seconds)."
echo "Here is the output of the current hdparm -C"
/sbin/hdparm -C /dev/sd?

echo "/usr/local/bin/idle_drives_enable complete!"

我设置了zfs道具,atime=off
我还为我的启动驱动器设置了仅/etc/fstab noatime包含root/ home xfs& 的swap道具。

这是唯一所做的改变。

第一次重新启动测试后,zfs池不再可用,并且这种情况仍在继续。

测试hdparm我发现它有相同的症状(zfs启动时没有)。我最终意识到它只是在启动时没有正确导入。如果我 zfs export 那时zfs import,池就恢复正常,并且睡眠处于空闲状态,并在访问池时重新唤醒工作正常在此刻。 (至少在使用时hdparm)。我在使用的时候还没有想到这一点hd-idle

有趣的是,我发现在 6 驱动器RaidZ2阵列上,当我访问某些文件夹时,只有某些驱动器会被唤醒,这非常酷。

我已采取措施尝试修复:

  • 打开zfs上的atime属性,没有修复,所以关闭。
  • 注释了 cron 作业,因此在启动时不会设置空闲时间。

我怀疑也许我hd-idle先尝试过,它有一些残留设置可能不起作用,需要重置。

关于在哪里查找 zfs 池在启动时不再可用的任何想法?

更新 最后,我认为我只是搞砸了 ZFS 的实现。这个脚本效果很好。如果其他人想休眠他们的驱动器,这就是我最终得到的结果。

#!/bin/bash                                                                                                                                     

# idle_drives_enable
# Sets idle times to drives, usually needed at boot

# Default idle time covers all drives, including zfs drives, unless otherwise specified
DEFAULT_IDLE_TIME=120;

# Root drive we want to increase a bit, so specify separately 
ROOT_IDLE_TIME=360;


#ALLDRIVELIST=("a" "b" "c" "d" "e" "f" "g");
#for DRIVE in "${ALLDRIVELIST[@]}";
#do
#    #/sbin/hdparm -C /dev/sd$DRIVE 
#     
#done

#------------------------------------------------------------------
# Using hd-idle 
# @dependency sudo yum install hd-idle
#
## 120 seconds is 10 minutes, 360 is 30 minutes
## Set default idle time on all.  
#/sbin/hd-idle -i $DEFAULT_IDLE_TIME;

## Set root drive idle time longer, incase doing work, dont want to continually be waking it up

## sdb is current root, but sometimes changes
##/sbin/hd-idle -a /dev/sdb

## Use uuid instead because it never changes.  Specifying the root partition is enough to trigger the whole drive. 
#/sbin/hd-idle -a /dev/disk/by-uuid/bbc69fc6-12fa-499a-a0c6-e0f65e248ce2 -i $ROOT_IDLE_TIME;

#echo "/usr/local/bin/idle_drives_enable complete! Default idle time of $DEFAULT_IDLE_TIME seconds was set. Additionally, the root drive is set to idle after $ROOT_IDLE_TIME seconds.";


#------------------------------------------------------------------------
# hd-idle is not allowing wake, are these considered scsi??
# testing with hdparm instead

echo "executing /usr/local/bin/idle_drives_enable..."
echo "using hdparm"
echo "Here is the output of the current hdparm -C"
/sbin/hdparm -C /dev/sd?

echo "setting idle times now..."
/sbin/hdparm -q -S  $DEFAULT_IDLE_TIME -y /dev/sd?

echo "done settting idle times. to default idle time ($DEFAULT_IDLE_TIME seconds)."
echo "Here is the output of the current hdparm -C"
/sbin/hdparm -C /dev/sd?

echo "/usr/local/bin/idle_drives_enable complete!"

相关内容