Debian Codegraph @

upstream/debian-unstable/man8/hdparm.8

raw
1 .TH HDPARM 8 "Sep 2022" "Version 9.65"
2
3 .SH NAME
4 hdparm \- get/set SATA/IDE device parameters
5 .SH SYNOPSIS
6 .B hdparm
7 [options] [device ...]
8 .SH DESCRIPTION
9 .B hdparm
10 provides a command line interface to various kernel interfaces
11 supported by the Linux SATA/PATA/SAS "libata" subsystem
12 and the older IDE driver subsystem. Many newer (2008 and later)
13 USB drive enclosures now also support "SAT" (SCSI-ATA Command Translation)
14 and therefore may also work with hdparm. E.g., recent WD "Passport" models
15 and recent NexStar-3 enclosures.
16 Some options may work correctly only with the latest kernels.
17 .SH OPTIONS
18 When no options are given,
19 .B \-acdgkmur
20 is assumed.
21 For "Get/set" options, a query without the optional parameter (e.g.,
22 \-d) will query (get) the device state, and with a parameter (e.g.,
23 \-d0) will set the device state.
24 .TP
25 .I \-a
26 Get/set sector count for filesystem (software) read-ahead.
27 This is used to improve performance in sequential reads of large files,
28 by prefetching additional
29 blocks in anticipation of them being needed by the running task.
30 Many IDE drives also have a separate built-in read-ahead function,
31 which augments this filesystem (software) read-ahead function.
32 .TP
33 .I \-A
34 Get/set the IDE drive's read-lookahead feature (usually ON by default).
35 Usage:
36 .B \-A0
37 (disable) or
38 .B \-A1
39 (enable).
40 .TP
41 .I \-b
42 Get/set bus state.
43 .TP
44 .I \-B
45 Get/set Advanced Power Management feature, if the drive supports it. A low value
46 means aggressive power management and a high value means better performance.
47 Possible settings range from values 1 through 127 (which permit spin-down),
48 and values 128 through 254 (which do not permit spin-down).
49 The highest degree of power management is attained with a setting of 1,
50 and the highest I/O performance with a setting of 254.
51 A value of 255 tells hdparm to disable Advanced Power Management altogether
52 on the drive (not all drives support disabling it, but most do).
53 .TP
54 .I \-c
55 Get/set (E)IDE 32-bit I/O support. A numeric parameter can be
56 used to enable/disable 32-bit I/O support.
57 Currently supported values include
58 .B 0
59 to disable 32-bit I/O support,
60 .B 1
61 to enable 32-bit data transfers, and
62 .B 3
63 to enable 32-bit data transfers with a special
64 .B sync
65 sequence required by many chipsets. The value
66 .B 3
67 works with nearly all
68 32-bit IDE chipsets, but incurs slightly more overhead.
69 Note that "32-bit" refers to data transfers across a PCI or VLB bus to the
70 interface card only; all (E)IDE drives still have only a 16-bit connection
71 over the ribbon cable from the interface card.
72 .TP
73 .I \-C
74 Check the current IDE power mode status, which will always be one of
75 .B unknown
76 (drive does not support this command),
77 .B active/idle
78 (normal operation),
79 .B standby
80 (low power mode, drive has spun down),
81 or
82 .B sleeping
83 (lowest power mode, drive is completely shut down).
84 The
85 .B \-S, \-y, \-Y,
86 and
87 .B \-Z
88 options can be used to manipulate the IDE power modes.
89 .TP
90 .I \-d
91 Get/set the "using_dma" flag for this drive. This option now works
92 with most combinations of drives and PCI interfaces which support DMA
93 and which are known to the kernel IDE driver.
94 It is also a good idea to use the appropriate
95 .B \-X
96 option in combination with
97 .B \-d1
98 to ensure that the drive itself is programmed for the correct DMA mode,
99 although most BIOSs should do this for you at boot time.
100 Using DMA nearly always gives the best performance,
101 with fast I/O throughput and low CPU usage.
102 But there are at least a few configurations of chipsets and drives
103 for which DMA does not make much of a difference, or may even slow
104 things down (on really messed up hardware!). Your mileage may vary.
105 .TP
106 .I \-\-dco-freeze
107 DCO stands for Device Configuration Overlay, a way for vendors to selectively
108 disable certain features of a drive. The
109 .B \-\-dco-freeze
110 option will freeze/lock the current drive configuration,
111 thereby preventing software (or malware)
112 from changing any DCO settings until after the next power-on reset.
113 .TP
114 .I \-\-dco-identify
115 Query and dump information regarding drive configuration settings
116 which can be disabled by the vendor or OEM installer.
117 These settings show capabilities of the drive which might be disabled
118 by the vendor for "enhanced compatibility".
119 When disabled, they are otherwise hidden and will not show in the
120 .B \-I
121 identify output. For example, system vendors sometimes disable 48_bit
122 addressing on large drives, for compatibility (and loss of capacity)
123 with a specific BIOS. In such cases,
124 .B \-\-dco-identify
125 will show that the drive is 48_bit capable, but
126 .B \-I
127 will not show it, and nor will the drive accept 48_bit commands.
128 .TP
129 .I \-\-dco-restore
130 Reset all drive settings, features, and accessible capacities back to
131 factory defaults and full capabilities.
132 This command will fail if DCO is frozen/locked,
133 or if a
134 .B \-Np
135 maximum size restriction has also been set.
136 This is
137 .B EXTREMELY DANGEROUS
138 and will very likely cause massive loss of data.
139 .B DO NOT USE THIS COMMAND.
140 .TP
141 .I \-\-direct
142 Use the kernel's "O_DIRECT" flag when performing a
143 .B \-t
144 timing test. This bypasses the page cache, causing the reads
145 to go directly from the drive into hdparm's buffers, using so-called
146 "raw" I/O. In many cases, this can produce results that appear
147 much faster than the usual page cache method, giving a better indication
148 of raw device and driver performance.
149 .TP
150 .I \-\-drq-hsm-error
151 .B VERY DANGEROUS, DON'T EVEN THINK ABOUT USING IT.
152 This option causes hdparm to issue an IDENTIFY command
153 to the kernel, but incorrectly marked as a "non-data" command.
154 This results in the drive being left with its DataReQust(DRQ) line
155 "stuck" high. This confuses the kernel drivers, and may crash the system
156 immediately with massive data loss. The option exists to help in testing
157 and fortifying the kernel against similar real-world drive malfunctions.
158 .B VERY DANGEROUS, DO NOT USE!!
159 .TP
160 .I \-D
161 Enable/disable the on-drive defect management feature,
162 whereby the drive firmware tries to automatically manage
163 defective sectors by relocating them to "spare" sectors
164 reserved by the factory for such. Control of this feature
165 via the
166 .B \-D
167 option is not supported for most modern drives
168 since ATA-4; thus this command may fail.
169 .TP
170 .I \-E
171 Set cd/dvd drive speed. This is NOT necessary for regular operation,
172 as the drive will automatically switch speeds on its own.
173 But if you want to play with it, just supply a speed number
174 after the option, usually a number like 2 or 4.
175 This can be useful in some cases, though, to smooth out DVD video playback.
176 .TP
177 .I \-f
178 Sync and flush the buffer cache for the device on exit.
179 This operation is also performed internally as part of the
180 .B \-t
181 and
182 .B \-T
183 timings and other options.
184 .TP
185 .I \-\-fallocate
186 This option currently works only on ext4 and xfs filesystem types.
187 When used, this must be the only option given.
188 It requires two parameters: the desired file size in kibibytes
189 (byte count divided by 1024), followed by the pathname for the new file.
190 It will create a new file of the specified size,
191 but without actually having to write any data to the file.
192 This will normally complete very quickly, and without thrashing the
193 storage device.
194 .IP
195 E.g., create a 10\ kibibyte file:
196 .B hdparm \-\-fallocate 10 temp_file
197 .TP
198 .I \-\-fibmap
199 When used, this must be the only option given.
200 It requires a file path as a parameter, and will print
201 out a list of the block extents (sector ranges)
202 occupied by that file on disk.
203 Sector numbers are given as absolute LBA numbers,
204 referenced from sector 0 of the physical device rather
205 than from the partition or filesystem.
206 This information can then be used for a variety of purposes,
207 such as examining the degree of fragmentation of larger files, or
208 determining appropriate sectors to deliberately corrupt
209 during fault-injection testing procedures.
210 .IP
211 This option uses the new FIEMAP (file extent map) ioctl() when available,
212 and falls back to the older FIBMAP (file block map) ioctl() otherwise.
213 Note that FIBMAP suffers from a 32-bit block-number interface,
214 and thus not work beyond 8\ TB or 16\ TB. FIBMAP is also very slow,
215 and does not deal well with preallocated uncommitted extents
216 in ext4/xfs filesystems, unless a sync() is done before using this option.
217 .TP
218 .I \-\-fwdownload
219 When used, this should be the only option given.
220 It requires a file path immediately after the
221 option, indicating where the new drive firmware should be read from.
222 The contents of this file will be sent to the drive using the
223 (S)ATA
224 .B DOWNLOAD MICROCODE
225 command, using either transfer protocol 7 (entire file at once),
226 or, if the drive supports it, transfer protocol 3 (segmented download).
227 This command is
228 .B EXTREMELY DANGEROUS
229 and could destroy both the drive and all data on it.
230 .B DO NOT USE THIS COMMAND.
231 The
232 .B \-\-fwdownload-mode3
233 ,
234 .B \-\-fwdownload-mode3-max
235 , and
236 .B \-\-fwdownload-mode7
237 variations on basic
238 .B \-\-fwdownload
239 allow overriding automatic protocol detection in favour of
240 forcing hdparm to use a specific transfer protocol, for testing purposes only.
241 .TP
242 .I \-F
243 Flush the on-drive write cache buffer (older drives may not implement this).
244 .TP
245 .I \-g
246 Display the drive geometry (cylinders, heads, sectors),
247 the size (in sectors) of the device,
248 and the starting offset (in sectors) of the device from
249 the beginning of the drive.
250 .TP
251 .I \-h
252 Display terse usage information (help).
253 .TP
254 .I \-H
255 Read the temperature from some (mostly Hitachi) drives.
256 Also reports if the temperature is within operating condition range
257 (this may not be reliable). Does not cause the drive to spin up if idle.
258 .TP
259 .I \-i
260 Display the identification info which the kernel drivers (IDE, libata)
261 have stored from boot/configuration time. This may differ from the
262 current information obtainable directly from the drive itself
263 with the
264 .B \-I
265 option.
266 The data returned may or may not be current, depending on activity
267 since booting the system.
268 For a more detailed interpretation of the identification info,
269 refer to
270 .I AT Attachment Interface for Disk Drives,
271 ANSI ASC X3T9.2 working draft, revision 4a, April 19/93, and later editions.
272 .TP
273 .I \-\-idle-immediate
274 Issue an ATA IDLE_IMMEDIATE command, to put the drive into a lower power state.
275 Usually the device remains spun-up.
276 .TP
277 .I \-\-idle-unload
278 Issue an ATA IDLE_IMMEDIATE_WITH_UNLOAD command, to unload or park the heads
279 and put the drive into a lower power state. Usually the device remains spun-up.
280 .TP
281 .I \-I
282 Request identification info directly from the drive,
283 which is displayed in a new expanded format with considerably
284 more detail than with the older
285 .B \-i
286 option.
287 .TP
288 .I \-\-Iraw <pathname>
289 This option dumps the drive's identify data in raw binary to the specified file.
290 .TP
291 .I \-\-Istdin
292 This is a special variation on the
293 .B \-I
294 option,
295 which accepts a drive identification block as standard input
296 instead of using a /dev/hd* parameter.
297 The format of this block must be
298 .B exactly
299 the same as that found in the /proc/ide/*/hd*/identify "files",
300 or that produced by the
301 .B \-\-Istdout
302 option described below.
303 This variation is designed for use with collected "libraries" of drive
304 identification information, and can also be used on ATAPI
305 drives which may give media errors with the standard mechanism.
306 When
307 .B \-\-Istdin
308 is used, it must be the *only* parameter given.
309 Note that some information will be incomplete, as the drive LOG PAGES are unavailable when
310 .B \-\-Istdin
311 is used.
312 .TP
313 .I \-\-Istdout
314 This option dumps the drive's identify data in hex to stdout,
315 in a format similar to that from /proc/ide/*/identify, and suitable for
316 later use with the
317 .B \-\-Istdin
318 option.
319 .TP
320 .I \-J
321 Get/set the Western Digital (WD) Green Drive's "idle3" timeout value.
322 This timeout controls how often the drive parks its heads and enters
323 a low power consumption state. The factory default is eight (8) seconds,
324 which is a very poor choice for use with Linux. Leaving it at the default
325 will result in hundreds of thousands of head load/unload cycles in a very
326 short period of time. The drive mechanism is only rated for 300,000 to 1,000,000
327 cycles, so leaving it at the default could result in premature failure,
328 not to mention the performance impact of the drive often having to wake-up
329 before doing routine I/O.
330 .IP
331 WD supply a WDIDLE3.EXE DOS utility for tweaking this setting,
332 and you should use that program instead of hdparm
333 if at all possible. The reverse-engineered implementation in hdparm
334 is not as complete as the original official program, even though it does
335 seem to work on at a least a few drives. A full power cycle is required
336 for any change in setting to take effect, regardless of which program is
337 used to tweak things.
338 .IP
339 A setting of 30 seconds is recommended for Linux use.
340 Permitted values are from 8 to 12 seconds, and from 30 to 300 seconds
341 in 30-second increments.
342 Specify a value of zero (0) to disable the WD idle3 timer completely
343 (NOT RECOMMENDED!).
344 .TP
345 .I \-k
346 Get/set the "keep_settings_over_reset" flag for the drive.
347 When this flag is set, the drive will preserve the
348 .B \-dmu
349 settings over a soft reset, (as done during the error recovery sequence).
350 This option defaults to off,
351 to prevent drive reset loops which could be caused by combinations of
352 .B \-dmu
353 settings. The
354 .B \-k
355 option should therefore only be set after one has achieved confidence in
356 correct system operation with a chosen set of configuration settings.
357 In practice, all that is typically necessary to test a configuration
358 (prior to using \-k) is to verify that the drive can be read/written,
359 and that no error logs (kernel messages) are generated in the process
360 (look in /var/log/messages on most systems).
361 .TP
362 .I \-K
363 Set the drive's "keep_features_over_reset" flag. Setting this enables
364 the drive to retain the settings for
365 .B \-APSWXZ
366 over a soft reset (as done during the error recovery sequence).
367 Not all drives support this feature.
368 .TP
369 .I \-L
370 Set the drive's doorlock flag. Setting this to
371 .B 1
372 will lock the door mechanism of some removable hard drives
373 (e.g., Syquest, ZIP, Jazz..), and setting it to
374 .B 0
375 will unlock the door mechanism. Normally, Linux
376 maintains the door locking mechanism automatically, depending on drive usage
377 (locked whenever a filesystem is mounted). But on system shutdown, this can
378 be a nuisance if the root partition is on a removable disk, since the root
379 partition is left mounted (read-only) after shutdown. So, by using this
380 command to unlock the door
381 .B after
382 the root filesystem is remounted read-only, one can then remove the cartridge
383 from the drive after shutdown.
384 .TP
385 .I \-m
386 Get/set sector count for multiple sector I/O on the drive. A setting of
387 .B 0
388 disables this feature. Multiple sector mode (aka IDE Block Mode), is a feature
389 of most modern IDE hard drives, permitting the transfer of multiple sectors per
390 I/O interrupt, rather than the usual one sector per interrupt. When this
391 feature is enabled, it typically reduces operating system overhead for disk
392 I/O by 30\(en50%. On many systems, it also provides increased data throughput
393 of anywhere from 5% to 50%. Some drives, however
394 (most notably the WD Caviar series),
395 seem to run slower with multiple mode enabled. Your mileage may vary.
396 Most drives support the minimum settings of
397 2, 4, 8, or 16 (sectors). Larger settings may also be possible, depending on
398 the drive. A setting of 16 or 32 seems optimal on many systems.
399 Western Digital recommends lower settings of 4 to 8 on many of their drives,
400 due tiny (32 KiB) drive buffers and non-optimized buffering algorithms.
401 The
402 .B \-i
403 option can be used to find the maximum setting supported by an installed drive
404 (look for MaxMultSect in the output).
405 Some drives claim to support multiple mode, but lose data at some settings.
406 Under rare circumstances, such failures can result in
407 .B massive filesystem corruption.
408 .TP
409 .I \-\-make-bad-sector
410 Deliberately create a bad sector (aka. "media error") on the disk.
411 .B EXCEPTIONALLY DANGEROUS. DO NOT USE THIS OPTION!!
412 This can be useful for testing of device/RAID error recovery mechanisms.
413 The sector number is given as a (base10) parameter after the option.
414 Depending on the device, hdparm will choose one of two possible ATA
415 commands for corrupting the sector.
416 The WRITE_LONG works on most drives, but only up to the 28-bit
417 sector boundary.
418 Some very recent drives (2008) may support the new WRITE_UNCORRECTABLE_EXT
419 command, which works for any LBA48 sector.
420 If available, hdparm will use that in
421 preference to WRITE_LONG.
422 The WRITE_UNCORRECTABLE_EXT command itself presents a
423 choice of how the new bad sector should behave.
424 By default, it will look like any other bad sector, and the drive may
425 take some time to retry and fail on subsequent READs of the sector.
426 However, if a single letter
427 .B f
428 is prepended immediately in front of the first digit of the sector
429 number parameter,
430 then hdparm will issue a "flagged" WRITE_UNCORRECTABLE_EXT,
431 which causes the drive to merely flag the sector as bad (rather than
432 genuinely corrupt it),
433 and subsequent READs of the sector will fail immediately (rather than
434 after several retries).
435 Note also that the
436 .B \-\-repair-sector
437 option can be used to restore (any) bad sectors when they are no
438 longer needed,
439 including sectors that were genuinely bad (the drive will likely remap
440 those to a fresh area on the media).
441 .TP
442 .I \-M
443 Get/set Automatic Acoustic Management (AAM) setting. Most modern harddisk drives
444 have the ability to speed down the head movements to reduce their noise output.
445 The possible values are between 0 and 254. 128 is the most quiet (and therefore
446 slowest) setting and 254 the fastest (and loudest). Some drives have only two
447 levels (quiet / fast), while others may have different levels between 128 and 254.
448 At the moment, most drives only support 3 options, off, quiet, and fast.
449 These have been assigned the values 0, 128, and 254 at present, respectively,
450 but integer space has been incorporated for future expansion, should this change.
451 .TP
452 .I \-n
453 Get or set the "ignore_write_errors" flag in the driver.
454 Do NOT play with this without grokking the driver source code first.
455 .TP
456 .I \-N
457 Get/set max visible number of sectors, also known as the
458 .B Host Protected Area
459 setting. Without a parameter,
460 .B \-N
461 displays the current setting, which is reported as two values: the first
462 gives the current max sectors setting, and the second shows
463 the native (real) hardware limit for the disk.
464 The difference between these two values indicates how many sectors of the disk
465 are currently hidden from the operating system, in the form of a
466 .B Host Protected Area (HPA).
467 This area is often used by computer makers to hold diagnostic software,
468 and/or a copy of the originally provided operating system for recovery purposes.
469 Another possible use is to hide the true capacity of a very large disk
470 from a BIOS/system that cannot normally cope with drives of that size
471 (e.g., most current {2010} BIOSs cannot deal with drives larger than 2\ TB,
472 so an HPA could be used to cause a 3\ TB drive to report itself as a 2\ TB drive).
473 To change the current max (VERY DANGEROUS, DATA LOSS IS EXTREMELY LIKELY),
474 a new value should be provided (in base10) immediately
475 following the
476 .B \-N
477 option.
478 This value is specified as a count of sectors, rather than
479 the "max sector address" of the drive.
480 Drives have the concept of a temporary (volatile) setting which is
481 lost on the next hardware reset, as well as a more permanent (non-volatile)
482 value which survives resets and power cycles. By default,
483 .B \-N
484 affects only the temporary (volatile) setting. To change the permanent
485 (non-volatile) value, prepend a leading
486 .B p
487 character immediately before the first digit of the value.
488 Drives are supposed to allow only a single permanent
489 change per session. A hardware reset (or power cycle) is required
490 before another permanent
491 .B \-N
492 operation can succeed. Note that any attempt to set this value
493 may fail if the disk is being accessed by other software at the same time.
494 This is because setting the value requires a pair of back-to-back drive commands,
495 but there is no way to prevent some other command from being inserted between
496 them by the kernel. So if it fails initially, just try again.
497 Kernel support for
498 .B \-N
499 is buggy for many adapter types across many kernel versions,
500 in that an incorrect (too small) max size value is sometimes reported.
501 As of the 2.6.27 kernel, this does finally seem to be working on most hardware.
502 .TP
503 .I \-\-offset
504 Offsets to given number of GiB (1024*1024*1024) when performing
505 .B \-t
506 timings of device reads.
507 Speed changes (about twice) along many mechanical drives.
508 Usually the maximum is at the beginning, but not always.
509 Solid-state drives (SSDs) should show similar timings regardless of offset.
510 .TP
511 .I \-p
512 Attempt to reprogram the IDE interface chipset for the specified PIO mode,
513 or attempt to auto-tune for the "best" PIO mode supported by the drive.
514 This feature is supported in the kernel for only a few "known" chipsets,
515 and even then the support is iffy at best. Some IDE chipsets are unable
516 to alter the PIO mode for a single drive, in which case this option may cause
517 the PIO mode for
518 .I both
519 drives to be set. Many IDE chipsets support either fewer or more than the
520 standard six (0 to 5) PIO modes, so the exact speed setting that is actually
521 implemented will vary by chipset/driver sophistication.
522 .I Use with extreme caution!
523 This feature includes zero protection for the unwary,
524 and an unsuccessful outcome may result in
525 .I severe filesystem corruption!
526 .TP
527 .I \-P
528 Set the maximum sector count for the drive's internal prefetch mechanism.
529 Not all drives support this feature, and it was dropped from the official spec
530 as of ATA-4.
531 .TP
532 .I \-\-prefer-ata12
533 When using the SAT (SCSI ATA Translation) protocol, hdparm normally prefers
534 to use the 16-byte command format whenever possible.
535 But some USB drive enclosures don't work correctly with 16-byte commands.
536 This option can be used to force use of the smaller 12-byte command format
537 with such drives. hdparm will still revert to 16-byte commands for things
538 that cannot be done with the 12-byte format (e.g., sector accesses beyond 28-bits).
539 .TP
540 .I \-q
541 Handle the next option quietly, suppressing normal output (but not error messages).
542 This is useful for reducing screen clutter when running from system startup scripts.
543 Not applicable to the
544 .B \-i
545 or
546 .B \-v
547 or
548 .B \-t
549 or
550 .B \-T
551 options.
552 .TP
553 .I \-Q
554 Get or set the device's command queue_depth, if supported by the hardware.
555 This only works with 2.6.xx (or later) kernels, and only with
556 device and driver combinations which support changing the queue_depth.
557 For SATA disks, this is the Native Command Queuing (NCQ) queue depth.
558 .TP
559 .I \-r
560 Get/set read-only flag for the device.
561 When set, Linux disallows write operations on the device.
562 .TP
563 .I \-R
564 Get/set Write-Read-Verify feature, if the drive supports it.
565 Usage:
566 .B \-R0
567 (disable) or
568 .B \-R1
569 (enable). This feature is intended to have the drive firmware automatically
570 read-back any data that is written by software, to verify that the data was
571 successfully written. This is generally overkill, and can slow down disk
572 writes by as much as a factor of two (or more).
573 .TP
574 .I \-\-read-sector
575 Reads from the specified sector number,
576 and dumps the contents in hex to standard output.
577 The sector number must be given (base10) after this option.
578 hdparm will issue a low-level read (completely bypassing the usual
579 block layer read/write mechanisms) for the specified sector.
580 This can be used to definitively check whether a given sector is bad
581 (media error) or not (doing so through the usual mechanisms can
582 sometimes give false positives).
583 .TP
584 .I \-\-repair-sector
585 This is an alias for the
586 .B \-\-write-sector
587 option. VERY DANGEROUS.
588 .TP
589 .I \-s
590 Enable/disable the power-on in standby feature, if supported by
591 the drive.
592 .B VERY DANGEROUS.
593 Do not use unless you are absolutely certain
594 that both the system BIOS (or firmware) and the operating system kernel
595 (Linux >= 2.6.22) support probing for drives that use this feature.
596 When enabled, the drive is powered-up in the
597 .B standby
598 mode to allow the controller to sequence the spin-up of devices,
599 reducing the instantaneous current draw burden when many drives
600 share a power supply. Primarily for use in large RAID setups.
601 This feature is usually disabled and the drive is powered-up in the
602 .B active
603 mode (see \-C above).
604 Note that a drive may also allow enabling this feature by a jumper.
605 Some SATA drives support the control of this feature by pin 11 of
606 the SATA power connector. In these cases, this command may be
607 unsupported or may have no effect.
608 .TP
609 .I \-S
610 Put the drive into idle (low-power) mode, and also set the standby
611 (spindown) timeout for the drive. This timeout value is used
612 by the drive to determine how long to wait (with no disk activity)
613 before turning off the spindle motor to save power. Under such
614 circumstances, the drive may take as long as 30 seconds to respond to
615 a subsequent disk access, though most drives are much quicker. The
616 encoding of the timeout value is somewhat peculiar. A value of zero
617 means "timeouts are disabled": the device will not automatically enter
618 standby mode. Values from 1 to 240 specify multiples of 5 seconds,
619 yielding timeouts from 5 seconds to 20 minutes. Values from 241 to
620 251 specify from 1 to 11 units of 30 minutes, yielding timeouts from
621 30 minutes to 5.5 hours. A value of 252 signifies a timeout of 21
622 minutes. A value of 253 sets a vendor-defined timeout period between 8
623 and 12 hours, and the value 254 is reserved. 255 is interpreted as 21
624 minutes plus 15 seconds. Note that some older drives may have very
625 different interpretations of these values.
626 .TP
627 .I \-\-set-sector-size
628 For drives which support reconfiguring of the Logical Sector Size,
629 this flag can be used to specify the new desired sector size in bytes.
630 .B VERY DANGEROUS. This most likely will scramble all data on the drive.
631 The specified size must be one of 512, 520, 528, 4096, 4160, or 4224.
632 Very few drives support values other than 512 and 4096. Eg.
633 .B hdparm --set-sector-size 4096 /dev/sdb
634 .TP
635 .I \-t
636 Perform timings of device reads for benchmark and comparison purposes.
637 For meaningful results, this operation should be repeated 2\(en3 times on
638 an otherwise inactive system (no other active processes) with at least a
639 couple of megabytes of free memory. This displays the speed of reading
640 through the buffer cache to the disk without any prior caching of data.
641 This measurement is an indication of how fast the drive can sustain
642 sequential data reads under Linux, without any filesystem overhead. To
643 ensure accurate measurements, the buffer cache is flushed during the
644 processing of
645 .I \-t
646 using the BLKFLSBUF ioctl.
647 .TP
648 .I \-T
649 Perform timings of cache reads for benchmark and comparison purposes.
650 For meaningful results, this operation should be repeated 2\(en3 times
651 on an otherwise inactive system (no other active processes) with at
652 least a couple of megabytes of free memory. This displays the speed
653 of reading directly from the Linux buffer cache without disk access.
654 This measurement is essentially an indication of the throughput of the
655 processor, cache, and memory of the system under test.
656 .TP
657 .I \-\-trim-sector-ranges
658 For Solid State Drives (SSDs).
659 .B EXCEPTIONALLY DANGEROUS. DO NOT USE THIS OPTION!!
660 Tells the drive firmware
661 to discard unneeded data sectors, destroying any data that may have
662 been present within them. This makes those sectors available for
663 immediate use by the firmware's garbage collection mechanism, to
664 improve scheduling for wear-leveling of the flash media.
665 This option expects one or more sector range pairs immediately after
666 the option:
667 an LBA starting address, a colon, and a sector count (max 65535),
668 with no intervening spaces.
669 .B EXCEPTIONALLY DANGEROUS. DO NOT USE THIS OPTION!!
670 .IP
671 E.g.,
672 .B hdparm \-\-trim-sector-ranges 1000:4 7894:16 /dev/sdz
673 .TP
674 .I \-\-trim-sector-ranges-stdin
675 Identical to
676 .B \-\-trim-sector-ranges
677 above, except the list of lba:count pairs is read from stdin
678 rather than being specified on the command line. This can be used
679 to avoid problems with excessively long command lines. It also permits
680 batching of many more sector ranges into single commands to the drive,
681 up to the currently configured transfer limit (max_sectors_kb).
682 .TP
683 .I \-u
684 Get/set the interrupt-unmask flag for the drive. A setting of
685 .B 1
686 permits the
687 driver to unmask other interrupts during processing of a disk interrupt,
688 which greatly improves Linux's responsiveness and eliminates "serial port
689 overrun" errors.
690 .B Use this feature with caution:
691 some drive/controller combinations do
692 not tolerate the increased I/O latencies possible when this feature is enabled,
693 resulting in
694 .B massive filesystem corruption.
695 In particular,
696 .B CMD-640B
697 and
698 .B RZ1000
699 (E)IDE interfaces can be
700 .B unreliable
701 (due to a hardware flaw) when this option is used with kernel versions earlier
702 than 2.0.13. Disabling the
703 .B IDE prefetch
704 feature of these interfaces (usually a BIOS/CMOS setting)
705 provides a safe fix for the problem for use with earlier kernels.
706 .TP
707 .I \-v
708 Display some basic settings, similar to \-acdgkmur for IDE.
709 This is also the default behaviour when no options are specified.
710 .TP
711 .I \-V
712 Display program version and exit immediately.
713 .TP
714 .I \-\-verbose
715 Display extra diagnostics from some commands.
716 .TP
717 .I \-w
718 Perform a device reset
719 .B (DANGEROUS).
720 Do NOT use this option.
721 It exists for unlikely situations where a reboot might otherwise be
722 required to get a confused drive back into a useable state.
723 .TP
724 .I \-\-write-sector
725 Writes zeros to the specified sector number. VERY DANGEROUS.
726 The sector number must be given (base10) after this option.
727 hdparm will issue a low-level write (completely bypassing the usual
728 block layer read/write mechanisms) to the specified sector.
729 This can be used to force a drive to repair a bad sector (media error).
730 .TP
731 .I \-W
732 Get/set the IDE/SATA drive's write-caching feature.
733 .TP
734 .I \-X
735 Set the IDE transfer mode for (E)IDE/ATA drives.
736 This is typically used in combination with
737 .B \-d1
738 when enabling DMA to/from a drive on a supported interface chipset, where
739 .B \-X mdma2
740 is used to select multiword DMA mode2 transfers and
741 .B \-X sdma1
742 is used to select simple mode 1 DMA transfers.
743 With systems which support UltraDMA burst timings,
744 .B \-X udma2
745 is used to select UltraDMA mode2 transfers (you'll need to prepare
746 the chipset for UltraDMA beforehand).
747 Apart from that, use of this option is
748 .B seldom necessary
749 since most/all modern IDE drives default to their fastest PIO transfer mode
750 at power-on. Fiddling with this can be both needless and risky.
751 On drives which support alternate transfer modes,
752 .B \-X
753 can be used to switch the mode of the drive
754 .B only.
755 Prior to changing the transfer mode, the IDE interface should be jumpered
756 or programmed (see
757 .B \-p
758 option)
759 for the new mode setting to prevent loss and/or corruption of data.
760 .I Use this with extreme caution!
761 For the PIO (Programmed Input/Output)
762 transfer modes used by Linux, this value is simply the desired
763 PIO mode number plus 8.
764 Thus, a value of 09 sets PIO mode1, 10 enables PIO mode2,
765 and 11 selects PIO mode3.
766 Setting 00 restores the drive's "default" PIO mode, and 01 disables IORDY.
767 For multiword DMA, the value used is the desired DMA mode number
768 plus 32. for UltraDMA, the value is the desired UltraDMA mode number
769 plus 64.
770 .TP
771 .I \-y
772 Force an IDE drive to immediately enter the low power consumption
773 .B standby
774 mode, usually causing it to spin down.
775 The current power mode status can be checked using the
776 .B \-C
777 option.
778 .TP
779 .I \-Y
780 Force an IDE drive to immediately enter the lowest power consumption
781 .B sleep
782 mode, causing it to shut down completely. A hard or soft reset
783 is required before the drive can be accessed again
784 (the Linux IDE driver will automatically handle issuing a reset if/when needed).
785 The current power mode status can be checked using the
786 .B \-C
787 option.
788 .TP
789 .I \-z
790 Force a kernel re-read of the partition table of the specified device(s).
791 .TP
792 .I \-Z
793 Disable the automatic power-saving function of certain Seagate drives
794 (ST3xxx models?), to prevent them from idling/spinning-down
795 at inconvenient times.
796 .
797 .SH ATA Security Feature Set
798 .
799 These switches are
800 .B DANGEROUS
801 to experiment with, and might not work with some kernels.
802 .B USE AT YOUR OWN RISK.
803 .TP
804 .I \-\-security-help
805 Display terse usage info for all of the \-\-security-* options.
806 .TP
807 .I \-\-security-freeze
808 Freeze the drive's security settings.
809 The drive does not accept any security commands until next power-on reset.
810 Use this function in combination with \-\-security-unlock to protect drive
811 from any attempt to set a new password. Can be used standalone, too.
812 No other options are permitted on the command line with this one.
813 .TP
814 .I \-\-security-prompt-for-password
815 Prompt for the \-\-security PWD rather than getting from the command line args.
816 This avoids having passwords show up in shell history or in
817 /proc/self/cmdline during execution.
818 .TP
819 .I \-\-security-unlock PWD
820 Unlock the drive, using password PWD.
821 Password is given as an ASCII string and is padded with NULs to reach 32 bytes.
822 The applicable drive password is selected with the \-\-user-master switch
823 (default is "user" password).
824 No other options are permitted on the command line with this one.
825 .TP
826 .I \-\-security-set-pass PWD
827 Lock the drive, using password PWD (Set Password)
828 .B (DANGEROUS).
829 Password is given as an ASCII string and is padded with NULs to reach 32 bytes.
830 Use the special password
831 .B NULL
832 to set an empty password.
833 The applicable drive password is selected with the \-\-user-master switch
834 (default is "user" password)
835 and the applicable security mode with the \-\-security-mode switch.
836 No other options are permitted on the command line with this one.
837 .TP
838 .I \-\-security-disable PWD
839 Disable drive locking, using password PWD.
840 Password is given as an ASCII string and is padded with NULs to reach 32 bytes.
841 The applicable drive password is selected with the \-\-user-master switch
842 (default is "user" password).
843 No other options are permitted on the command line with this one.
844 .TP
845 .I \-\-security-erase PWD
846 Erase (locked) drive, using password PWD
847 .B (DANGEROUS).
848 Password is given as an ASCII string and is padded with NULs to reach 32 bytes.
849 Use the special password
850 .B NULL
851 to represent an empty password.
852 The applicable drive password is selected with the \-\-user-master switch
853 (default is "user" password).
854 No other options are permitted on the command line with this one.
855 .TP
856 .I \-\-security-erase-enhanced PWD
857 Enhanced erase (locked) drive, using password PWD
858 .B (DANGEROUS).
859 Password is given as an ASCII string and is padded with NULs to reach 32 bytes.
860 The applicable drive password is selected with the \-\-user-master switch
861 (default is "user" password).
862 No other options are permitted on the command line with this one.
863 .TP
864 .I \-\-user-master USER
865 Specifies which password (user/master) to select.
866 .B Defaults to "user" password.
867 Only useful in combination with \-\-security-unlock, \-\-security-set-pass,
868 \-\-security-disable, \-\-security-erase or \-\-security-erase-enhanced.
869 u user password
870 m master password
871
872 .TP
873 .I \-\-security-mode MODE
874 Specifies which security mode (high/maximum) to set.
875 .B Defaults to high.
876 Only useful in combination with \-\-security-set-pass.
877 h high security
878 m maximum security
879
880 .B THIS FEATURE IS EXPERIMENTAL AND NOT WELL TESTED. USE AT YOUR OWN RISK.
881 .SH FILES
882 /etc/hdparm.conf
883 .SH BUGS
884 As noted above, the
885 .B \-m sectcount
886 and
887 .B \-u 1
888 options should be used with caution at first, preferably on a
889 read-only filesystem. Most drives work well with these features, but
890 a few drive/controller combinations are not 100% compatible. Filesystem
891 corruption may result. Backup everything before experimenting!
892 .PP
893 Some options (e.g., \-r for SCSI) may not work with old kernels as
894 necessary ioctl()'s were not supported.
895 .PP
896 Although this utility is intended primarily for use with SATA/IDE hard disk
897 devices, several of the options are also valid (and permitted) for use with
898 SCSI hard disk devices and MFM/RLL hard disks with XT interfaces.
899 .PP
900 The Linux kernel up until 2.6.12 (and probably later) doesn't handle the
901 security unlock and disable commands gracefully and will segfault and in some
902 cases even panic. The security commands however might indeed have been executed
903 by the drive. This poor kernel behaviour makes the PIO data security commands
904 rather useless at the moment.
905 .PP
906 Note that the "security erase" and "security disable" commands have been
907 implemented as two consecutive PIO data commands and will not succeed on a
908 locked drive because the second command will not be issued after the segfault.
909 See the code for hints how patch it to work around this problem. Despite the
910 segfault it is often still possible to run two instances of hdparm
911 consecutively and issue the two necessary commands that way.
912 .SH AUTHOR
913 .B hdparm
914 has been written by Mark Lord <[email protected]>, the original primary
915 developer and maintainer of the (E)IDE driver for Linux, and current contributor
916 to the libata subsystem, along with suggestions and patches from many netfolk.
917 .PP
918 The disable Seagate auto-powersaving code
919 is courtesy of Tomi Leppikangas([email protected]).
920 .PP
921 Security freeze command by Benjamin Benz, 2005.
922 .PP
923 PIO data out security commands by Leonard den Ottolander, 2005.
924 Some other parts by Benjamin Benz and others.
925 .SH SEE ALSO
926 .B http://www.t13.org/
927 Technical Committee T13 AT Attachment (ATA/ATAPI) Interface.
928 .PP
929 .B http://www.serialata.org/
930 Serial ATA International Organization.
931 .PP
932 .B http://www.compactflash.org/
933 CompactFlash Association.