Linux command for doing fun things to a hard drive. Man page is below



NAME

hdparm - get/set hard disk parameters


SYNOPSIS

hdparm [ -a [sectcount] ] [ -A [0|1] ] [ -c [chipset_mode]
       ] [ -d [0|1] ] [ -f ] [ -g ] [ -i ] [  -k [0|1]  ]  [  -K
[0|1]  ]  [  -m [sectcount]  ]  [ -p [0|1|2|3|4|5] ] [ -P
[sectcount] ] [ -q ] [ -r [0|1] ] [ -S [timeout] ] [ -t ]
       [  -u [0|1] ] [ -v ] [ -W [0|1] ] [ -X [xfermode] ] [ -Z ]
       [device] ..


DESCRIPTION

hdparm provides a command line interface to  various  hard
       disk ioctls supported by the stock Linux IDE/ST-506 device
       driver.  This utility requires Linux kernel version 1.1.57
       or  later.   Some options may not work correctly with ear-
       lier kernels.  In addition, several options are  supported
       only  for  kernels  which  include  the  new (E)IDE device
       driver, such as version 1.2.0 or later.  These options are
       unavailable  when hdparm is compiled on systems with older
       kernel files in /usr/include/linux.


OPTIONS

When no flags are given,  -acdgkmnru is  assumed  (except
       when  a  given  device  is  SCSI, in which case -gr is the
       default).

       -a Get/set sector count for filesystem read-ahead.
              This  is  used to improve performance in sequential
              reads of large  files,  by  prefetching  additional
              blocks  in anticipation of them being needed by the
              running  task.   In  the  current  kernel   version
              (1.2.0)  this  has  a  default setting of 8 sectors
              (4KB).  This value seems good  for  most  purposes,
              but in a system where most file accesses are random
              seeks, a smaller setting might provide better  per-
              formance.   Also, many IDE drives also have a sepa-
              rate built-in read-ahead function, which alleviates
              the need for a filesystem read-ahead in many situa-
              tions.

       -A Disable/enable the IDE drive's read-lookahead  fea-
              ture (usually ON by default).

       -c Query/enable  (E)IDE 32-bit I/O support.  A numeric
              parameter can be used to enable/disable 32-bit  I/O
              support:  Currently  supported  values include 0 to
              disable 32-bit I/O support, 1 to enable 32-bit data
              transfers,  and  3 to enable 32-bit data transfers
              with a  special  sync sequence  required  by  many
              chipsets.  The value 3 works with nearly all 32-bit
              IDE chipsets, but incurs  slightly  more  overhead.
              Note  that "32-bit" refers to data transfers across
              a PCI or VLB bus to the interface  card  only;  all
              (E)IDE  drives  still have only a 16-bit connection
              over the ribbon cable from the interface card.

       -d Disable/enable the "using_dma" flag for this drive.
              This  option  only works with a few combinations of
              drives and interfaces which support DMA  and  which
              are  known  to  the IDE driver.  In particular, the
              Intel Triton chipset is supported for  bus-mastered
              DMA  operation with many drives (experimental).  It
              is also a good idea to use the -X34 option in  com-
              bination  with  -d1 to ensure that the drive itself
              is programmed for multiword DMA mode2.   Using  DMA
              does  not  necessarily  provide  any improvement in
              throughput or system performance,  but  many  folks
              swear by it.  Your mileage may vary.

       -f Sync  and  flush the buffer cache for the device on
              exit.  This operation is also performed as part  of
              the -t timings.

       -g Display  the drive geometry (cylinders, heads, sectors),
	      the size (in sectors) of the device, and the
              starting offset (in sectors) of the device from the
              beginning of the drive.

       -h Display terse usage information (help).

       -i Display the identification info that  was  obtained
              from the drive at boot time, if available.  This is
              a feature of modern IDE drives, and may not be sup-
              ported  by older devices.  The data returned may or
              may not be current,  depending  on  activity  since
              booting  the system.  However, the current multiple
              sector mode count is  always  shown.   For  a  more
              detailed interpretation of the identification info,
              refer to AT Attachment Interface for Disk Drives
