21.7.10

VIA Epia Homeserver Project - HDD Power Saving

The power consumption of a hard disk cannot be neglected in a system designed to be of low consumption. For the operating system, a flash based drive (SSD or CF disk) is a good solution, yet for high volume storage this is usually not affordable. Recently, hard disk drives in the terrabyte range especially designed to be power efficient have been announced such as Western Digital's Greenpower series or the Ecogreen drives of Samsung. Their offer is  a substantial decrease of power consumption (up to 40% claimed) at the expense of somewhat slower operation. This is achieved for instance by spinning only at 5400rpm instead of 7200rpm, which is still reasonable for media storage or backup and even for office applications.

This tutorial is on setting up a Samsung Ecogreen HD154UI drive in my Via Epia homeserver. The goal was to make use of the power saving features that the drive has to offer using the native linux tool hdparm.
This is a very powerful (and therefore dangerous!) program that can read or set many parameters of PATA or SATA drives in order to tune performance, power consumption, or even hot swap disks. As of the writing of this tutorial, I use hdparm v8.9, note that syntax might change later on. It is also important that the proper driver for the PATA and SATA chipset is either compiled in the kernel or loaded as a module.

All functionality of hdparm is available through command line, yet it is better to use /etc/hdparm.conf to adjust parameters, as it will make those effective after each system boot. Mine looks like this:

/dev/sda {
    dma = on
    interrupt_unmask = on
    mult_sect_io = 16
    write_cache = on
    transfer_mode = 70
    io32_support = 1
    apm = 1
    spindown_time = 60
}

with dma = on meaning DMA instead of PIO (this is the default anyway). Interrupt_unmask = on allowing the system to process multiple IRQs at the same time. mult_sect_io = 16 determines the number of simultaneously transferred blocks (safe to set it to its maximum value). Write_cache = on tells the system to cache write operations. This might be dangerous if a power-cut occurs, yet usually is a good idea to set. Transfer_mode = 70 sets UDMA6. Other UDMA, DMA, PIO settings can be found here. io32_support = 1 is quite straightforward and should be set as well. 

The rest are the power saving parameters: apm = X sets how aggressively the drive would enter power saving modes with 1 equals the lowest consumption and 255 means no power saving and maximum performance. Note that X being equal to 128 or above, no spindown is allowed. As I use my disk mostly for storage, I chose the lowest power setting, X=1. Spindown_time sets the length of inactivity before the drive spins down in 5 sec units, so that 60 means 5 minutes timeout. If you experience that you have to wait often to the drive to spin up, consider setting this parameter higher. 

It is very important to note that not only disk I/O but any disk operation including checking drive health status using smartmontools will cause the drive to spin up. This means that periodic checking of drive health or temperature will render this setting essentially useless.

If hdparm.conf is set up correctly, the new parameters will be effective upon the next boot and can be checked:

~#: hdparm -i /dev/sda

/dev/sda:

 Model=SAMSUNG HD154UI                         , FwRev=1AG01118, SerialNo=S1XWJ1KZ300133     
 Config={ Fixed }
 RawCHS=16383/16/63, TrkSize=34902, SectSize=554, ECCbytes=4
 BuffType=DualPortCache, BuffSize=32767kB, MaxMultSect=16, MultSect=?16?
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=18446744072344861488
 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio1 pio2 pio3 pio4
 DMA modes:  mdma0 mdma1 mdma2
 UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6
 AdvancedPM=yes: unknown setting WriteCache=enabled
 Drive conforms to: unknown:  ATA/ATAPI-3,4,5,6,7

 * signifies the current active mode


No comments:

Post a Comment