FreeBSD에서 하드 디스크 스핀 다운이나 헤드 파킹을 어떻게 비활성화합니까?
HDD가 여러 개인 새로운 FreeBSD 파일 서버를 구축했습니다. 디스크에 잠시 액세스하지 않으면 디스크가 완전히 회전하거나 헤드가 파킹됩니다. HDD 스핀 다운 또는 헤드 파킹을 비활성화하려면 어떻게합니까? Linux에서는를 통해 할 수 있다는 것을 알고 hdparm
있지만 FreeBSD는 어떻습니까?
노트 :
AFAIK, 이것은 중복 질문이 아닙니다. serverfault.com에서 "HDD 스핀 다운"에 대한 검색 결과의 99 %는 Linux 전용입니다. serverfault.com에서 유일한 "HDD 스핀 다운"관련 질문 은 타이머에서 하드 드라이브를 대기 (스핀 다운)하는 방법입니다. , 질문에 대답하지 않고 2018-12-31 이후로 사용되지 않는 ataidle 을 사용합니다. 다른 후보로는 FreeNAS가 디스크를 스핀 다운하는 방법이 있습니다. -질문에 대답하지 않거나 디스크가 절전 상태인지 확인 (FreeNAS) -사용
atacontrol
, FreeBSD 11 이후 제거됨.Google 또는 DuckDuckGo에서 "freebsd spin down hard disk"의 검색 결과는 대부분 forums.freebsd.org의 오래된 포럼 게시물 또는 다른 곳의 자습서로 구성되어 있으며 모두 현재 사용되지 않는 도구
ataidle
나atacontrol
도구에 대한 제안이 포함되어 있습니다. 또한 ATA 대기 모드와 APM의 관계를 설명하는 게시물은 없으며 확장 전원 상태에 대한 설명도 없습니다 .
따라서 ATA 대기, APM 및 EPC에 대한 자세한 설명이 포함 된 참조 질문 "FreeBSD에서 하드 디스크 스핀 다운 또는 헤드 파킹을 비활성화하는 방법"이 커뮤니티에 유용한 목적이 될 것이며 검색을 통해 오는 독자에게 도움이 될 것이라고 생각합니다. 엔진.
답변
FreeBSD 12에서는 camcontrol
스핀 다운 및 하드 파킹을 포함하여 HDD 전원 관리를 제어하는 데 사용됩니다. 이전에 ataidle
또는 atacontrol
사용되었지만 해당 기능이 이미에 병합되어 camcontrol
더 이상 사용되지 않으며 더 이상 지원되지 않습니다.
TL; DR
재부팅 할 때마다이 명령을 실행해야합니다. 예를 들어 /etc/rc.local
.
자동 스핀 다운 비활성화
"대기"타이머를 0
초로 설정하고 APM을 이상으로 128
설정 한 다음 EPC "standby_z"타이머를 비활성화합니다. ada1
하드 드라이브 로 변경 하는 것을 잊지 마십시오 .
# ATA has a "Standby" timer, but there's no "Idle" timer. The time
# `-t` is for standby timer.
# XXX: This command put the disk to Idle immediately, even if we only
# want to program a timer, there is no way to do that otherwise.
# But it's only a one-time event on boot, it shouldn't matter.
camcontrol idle ada1 -t 0
# Enable APM should automatically disable EPC. If "camcontrol apm"
# succeeds but "camcontrol epc" fails, it's safe to ignore. Vice versa,
# if "camcontrol epc" succeeds but "camcontrol apm" fails, it's also
# safe to ignore.
camcontrol apm ada1 -l 128
camcontrol epc ada1 -c state -d -p standby_z
이것은 대부분의 사람들에게 충분할 것입니다.
자동 스핀 다운 및 헤드 파킹 비활성화
"대기"타이머를 0
초로 설정하고 APM을 비활성화하고 EPC를 비활성화합니다.
이것은 본질적으로 모든 전원 관리를 비활성화합니다. 하드 드라이브가 EPC를 지원하는 경우 모든 전원 관리를 맹목적으로 비활성화하는 대신 아래의 EPC 솔루션 (계속 읽으십시오)을 사용하는 것이 좋습니다. 또한 SMART에서 로드 / 언로드주기 수가 과도하게 증가 하지 않는 경우 필요하지 않을 수 있으며 스핀 다운을 비활성화하는 것으로 충분합니다.
# There is a "Standby" timer, but there is no
# "Idle" timer. Actually both "standby -t" and
# "idle -t" program the same "Standby" timer.
camcontrol idle ada1 -t 0
# not specify a number = disable apm
camcontrol apm ada1
# EPC is not necessaily supported, it can fail
camcontrol epc ada1 -c disable
마지막으로 헤드 파킹을 비활성화하는 보장 된 방법은 없으며 궁극적으로 공급 업체 및 모델 별 동작입니다. 우리가 시도 할 수있는 최선의 방법은 가능한 한 많은 전원 관리를 비활성화하는 것입니다. 일반적으로 작동하지만 특히 문제가있는 일부 하드 드라이브 모델 (예 : WD Green)에는 영향을 미치지 않습니다. 이를 저장하는 유일한 방법은이 답변의 범위를 벗어난 공급 업체별 도구를 사용하는 것입니다.
EPC를 통한 자동 스핀 다운 또는 헤드 파킹 비활성화
하드 드라이브가 EPC를 지원하는 경우 아래의 EPC 솔루션 (계속 읽기)을 사용하여 스핀 다운 또는 헤드 파킹을 비활성화하는 것이 좋습니다. HDD가 회전하지 않도록하려면을 비활성화하십시오 standby_z
. 주차, 사용 안 함에서 하드 디스크 드라이브를 방지하기 위해 Idle_b
, Idle_c
하고 standby_y
.
먼저 HDD가 EPC를 지원하는지 확인하십시오.
# check whether EPC is supported
camcontrol identify ada1 | grep "Feature\|extended power conditions"
# see the current EPC power state
camcontrol epc ada1 -c status
EPC를 통해 스핀 다운을 활성화 및 비활성화하려면 ...
# disable APM first, and enable EPC.
# APM can fail if the HDD only support EPC, which is okay.
camcontrol apm ada1
camcontrol epc ada1 -c enable
# disable spin-down (Standby_z) via EPC
camcontrol epc ada1 -c state -d -p standby_z
# just in case, also disable the Standby timer
camcontrol idle ada1 -t 0
### Optional: disable head parking ###
# disable head parking (Idle_b, Idle_c, Standby_y)
camcontrol epc ada1 -c state -d -p idle_b
camcontrol epc ada1 -c state -d -p idle_c
camcontrol epc ada1 -c state -d -p standby_y
문제 해결
HDD가 APM을 지원하지 않는 경우 다음 오류가 발생합니다. HDD가 EPC 만 지원하는 경우 EPC를 사용하고이 오류를 무시할 수 있습니다.
camcontrol: ATA SETFEATURES ENABLE APM failed
HDD가 EPC를 지원하지 않는 경우 (또는 EPC가 이미 완전히 비활성화 된 경우, 예를 들어 APM을 활성화하면 EPC가 자동으로 비활성화 됨) APM을 사용하고이 오류를 무시할 수 있습니다.
SETFEATURES EXTENDED POWER CONDITIONS. ACB: ef 4a 03 00 00 40 00 00 00 00 00 00
CAM status: ATA Status Error
ATA status: 51 (DRDY SERV ERR), error: 04 (ABRT )
RES: 51 04 00 00 00 00 00 00 00 00 00
하드 디스크 스핀 다운을 비활성화 할 수 없거나 대기 / 유휴 타이머, APM 또는 EPC 설정에 관계없이 헤드 파킹을 비활성화 할 수없는 경우 불행히도 공급 업체별 도구 만 도움이 될 수 있습니다. 이 답변의 범위를 벗어납니다.
설명
이러한 명령의 의미를 이해하려면 잠시 멈추고 기술적 배경을 배워야합니다. 사실, HDD 전원 관리는 엉망입니다. 기본 ATA 명령 세트 2 (ATA8-ACS2) , 고급 전원 관리 (APM) 및 확장 전원 조건 (EPC)의 세 가지 독립적 인 메커니즘에 의해 제어됩니다 . 또한 일부 Seagate 및 WD Green 드라이브에서 발견 된 공급 업체 독점 기능을 계산하면 총 4 개의 메커니즘이 있지만이 답변의 범위를 벗어납니다.
예상 된 결과를 얻으려면 이러한 각 메커니즘을 올바르게 구성해야합니다. 예를 들어 디스크 대기 타이머가 ATA 명령 집합을 통해 비활성화 되었지만 APM 이 여전히 128보다 낮은 값으로 설정되어있는 경우 디스크는 여전히 스핀 다운됩니다. 문제를 복잡하게하기 위해 모든 하드 드라이브가 이러한 메커니즘을 모두 지원하는 것은 아닙니다. 예를 들어, 일부 엔터프라이즈 급 HDD는 APM을 지원하지 않고 EPC를 독점적으로 사용합니다. 또한 EPC를 지원하지만 비활성화하는 HDD도 있습니다. 기본값은 APM이며 일부 이전 세대의 HDD와 많은 소비자 용 HDD는 지원하지 않습니다. t는 EPC를 전혀 지원하지 않습니다.
원하는 설정을 얻으려면 각 전원 관리 메커니즘을 올바르게 구성해야합니다.
ATA 명령 세트 2 (ATA8-ACS2)
The ATA Command Set 2 specification supports basic power management. It defines four power states in ATA drives and a Standby timer.
Active–The device is fully powered up and ready to send/receive data.
Idle–The device is capable of responding to commands but the device may take longer to complete commands than when in the Activemode. Power consumption of the device in this state is lower than that of Active mode. If a hard drive is present, it is spun up.
Standby–The device is capable of responding to commands but the device may take longer (up to 30 seconds) to complete commands than in the Idle mode. Power consumption is reduced from that of Idle mode. If a hard drive is present, it is spun down.
Sleep–This is the lowest power mode. The device interface is typically inactive and, if a hard drive is present, the drive is spun down. The device will exit the Sleep mode only after receiving a reset. Wakeup time can be as long as 30 seconds.
Source: SATA Power Management: It’s Good to Be Green
In other words, Standby causes the hard drive to spin down, and Idle is a low-power mode without no spin down. Since the standard doesn't say what a hard drive should do in Idle mode, it's vendor-specific behavior. For an educated guess, it could allow the HDD to spin at a reduced speed, or to also park its head. Finally, Sleep should never be used, unless you're going to remove the HDD or shut down the system.
Only the Standby timer can be disabled by setting it to 0
seconds. The Idle state is not controlled by a timer, and cannot be disabled.
Alternatively, you can also set the Standby timer to the number you want, however, the encoding of the timer is really strange!