(ANSI  ASC X3T9.2 working draft, revision 4a, April
              19/93).

       -I Request  identification  info  directly  from   the
              drive.  Otherwise similar to the -i option.

       -k Get/set  the  keep_settings_over_reset flag for the
              drive.  When this flag is set, the driver will pre-
              serve  the -dmu options over a soft reset, (as done
              during the error  recovery  sequence).   This  flag
              defaults to off, to prevent drive reset loops which
              could be caused by combinations of  -dmu settings.
              The  -k flag should therefore only be set after one
              has achieved confidence in correct system operation
              with  a  chosen  set of configuration settings.  In
              practice, all that is typically necessary to test a
              configuration (prior to using -k) is to verify that
              the drive can be read/written, and  that  no  error
              logs (kernel messages) are generated in the process
              (look in /var/adm/messages on most systems).

       -K Set  the  drive's  keep_features_over_reset   flag.
              Setting  this  enables the drive to retain the set-
              tings for -APSWXZ over a soft reset (as done during
              the  error recovery sequence).  Not all drives sup-
              port this feature.

       -m Get/set sector count for multiple sector I/O on the
              drive.  A setting of 0 disables this feature.  Mul-
              tiple sector mode (aka IDE Block Mode), is  a  fea-
              ture of most modern IDE hard drives, permitting the
              transfer of multiple  sectors  per  I/O  interrupt,
              rather  than  the  usual  one sector per interrupt.
              When this feature is enabled, it typically  reduces
              operating  system  overhead for disk I/O by 30-50%.
              On many systems, it also  provides  increased  data
              throughput  of  anywhere  from  5%  to  50%.   Some
              drives,  however  (most  notably  the   WD   Caviar
              series),  seem  to  run  slower  with multiple mode
              enabled.  Your mileage may vary.  Most drives  sup-
              port  the  minimum settings of 2, 4, 8, or 16 (sec-
              tors).   Larger  settings  may  also  be  possible,
              depending  on  the  drive.   A  setting of 16 or 32
              seems optimal on  many  systems.   Western  Digital
              recommends  lower  settings  of  4  to 8 on many of
              their drives, due tiny  (32kB)  drive  buffers  and
              non-optimized  buffering  algorithms.   The -i flag
              can be used to find the maximum  setting  supported
              by  an installed drive (look for MaxMultSect in the
              output).  Some drives  claim  to  support  multiple
              mode,  but  lose data at some settings.  Under rare
              circumstances, such failures can result in  massive
filesystem corruption.

-p Attempt  to reprogram the IDE interface chipset for
              the specified PIO mode, or attempt to auto-tune for
              the  "best"  PIO mode supported by the drive.  This
              feature is supported in the kernel for only  a  few
              "known" chipsets, and even then the support is iffy
              at best.  Some IDE chipsets are unable to alter the
              PIO  mode  for  a  single drive, in which case this
              flag may cause the PIO mode for both drives  to  be
              set.   Many  IDE  chipsets  support either fewer or
              more than the standard six (0 to 5) PIO  modes,  so
              the  exact  speed  setting  that is actually imple-
              mented will vary by chipset/driver sophistication.
              Use with extreme caution! This feature includes
              zero protection for the unwary, and an unsuccessful
              outcome may result in severe filesystem corruption!

-P Set the maximum sector count for the drive's inter-
              nal  prefetch mechanism.   Not  all drives support
              this feature.

       -q Handle the next  flag  quietly,  supressing  normal
              output.  This is useful for reducing screen clutter
              when running from /etc/rc.d/rc.local.  Not applica-
              ble to the -i or -v or -t flags.

       -r Get/set read-only flag for device.  When set, write
              operations are not permitted on the device.

       -S Set the standby (spindown) timeout for  the  drive.
              This  value  is  used by the drive to determine how
              long to wait (with no disk activity) before turning
              off  the  spindle  motor to save power.  Under such
              circumstances, the drive may take  as  long  as  30
              seconds  to  respond  to  a subsequent disk access,
              though most drives are much quicker.  The  encoding
              of the timeout value is somewhat peculiar.  A value
              of zero means "off".  Values from 1 to 240  specify
              multiples of 5 seconds, for timeouts from 5 seconds
              to 20 minutes.  Values from 241 to 251 specify from
              1  to  11 units of 30 minutes, for timeouts from 30
              minutes to 5.5 hours.  A value of 252  signifies  a
              timeout  of  21  minutes, 253 sets a vendor-defined
              timeout, and 255 is interpreted as 21 minutes  plus
              15 seconds.

       -t Perform  timings  of device reads for benchmark and
              comparism purposes.  For meaningful  results,  this
              operation should be repeated 2-3 times on an other-
              wise inactive system (no  other  active  processes)
              with at least a couple of megabytes of free memory.
              Two sets of timings are displayed:   the  speed  of
              reading  directly from the Linux buffer cache with-
              out disk access, and the speed of  reading  through
              the  buffer  cache  to  the  disk without any prior
              caching of data.  The first measurement  is  essen-
              tially  an indication of the throughput of the pro-
              cessor, cache, and memory of the system under test.
              The second measurement is an indication of how fast
              the drive can sustain sequential data  reads  under
              Linux,  without any filesystem overhead.  To ensure
              accurate measurments, the buffer cache  is  flushed
              during  the  processing  of  -t using the BLKFLSBUF
              ioctl.

       -u Get/set interrupt-unmask flag  for  the  drive.   A
              setting  of  1 permits  the driver to unmask other
              interrupts during processing of a  disk  interrupt,
              which  greatly  improves Linux's responsiveness and
              eliminates "serial port overrun" errors.  Use this
