FreeBSD: Disable APM in disk (to avoid load/unload heads)


Laptop drive’s live is limited. One parameter that reflects how old your disk is the load_cycle_count. It can be read using the command ‘smartctl’ available in the ‘smartmontools’ port.

To install this port:


cd /usr/ports/sysutils/smartmontools
make install
make clean

Then see the load_cycle_count parameter with:


smartctl -d atacam -A -T permissive /dev/ada0

Note that you maybe need to change the command for your disk. The command is slightly different in NetBSD (smartctl -A -d ata -s on /dev/rwd0d).

So, you probably get something like:


=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000b 100 100 062 Pre-fail Always – 0
2 Throughput_Performance 0x0005 100 100 040 Pre-fail Offline – 0
3 Spin_Up_Time 0x0007 241 241 033 Pre-fail Always – 1
4 Start_Stop_Count 0x0012 100 100 000 Old_age Always – 53
5 Reallocated_Sector_Ct 0x0033 100 100 005 Pre-fail Always – 0
7 Seek_Error_Rate 0x000b 100 100 067 Pre-fail Always – 0
8 Seek_Time_Performance 0x0005 100 100 040 Pre-fail Offline – 0
9 Power_On_Hours 0x0012 100 100 000 Old_age Always – 96
10 Spin_Retry_Count 0x0013 100 100 060 Pre-fail Always – 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always – 47
191 G-Sense_Error_Rate 0x000a 100 100 000 Old_age Always – 0
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always – 28
193 Load_Cycle_Count 0x0012 100 100 000 Old_age Always – 6211
194 Temperature_Celsius 0x0002 171 171 000 Old_age Always – 32 (Lifetime Min/Max 18/39)
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always – 0
197 Current_Pending_Sector 0x0022 100 100 000 Old_age Always – 0
198 Offline_Uncorrectable 0x0008 100 100 000 Old_age Offline – 0
199 UDMA_CRC_Error_Count 0x000a 200 200 000 Old_age Always – 0
223 Load_Retry_Count 0x000a 100 100 000 Old_age Always – 0

In this case, Load_Cycle_Count=6211.

If you prefer your disk spin down to save power, or because it’s noisy, well, probably you don’t need do nothing. Or you can play with ‘ataidle’ to adjust timers for idle, standby, sleep.

In my case, to avoid my disk get older quickly I prefer to disable APM (Advanced Power Management) in the disk. This make the disk never spin down.

In order to do this I had to add some commands to ‘/etc/rc.local’ (for boot) and ‘/etc/rc.resume’ (it’s necessary to configure it again after resume). So simply add in both files:


#Disable APM in disk
/sbin/camcontrol cmd ada0 -a “EF 85 00 00 00 00 00 00 00 00 00 00”

About jjjesss

I'm a guy interested in technology, bsd fan and concerned about the world around.
This entry was posted in FreeBSD. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s