A concise summary can be found from hdparm
's man page:
Values from 1 to 240 specify multiples of 5 seconds, yielding timeouts from 5 seconds to 20 minutes. Values from 241 to 251 specify from 1 to 11 units of 30 minutes, yielding timeouts from 30 minutes to 5.5 hours. A value of 252 signifies a timeout of 21 minutes. A value of 253 sets a vendor-defined timeout period between 8 and 12 hours, and the value 254 is reserved. 255 is interpreted as 21 minutes plus 15 seconds. Note that some older drives may have very different interpretations of these values.
On FreeBSD,
# check whether ATA power management is supported
# don't omit "^", or you'll get "advanced power management"
camcontrol identify ada1 | grep "Feature\|^power management"
# set standby timer, 0 to disable
camcontrol idle ada1 -t 0
# "idle -t 0" is equivalent to "standby -t 0", it set the same
# "Standby" timer, but without forcing the device to standby,
# only to "idle", which allows a quicker recovery. There is
# no way to set the timer without actually send an "idle"
# or "standby" command.
camcontrol idle ada1 -t 0
However, the devil is in the detail. There is no guaranteed way to disable either "Standby" or "Idle" states. First, as previously stated, there is no timer for "Idle", only a timer for "Standby". Thus, if the HDD vendor decides to enter Idle aggressively, and if Idle mode implies a head parking, you are out of luck without EPC. For example, some WD Green hard drives are known to perform head parking aggressively.
Also, HDDs are allowed to enter "Idle" or "Standby" by itself without host intervention.
PM1: Idle: This state shall be entered when the device receives an IDLE command or IDLE IMMEDIATE command. Some devices may perform vendor specific internal power management and transition to the Idle mode without host intervention. [...]
PM2: Standby: This state shall be entered when:
- h) a device performs a vendor specific power management function;
Source: ATA/ATAPI Command Set - 2 (ACS-2)
Thus, if the HDD vendor decides to enter Standby aggressively, You're also out of luck.
Advanced Power Management (APM)
Advanced Power Management (APM) is a power management mechanism for personal computers standardized in the late 90s. It has long been superseded by ACPI, however, it's still used in HDD power management and is supported by almost all hard drives. It's unsupported only in some enterprise-grade hard drives.
The APM level is a scale from the lowest power consumption setting of 01h to the maximum performance level of FEh. Table 120 shows these values.Device performance may increase with increasing APM levels. Device power consumption may increase with increasing power management levels. The APM levels may contain discrete bands (e.g., a device may implement one APM method from 80h to A0h and a higher performance, higher power consumption method from level A1h to FEh). APM levels 80h and higher do not permit the device to spin down to save power.Subcommand code 85h disables APM. Subcommand 85h may not be implemented on all devices that implement SET FEATURES subcommand 05h.
Table 120: APM levels
- 00h (0): Reserved
- 01h (1): Minimum power consumption with Standby
- 02h-7Fh (2-127): Intermediate power management levels with Standby
- 80h (128): Minimum power consumption without Standby
- 81h-FDh (129-254): Intermediate power management levels without Standby
- FEh (254): Maximum performance
- FFh (255): Reserved
APM is independent of the Standby timer. If both APM and the Standby timer are set, then the device shall go to the Standby state when the timer expires or the device’s APM algorithm indicates that the Standby state should be entered.
Source: ATA/ATAPI Command Set - 2 (ACS-2)
The implementation of APM is not specified by the standard, thus it depends on the vendor and model of your hard drive. The only things we can be sure are that
"128" enables all power saving features without spinning down. Presumably, the HDD can spin at a reduced speed, or to park its head.
Usually, APM can be disabled. It's possible that speed reduction or head parking can be disabled if APM is disabled, but we cannot know for sure.
On some hard drives, APM cannot be disabled, alternatively, we can use "254", the maximum performance mode defined by APM.
In FreeBSD,
# check whether APM is supported
camcontrol identify ada1 | grep "Feature\|advanced power management"
# set APM level
camcontrol apm ada1 -l 128
# disable APM
camcontrol apm ada1
Extended Power Conditions (EPC)
This is the latest power management standard in hard drives, it's usually supported on enterprise-grade hard drives (some newer hard drives don't support APM, EPC is used exclusively). Seagate markets EPC as PowerChoice™ Technology.
It offers the more fine-tuned power management levels, more specific than the basic Idle, Standby states in the standard ATA command set. It defines 2 power states and 5 power conditions.
- PM1: Idle state
Idle_a
- Disables some electronics.
- Discs rotating at full speed (7,200 RPM).
Idle_b
- Disables some electronics.
- Heads are unloaded to drive ramp.
- Discs rotating at full speed (7,200 RPM)
Idle_c
- Disables some electronics.
- Heads are unloaded to drive ramp.
- Drive speed reduced to a lower RPM (reduced RPM)
- PM2: Standby state
Standby_y
- Same as
Idle_c
in Seagate and HGST (now WD).Standby_z
- Heads are unloaded to drive ramp.
- Drive motor is spun down.
Source: * ATA/ATAPI Command Set - 2 (ACS-2) * Hard Drive for Low PowerEnergy Efficiency in Disk Storage by Hitachi * Seagate® PowerChoice™ Technology Provides Unprecedented Hard Drive Power Savings and Flexibility by Seagate * Ultrastar® DC HC620 Hard disk drive specifications by HGST/Western Digital.
Each power condition can be controlled by a timer, and they can also be enabled or disabled individually.
Note that the precise meaning of Idle_a
, Idle_b
, Idle_c
, Standby_y
, or Standby_z
is not specific in the standard at all! Again, it's up to HDD device manufecterer to implement them. I used the definition from the HGST/WD Ultrastar and Seagate datasheets. Make sure to check the full datasheet of your hard drive model!
It's clear to see that for our selected hard drives, disabling Standby_z
will prevent the HDD from spinning down, and disabling Idle_b
, Idle_c
and Standby_y
will prevent the head from being unloaded. Thus, if your HDD support EPC, it's recommended to use them.
Also, APM must be disabled first before using EPC.
The Extended Power Conditions feature set and the Advanced Power Management feature set are mutually exclusive. All EPC subcommands, except Enable the EPC feature set (see 7.49.18.6), shall return command aborted if the EPC feature set is disabled. If the device processes a SET FEATURES Enable APM subcommand without error and IDENTIFY DEVICE data word 120 bit 7 (see 7.17.7.41) is set to one, then the device shall disable the EPC feature set.
In FreeBSD,
# check whether EPC is supported
camcontrol identify ada1 | grep "Feature\|extended power conditions"
# see the current EPC power state
camcontrol epc ada1 -c status
# disable APM first
camcontrol apm ada1
# enable EPC
camcontrol epc ada1 -c enable
# disable spin-down (Standby_z)
camcontrol epc ada1 -c state -d -p standby_z
# disable head parking (Idle_b, Idle_c, Standby_y)
camcontrol epc ada1 -c state -d -p idle_b
camcontrol epc ada1 -c state -d -p idle_c
camcontrol epc ada1 -c state -d -p standby_y