Friday, December 05, 2008

SATA Drive Power Management in Linux

I recently purchased a new 1TB HDD for a new power efficient server I built and I wanted to share a few of the power saving tips I discovered after reading a few sites.

File system

I was originally going to use ext3 for compatibility reasons, but after reading into JFS more I found that it's lighter on CPU and a bit more power friendly, so I used it to format this new drive. I also disabled atime and diratime within /etc/fstab.

/dev/mapper/jezebel-homevol /home jfs noatime,nodiratime 0 1
hdparm

Many newer drives support advanced power management on the drive itself, mostly at the sake of performance but since this is a data drive that sits idle most of the time the hit is negligible.
sudo hdparm -M 128 /dev/sdb
sudo hdparm -B 100 -S 240 /dev/sdb
The first will enable Acoustic Mode and the second will set spin down after 20 minutes of idle time. You can make the permanent by adding them in /etc/hdparm.conf.

Kernel params

Most of these tricks are for laptops, but they work just as well on an always-on server by enabling them in /etc/sysctl.conf.

#Specific Flash and Power Tweaks
#
#Set Laptop mode for less disk writes
vm.laptop_mode = 1
#
#Set Dirty writeback higher
vm.dirty_writeback_centisecs = 1500
vm.dirty_expire_centisecs = 1500
vm.dirty_ratio = 25

#
#Set swappiness
vm.swappiness = 20
Swappiness is set lower than default to keep swap around in case it's needed but to not use it very much.