Goal: Control head parking behaviour on WD Green Caviar hard drives to optimize power savings and lifetime in Linux-based NAS.
I recently bought a Western Digital Green drive (WD10EADS-00M2B0) for my Kurobox Pro and discovered that it made a constant clicking sound every x seconds. After doing some internet research, the clicking comes from the head parking feature of the WD Green drives. In order to conserve power, WD Green hard drives have a feature called "Intellipark" which unintelligently parks the drive's head after 8 seconds of inactivity. While this feature works great in USB enclosures, when used as the main drive on any operating system, the drive's head is frequently unparked due to filesystem synchronization mechanisms. This results in LLC (Load/Unload Cycles) counts of as high as 100 per hour. As WD Green hard drives are rated for 300000 cycles, the limit can be reached within months.
My KuroBox Pro idles most of the time, but over a period of 80 hours, the harddrive has racked up over 5000 LLC! This is unacceptable! Therefore I have come up with a simple solution which reduces the LLC count and at the same time makes use of Intellipark to save power when the disk is idle!
Most (well, all of the) Western Digital Green drives. To see if your drive is affected, use smartctl.
smartctl -a /dev/sda
Take Load_Cycle_Count and divide it by Power_On_Hours and if the value is > 50, your drive is affected.
From what I understand, some WD Green drives report a low LLC count but in reality still has this problem because those drives don't increment the LLC count (source). You must either listen to your drive closely for a click 8 seconds after the last disk activity or use a power meter to monitor changes to see if the drive is affected.
There are several solutions I have discovered to keep load/unload counts low.
Method 1: wdidle3.exe
There is a utility called wdidle3.exe which disables intellipark. This is probably the best solution to date. However, this also disables the WD power saving features (i.e. the "Green" part of the WD Green drives).
Method 2: Write a script which touches the hard drive every 7 seconds
By generating some write activity every 7 seconds we can prevent the drive from parking. This is like the wdidle3.exe program except it doesn't modify your firmware or voids your warranty.
Method 3: Laptop-mode minus the hard drive spindown
This alone works surprisingly well! Laptop-mode holds back write activity for up to 10 minutes (a tweakable setting) given there is no read activity. It is designed to optimize i/o for hard disk spindowns on laptops, however, we can take advantage of the same feature to optimize Intellipark usage. During the idle times, disk activity can be prevented for up to 10 minutes at a time causing only 1 unpark cycle per 10 minutes. Ofcourse, hard drive spindown should be disabled or your drives will spin down and spin up every 10 minutes to its death. While laptop-mode works best during idle activity, it is still easy to rack up cycles quickly during moderate usage.
wdantiparkd monitors for disk activity and keeps the drive unparked by writing to the disk every 7 seconds. When a period of read inactivity occurs, wdantiparkd switches off and allows laptop-mode to take over, allowing the disk to idle.
wdantiparkd runs in 3 states: ANTIPARK, PARKED and IDLE.
In the ANTIPARK state, wdantiparkd writes data to a file every 7 seconds, preventing the disk from parking its head. A timeout of 1 minute is set for ANTIPARK. If no read activity occurs during the timeout period (1 minute), then wdantiparkd switches to the PARKED state.
In the PARKED state, wdantiparkd stops writing data to the hard disk and allows laptop-mode to kick in. laptop-mode will cache write data for up to x minutes. This allows the hard drive's head to park and rest in idle state (thus adding 1 to the LLC). If the PARKED state is interrupted by any disk activity, wdantiparkd switches back into the ANTIPARK state but doubles the timeout (so if the previous timeout for ANTIPARK was 1 minute, it is set to 2 minutes). The timeout for PARKED is set to 5 minutes. If no disk activity occurs during the timeout period for PARKED, then wdantiparkd switches to the IDLE state.
In the IDLE state, wdantiparkd works exactly the same as in the PARKED state. However, if IDLE is interrupted by disk activity, then ANTIPARK state is restarted with the default timeout (1 minute). It may be possible to spindown disks in the IDLE state.
This software is currently being tested on my KuroBox PRO and has very good results!
(Mar 28, 2010) After running wdantiparkd v1.0-alpha2 since January, my LLC count is 11012, with power on hours 2032 (~84.7 days). This is 5.42 LLC/hour. Let's not forget I racked up the first 5000 LLC in the first 4 days I owned this drive. If we discard 4 days of data, then my LLC is 6012 LLC / 1936 hours = 3.11 LLC/hour. This is from low-moderate usage of the drive.
(Jan 9, 2010) Power usage on my KuroBox PRO measured with power meter. wdantiparkd in ANTIPARK: 12W, PARKED: 10W, IDLE: 10W (8W w/ disk spun down)
(Jan 8, 2010) wdantiparkd build dbffe5. I am currently using aggressive laptop-mode settings (1 hour write delay) to allow my hard disk to spin down. So far, during overnight and work hours (18 hours+) when there is no activity, my disks have idled for 1 hour intervals with disks spun down 50 minutes at a time and LLC incrementing 1-2 per hour. With moderate activity, I'm averaging an LLC count of 10-20 per hour. Heavy activities is no problem ofcourse. This system currently runs: Samba, AFP, lighttpd, cron, ntp, avahi, mediatomb. This is much better than 60 LLC per hour!
Source code - Github
wdantiparkd_1.0alpha2_armel.deb - Experimental build for Debian Lenny (armel)
First of all, optimize your system for laptop-mode. Stop daemons which tend to generate alot of disk activity, etc... Here's are some FAQ to help you do so:
Laptop Mode / Laptop Mode Tools FAQ
NSLU2-Linux FAQ / SpinDownUSBHarddisks
I recommend /etc/laptop-mode/laptop-mode.conf (in Debian) with the settings below.
Make sure you disable disk spindown (unless you really know what you're doing).
Make sure laptop-mode is running, you can check by running:
and you should get a non-zero value back.
Because wdantiparkd is still in testing, it just runs in the foreground. Use Ctrl+C to terminate. wdantiparkd is controlled via commandline parameters (because I dislike configuration files).
Quick start - Run /usr/sbin/wdantiparkd -v as non-root user.
Even better - Run with screen, i.e. screen /usr/sbin/wdantiparkd -v then you can detach and monitor the stats.
Run /usr/sbin/wdantiparkd -h for description of commandline parameters.
Edit /etc/default/wdantiparkd to run in daemon mode on startup.
Please ensure that the /tmp directory is mounted on the disk partition (and not tmpfs). wdantiparkd writes to a file in temp (/tmp/wdantiparkd.tmp) to keep the disk head from parking. You can change the location of the file using: /usr/sbin/wdantiparkd --temp-file=/path/to/file/on/sda/something
Ofcourse, it has not been proven that high LLC counts on these HDs will lead to premature failure, so whether this program is needed or not is still up in the air. Delayed writing features of laptop-mode could cause up to x minutes of data loss in an event of a power loss. Perhaps, some file performance issues while in ANTIPARK mode, but hey, you chose to buy a 5200rpm HD instead of a 7200rpm....
Does wdantiparkd support Windows or Mac OS X?
Only Linux is supported.
Can wdantiparkd run in daemon mode?
By using wdantiparkd -D wdantiparkd will run the background.
Can I run wdantiparkd on startup?
On Debian systems, changing the WDANTIPARKD_ENABLE parameter in /etc/default/wdantiparkd will start wdantiparkd on startup. You can use the /etc/init.d/wdantiparkd init script to start and stop wdantiparkd.
Why should I disable hard drive spin down?
Laptop-mode is configured to sync data every 10 minutes by default. Therefore, allowing your hard drives to spin up and down every 10 minutes will kill it faster than the LLC will. Read next FAQ though.
Is there a workaround for allowing the hard drive to spin down?
Yes there is. By extending the time laptop-mode syncs data, it is possible to spin your disks down but with an increased risk of data loss. For example, by using the settings in /etc/laptop-mode/latptop-mode.conf:
This setting will let your disk spin down after 10 minutes of inactivity and laptop-mode to hold back write activity to the disk for up to 1 hour instead of the default 10 minutes. This setting is more risky because in the event of a power outage, you will lose up to one hour of data (though usually its mainly log data that is lost). With this setting, during the most idle times the LLC will only increment by 1 per hour and your hard drives will stay very cool since they can be spun down for 1 hour at a time.
I would greatly appreciate feedback on whether this works for you or perhaps insight on how it can be improved. I maybe contacted at: