How to Disable HDD Spin Down and Head Parking in FreeBSD: A Complete Guide to ATA APM and EPC Management


3 views

Modern HDDs implement power management through three primary ATA features:

  • APM (Advanced Power Management): Controls spin down timing (0-255 scale)
  • EPC (Extended Power Conditions): Modern alternative to APM with finer control
  • Standby Timer: Built-in firmware timeout that overrides OS settings

Since FreeBSD 11, the primary interface is camcontrol:

# List all disks
camcontrol devlist

# Check current APM settings (replace da0 with your disk)
camcontrol cmd da0 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -

To permanently disable spin down:

# Set APM to maximum performance (disables spin down)
camcontrol apm da0 -l 254

# Verify the setting
camcontrol apm da0 -c

For drives supporting EPC (check with camcontrol identify da0 | grep EPC):

# Disable all power saving states
camcontrol epc da0 -d

# Set to max performance
camcontrol epc da0 -p max

Create /usr/local/etc/rc.local with:

#!/bin/sh
for disk in $(camcontrol devlist | awk '{print $NF}'); do
    camcontrol apm $disk -l 254
    camcontrol epc $disk -p max 2>/dev/null
done

Make it executable with chmod +x /usr/local/etc/rc.local

Some drives ignore OS settings. For these, use smartctl:

# Disable standby timer permanently
smartctl -s standby,0 /dev/da0

# Disable APM completely (may void warranty)
smartctl -l scterc,70,70 /dev/da0

To verify your settings:

# Check current power state
camcontrol cmd da0 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -

# Monitor disk activity
iostat -x da0 5

When running a FreeBSD file server with multiple HDDs, you might notice that disks spin down or park their heads after periods of inactivity. This behavior, while power-efficient, can cause performance degradation in server environments where constant disk availability is crucial. Unlike Linux's hdparm, FreeBSD requires a different approach.

The old solutions like ataidle and atacontrol are obsolete in current FreeBSD versions. Instead, we now use camcontrol and direct ATA commands through smartctl.

First, identify your disks:

camcontrol devlist

Then check current APM (Advanced Power Management) settings:

smartctl -i /dev/ada0 | grep -i "APM"

To completely disable spin down, set APM to maximum performance (255):

camcontrol apm ada0 -l 255

For multiple disks, use a script:

for disk in $(sysctl -n kern.disks | grep 'ada'); do
    camcontrol apm $disk -l 255
done

Some newer disks support EPC, which provides more granular power management. Check if your disk supports EPC:

smartctl -c /dev/ada0 | grep -i "EPC"

To disable EPC-based spin down:

smartctl -s epc,0 /dev/ada0

To make these settings persistent across reboots, add them to /etc/rc.local:

echo 'for disk in $(sysctl -n kern.disks | grep "ada"); do
    camcontrol apm $disk -l 255
    smartctl -s epc,0 /dev/$disk
done' >> /etc/rc.local

After applying changes, verify they're active:

smartctl -c /dev/ada0 | grep -A10 "Power Conditions"

Some disks may ignore APM settings but respect the standby timer. To disable it:

camcontrol standby ada0 -t 0
  • These settings may not work on all drives - some enterprise disks ignore host commands
  • Disabling spin down will increase power consumption
  • Monitor disk temperatures after making these changes