Hdparm
Encyclopedia
hdparm is a command line utility for the Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

 and Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 operating systems to set and view ATA
AT Attachment
Parallel ATA , originally ATA, is an interface standard for the connection of storage devices such as hard disks, solid-state drives, floppy drives, and optical disc drives in computers. The standard is maintained by X3/INCITS committee...

 hard disk
Hard disk
A hard disk drive is a non-volatile, random access digital magnetic data storage device. It features rotating rigid platters on a motor-driven spindle within a protective enclosure. Data is magnetically read from and written to the platter by read/write heads that float on a film of air above the...

 hardware parameters. It can set parameters such as drive caches, sleep mode, power management, acoustic management, and DMA
Direct memory access
Direct memory access is a feature of modern computers that allows certain hardware subsystems within the computer to access system memory independently of the central processing unit ....

 settings.

Changing hardware parameters from suboptimal conservative defaults to their optimal settings can improve performance greatly. For example, turning on DMA
Direct memory access
Direct memory access is a feature of modern computers that allows certain hardware subsystems within the computer to access system memory independently of the central processing unit ....

 can in some instances double or triple data throughput. Unfortunately at present there's no reliable method for determining the optimal settings for a given controller/drive combination, except careful trial and error; nor is there yet any central database that collects and shares the combined experience of hdparm users.

hdparm has a more serious drawback: it can crash a computer and make data on its disk inaccessible if certain parameters are misused. Out of approximately sixty-seven parameters, several are dangerous and could result in "massive filesystem corruption" when used indiscriminately.

Before using hdparm it is important to read its man page, and (if testing any of its dangerous parameters) to have a full backup of everything on the drive.

hdparm is free software
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...

 under the BSD license.

hdparm is available in the Cygwin
Cygwin
Cygwin is a Unix-like environment and command-line interface for Microsoft Windows. Cygwin provides native integration of Windows-based applications, data, and other system resources with applications, software tools, and data of the Unix-like environment...

 environment for Windows.

Usage examples

Important: hdparm has to be run with root privileges, otherwise it will either not be found or the requested actions won't be executed properly.

Display information of the hard drive:
hdparm -I /dev/sda

Turn on DMA
Direct memory access
Direct memory access is a feature of modern computers that allows certain hardware subsystems within the computer to access system memory independently of the central processing unit ....

for the first hard drive:
hdparm -d1 /dev/sda

Test cache read performance of the first hard drive:
hdparm -t /dev/sda

Enable energy saving spindown after inactivity (24*5=120 seconds):
hdparm -S 24 /dev/sda

To retain hdparm settings after a software reset, run:
hdparm -K 1 /dev/sda

Enable read-ahead:
hdparm -A 1 /dev/sda

If the disk is constantly too noisy, you can change its acoustic management at the cost of read/write performance:
hdparm -M 128 /dev/sda

If the disk synchronisation intervals are too short, then even small amounts of data will be written to disk which can have severe consequences on its lifespan. The better way would be to collect small data to bigger chunks and write until the chunk is big enough to be written to disk.

Current web browsers like Chrome write regularly small chunks when browsing in order not to lose any important data when the application crashes. However, this lets the disk spin very often as the drive repeatedly needs to unleash and then park its heads. The generated noises can be thus regarded as distracting by the user. To circumvent this issue, you can turn on the disk's power management:
hdparm -B 254 /dev/sda

Additionally, changing the value of /proc/sys/vm/dirty_expire_centisecs can have an effect on the performance. It sets the flush interval when dirty pages are written to disk.

Note that all these commands are only effective on the long-run, if you make the changes persistent. However, the settings you can set via hdparm are reverted each time you reboot. Therefore, it might be recommendable to restore the personal settings upon boot. An appropriate place that's existent in most Linux distributions is the /etc/rc.local script.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK