LinuxDevCenter.com
oreilly.comSafari Books Online.Conferences.

advertisement


Linux in a Nutshell

This directory of Linux commands is from Linux in a Nutshell, 5th Edition.

Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.

Buy it now, or read it online on Safari Bookshelf.



hdparm

hdparm [options] [device]

System administration command. Read or set the hard drive parameters. This command can be used to tune hard drive performance; it is mostly used with IDE drives, but can also be used with SCSI drives.

Options

The hdparm command accepts many option flags, including some that can result in filesystem corruption if misused. Flags can be used to set or get a parameter. To get a parameter, just pass the flag without a value. To set a parameter, follow the flag with a space and the appropriate value.

-a [n]

Get or set the number of sectors to read ahead in the disk. The default is 8 sectors (4 KB); a larger value is more efficient for large, sequential reads, and a smaller value is better for small, random reads. Many IDE drives include this functionality in the drive itself, so this feature is not always necessary.

-A

Enable or disable the IDE read-ahead feature. Usually on by default.

-b [n]

Get or set the bus state for the drive.

-B

Set the Advanced Power Management (APM) data if the drive supports it.

-c [n]

Get or set 32-bit I/O values for IDE drives. Acceptable values are 0 (32-bit support off), 1 (32-bit support on), and 3 (on, but only with a sync sequence).

-C

Check the power status of the drive. This will tell you unknown, active/idle, standby, or sleeping. Use -S, -y, -Y, and -Z to set the power status.

-d [n]

Get or set the using_dma flag for the drive, which may be 0 (not using DMA) or 1 (using DMA).

-D

Enable or disable defect-handling features that are controlled by the hard drive itself.

-E n

Set CD-ROM read speed to n times normal audio playback speed. Not normally necessary.

-f

Flush and sync the buffer cache on exit.

-g

Query and display drive size and geometry information, such as number of cylinders, heads, and sectors.

-h

Display a short help message.

-i

Display the drive identification information obtained at boot time. If the drive has changed since boot, this information may not be current.

-I

Display more detailed identification information for the drive.

-Istdin

Read identify data from standard input.

-Istdout

Write identify data to standard output.

-k [n]

Get or set the keep_settings_over_reset variable. Valid settings are 0 and 1, and a value of 1 will keep the -dmu options when rebooting (soft reset only).

-K [n]

Get or set the keep_features_over_reset variable. Valid settings are 0 and 1, and a value of 1 will keep settings for the flags -APSWXZ over a soft reset.

-L n

Set the door lock flag for the drive. Used for Syquest, ZIP, and JAZ drives.

-m [n]

Get or set the number of sectors used for multiple sector count reading. A value of 0 disables the feature, and values of 2, 4, 8, 16, and 32 are common. Drives that try to support this feature and fail may suffer corruption and data loss.

-M [n]

Get or set the level for Automatic Acousting Management (AAM) features. Newer drives support this feature, which can slow down head movements to reduce hard disk noise. Values range from 128 (quiet, but slow) to 254 (fast, but loud). Some drives support only 128 and 254, while others support multiple levels between the extremes. At the time of writing, this feature was still considered experimental and not recommended for production use.

-n [n]

Set to 0 or 1 to disable or enable, respectively, the "ignore write errors" flag. This can cause massive data loss if used incorrectly, and is for development purposes only.

-p n

Tune the IDE interface to use PIO mode n, usually an integer between 0 and 5. Incorrect values can result in massive data loss. Support for the PIO mode-setting feature varies between IDE chips, so tuning it is not for the faint of heart.

-P n

Set the internal prefetch sector count. Not all drives support the feature.

-q

Suppress output for the flag after this one, unless it is the -i, -v, -t, or -T flag.

-Q [n]

Set the depth of tagged queues. 0 disables tagged queues. This is supported only on specific drives, and only for kernels 2.5.x and later.

-r [n]

Get or set the flag for read-only on the device. A value of 1 marks the device as read-only.

-R

This option should be used by experts only. It registers an IDE interface. See the -U option for further details.

-S n

Set the amount of time a disk is inactive before it spins down and goes into standby mode. Settings from 1 to 240 represent chunks of five seconds (for timeout values between 5 seconds and 20 minutes); values from 241 to 251 are increments of 30 minutes (for 30 minutes to 5.5 hours). A value of 252 sets the timeout to 21 minutes, 253 to the vendor default, and 255 to 20 minutes and 15 seconds.

-T

Time cache reads to determine performance.

-t

Time device reads to determine performance.

-u [n]

Get or set the interrupt-unmask value for the drive. A value of 1 lets the drive unmask other interrupts and can improve performance; when used with older kernels and hardware, it can cause data loss.

-U

Unregister an IDE interface. Use this feature and the -R feature only with hot-swappable hardware, such as very high-end servers and some laptops. It can damage or hang other systems, and should be used with caution.

-v

Display all appropriate settings for device except -i. This is the same as the default behavior with no flags.

-w

Reset the device. Use as a last resort only; may cause data loss.

-W

Enable or disable the write-cache feature for the drive. The default varies among drive manufacturers.

-x

Sets tristate. Use only for hot-swappable devices. See the -R and -U entries.

-X n

Set the IDE transfer mode. Possible values include 34 (multiword DMA mode2 transfers) and 66 (UltraDMA mode2 transfers), or any PIO mode number plus 8. This option is suggested for experts only, and is useful only with newer EIDE/IDE/ATA2 drives. Often used in combination with -d.

-y

Put the IDE drive into standby (spin-down) mode, saving power.

-Y

Put the IDE drive into sleep mode.

-z

Force the kernel to reread the partition table.

-Z

Disable automatic powersaving on some drives, which can prevent them from idling or spinning down at inconvenient moments. This will increase the electrical power consumption of your system.


Linux Resources
  • Linux Online
  • The Linux FAQ
  • linux.java.net
  • Linux Kernel Archives
  • Kernel Traffic
  • DistroWatch.com


  • Sponsored by: