Tips & Tricks
Disks and FilesystemsDisks are one of the few moving parts in your computer, and they tend to have a high speed data link going to them. Both of these properties turn disks into serious power consumers when they're active.SATA Aggressive Link Power ManagementSeveral SATA controllers, that use the AHCI specification, have a feature called ALPM, which stands for Aggressive Link Power Management. ALPM is a technique where the SATA AHCI controller puts the SATA link to the disk into a very low power mode when there's no IO for awhile. The controller automatically puts the link back into active power state when there's real work to be done. This can save between 0.5 and 1.5 Watts of power.
Filesystem atimeThe POSIX standard requires operating systems to: keep track of the last time each file was accessed by an application or the user, and to store this timestamp as part of the filesystem data. This timestamp, called atime. atime, can be useful in finding out which files are never used (to clean up the /tmp directory for example) or to find out if a file has been looked at after it changed (this is sometimes used by email applications to warn about newly received email).
mount -o remount,noatime / Filesystem relatimeBecause few programs use atime, disabling it always and for everyone is not very practical. The Linux kernel has a feature called relatime, which is an effective compromise between having some of the information that atime provides, without having the disk time updated every single time.
mount -o remount,relatime / Another option is to use the nodiratime option instead of noatime or relatime. nodiratime will not update the atime field on directory inodes. This allows you to continue to update file access on read, for programs which require it, but prevents updates for just reading a directory, such as with ls. mount -o remount,nodiratime / Disk Power ManagementSome hard disks support disk power management. You can use the hdparm program to check whether your disk supports this feature.
hdparm -i /dev/sda
/dev/sda:
Model=HTS541060G9SA00, FwRev=MB3IC60H, SerialNo= MPBCL0XGHTUU8M
Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
BuffType=DualPortCache, BuffSize=7538kB, MaxMultSect=16, MultSect=16
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=117210240
IORDY=on/off, tPIO={min:240,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
AdvancedPM=yes: mode=0x80 (128) WriteCache=enabled
Drive conforms to: ATA/ATAPI-7 T13 1532D revision 1:
ATA/ATAPI-2 ATA/ATAPI-3 ATA/ATAPI-4
ATA/ATAPI-5 ATA/ATAPI-6 ATA/ATAPI-7
* signifies the current active mode
If your hard drive supports AdvancedPM, you can use hdparm to tell the
disk to go into power savings mode after an elapsed period of idle time. The relevant options for hdparm are:
-B set Advanced Power Management setting (1-255) -S set standby (spindown) timeout -y put IDE drive in standby mode -Y put IDE drive to sleep -Z disable Seagate auto-powersaving modeTo put the disk into the most aggressive power savings mode after 60 seconds of idle time, you would use: hdparm -B 1 -S 12 /dev/sdaRead more about hdparm on your system by typing: man hdparm The VM writeback timeThe VM subsystem, in the Linux kernel, buffers writes to files that applications perform for a period of time. This caching allows the kernel to group consecutive writes into one big write, and to generally optimize the disk IO to be the most efficient. The kernel, by default, will start writing out data to disk after 5 seconds, so, if a power failure or kernel crash happens, at most, 5 seconds of data would be lost.
# cat /proc/sys/vm/dirty_writeback_centisecs 500This example shows that the timeout on this system was 500 centiseconds (or 5 seconds in human terms). To increase the timeout to 15 seconds, you can issue this command: echo 1500 > /proc/sys/vm/dirty_writeback_centisecs Enable laptop modeFor several years, the Linux kernel has had a "laptop mode" for the IO subsystem. When laptop mode is enabled, the kernel will try to be smart about when to do IO, to give the disk and the SATA links as much time as possible in a low power state.
# cat /proc/sys/vm/laptop_mode 5If the content of that file is 0, laptop mode is disabled. In the example here, laptop mode is enabled. To enable laptop mode, you can use this command: echo 5 > /proc/sys/vm/laptop_mode Several distributions also include the laptopmode scripts as part of their standard installation. These scripts enable laptop mode automatically, in some cases. Use the "-" option in /etc/syslog.confThe syslog daemon is the software component that takes care of logging all kernel and related logmessages to the /var/log/messages file. By default, the syslog daemon will issue a filesystem sync operation after each message. This sync operation has three effects on typical Linux systems: The data is written from the disk cache to the actual disk immediately (so the disk wakes up more); for some of the journalling filesystems, the journal gets flushed and cleaned, and the cache on the drive itself is flushed to the platter.
*.info;mail.none;authpriv.none;cron.none /var/log/messageslike this: *.info;mail.none;authpriv.none;cron.none -/var/log/messagesThis will cause the syslog program to stop using the sync operation for the most common messages. hal cdrom pollinghal is a core component of the various desktop environments and deals with all sorts of hardware interaction. One component of the hal daemon is the part where it polls the cdrom drive regularly (as often as once every two seconds!) to see if the user has inserted a CD. This is used, for example, to automatically open a new window with a file browser for the CD.
hal-disable-polling --device /dev/scd0Note that this means that you will not get a pop-up window if you insert a CD. To enable this polling again, use the this command: hal-disable-polling --device /dev/scd0 --enable-pollingNewer SATA-based CDROM drives have the capability to notify the machine when a CD gets inserted, making polling unnecessary. Both the kernel and hal are currently undergoing development to detect and support this capability, so that polling is not needed at any time for these devices. Kill Unnecessary Programs and ServicesSome programs keep your disk busy, which drains power. If you are in a power conservation environment, you will want to stop these programs from executing. Below is a list of programs that you should consider killing, to save power:
|