feature with caution: some drive/controller combi-
              nations do not tolerate the increased I/O latencies
              possible when this feature is enabled, resulting in
              massive filesystem corruption. In   particular,
              CMD-640B and RZ1000 (E)IDE interfaces can be unre-
liable (due to a hardware flaw) when this option is
              used  with  kernel  versions  earlier  than 1.3.32.
              Disabling the IDE prefetch feature of these  inter-
              faces (usually a BIOS/CMOS setting) provides a safe
              fix for the problem for use with earlier kernels.

       -v Display all settings, except -i (same as -acdgkmnru
              for IDE, or -gr for SCSI.  This is also the default
              behaviour when no flags are specified.

       -W Disable/enable the IDE drive's  write-caching  fea-
              ture (usually OFF by default).

       -X Set  the  IDE  transfer  mode for newer (E)IDE/ATA2
              drives.  This is typically used in combination with
              -d1 when  enabling  DMA  to/from a drive on a sup-
              ported interface chipset (such as the  Intel  430FX
              Triton), where -X34 is used to select multiword DMA
              mode2 transfers.  Apart from that, use of this flag
              is  seldom necessary since  most/all  modern  IDE
              drives default to their fastest PIO  transfer  mode
              at  power-on.  Fiddling with this can be both need-
              less and risky.  On drives which support  alternate
              transfer  modes,  -X can be used to switch the mode
              of the drive only. Prior to changing the  transfer
              mode,  the IDE interface should be jumpered or pro-
              grammed (see -p flag) for the new mode  setting  to
              prevent  loss  and/or corruption of data.  Use this
with extreme caution! For  the  PIO  (Programmed
              Input/Output)  transfer  modes  used by Linux, this
              value is simply the desired PIO mode number plus 8.
              Thus,  a value of 09 sets PIO mode1, 10 enables PIO
              mode2,  and  11  selects  PIO  mode3.   Setting  00
              restores  the  drive's  "default"  PIO mode, and 01
              disables IORDY.

       -Z Disable the automatic power-saving function of cer-
              tain  Seagate  drives  (ST3xxx models?), to prevent
              them  from  idling/spinning-down  at   inconvenient
              times.


BUGS

As  noted  above, the -m sectcount and -u 1 options should
       be used with caution at first, preferably on  a  read-only
       filesystem.   Most  drives  work well with these features,
       but a few drive/controller combinations are not 100%  com-
       patible.  Filesystem corruption may result.  Backup every-
       thing before experimenting!

       Although this utility is intended primarily for  use  with
       regular hard disk devices, several of the options are also
       valid (and permitted) for use with scsi hard disk devices.


AUTHOR

hdparm has  been  written by Mark Lord <mlord@pobox.com>,
       the primary developer and maintainer of the (E)IDE  driver
       for Linux, with suggestions from many netfolk.

       The  disable  Seagate auto-powersaving code is courtesy of
       Tomi Leppikangas(tomilepp@paju.oulu.fi).


SEE ALSO

AT Attachment Interface for Disk Drives, ANSI  ASC  X3T9.2
       working draft, revision 4a, April 19, 1993.

       AT Attachment Interface with Extensions (ATA-2), ANSI ASC
       X3T9.2 working draft, revision 2f, July 26, 1994.

       Western Digital Enhanced IDE Implementation Guide, by
       Western  Digital  Corporation,  revision 5.0, November 10,
       1993.

       Enhanced Disk Drive Specification, by Phoenix Technologies
       Ltd., version 1.0, January 25, 1994.