hdparm

hdparm is a Linux shell utility for viewing and manipulating various IDE drive and driver parameters. Most drives can benefit from improved performance using a command similar to "hdparm -qm8 -qu1 -qc1 -qd1 /dev/hda".

Tags Hardware Utilities
Licenses BSD Original
Operating Systems POSIX Linux
Implementation C

Tweet this project Short link

Rss Recent releases

  • Rrelease-mid
  •  17 Apr 2009 14:38
  • Rrelease-after

Changes: LBA48 bugs on big-endian machines were fixed. The "-m" option was fixed to work with libata.

  • Rrelease-mid
  •  09 Apr 2009 00:24
  • Rrelease-after

Changes: All accesses are now O_RDONLY again, to keep Debian/udevd happy. The DSM determinate/indeterminate TRIM support is now displayed in -I output. The output of CFA features from -I was tidied.

  • Rrelease-mid
  •  22 Mar 2009 12:16
  • Rrelease-after

Changes: A problem with O_DIRECT ("--direct") for architectures other than x86 was fixed. Some whitespace was stripped from output.

  • Rrelease-mid
  •  28 Feb 2009 23:17
  • Rrelease-after

Changes: The output of "-I" was updated with SATA-2.6 additions, and "form factor" and "rotation" displays were added to it. APM level retrieval is now supported with the "-B" flag. The "-C" output was updated to match ATA8. Logical/physical sector size reporting was added.

  • Rrelease-mid
  •  15 Feb 2009 20:48
  • Rrelease-after

Changes: ATA_16 is now the default again, as this is required by libata for ATAPI devices. The "--prefer-ata12" argument was added to allow forcing the use of ATA_12 when needed (e.g. some USB enclosures).

Rss Recent comments

Rcomment-before 22 Jun 2009 04:05 Rcomment-trans rkononov Rcomment-after

I'm not sure where you want the bugs submitted...

Compiled from v9.15 sources, hdparm crashes at hdparm.c, line 1826, when get_identify_data() returns NULL. Checking that id!=NULL is needed.

Rcomment-before 26 Dec 2008 04:29 Rcomment-trans ideguy Rcomment-after

Re: Inappropriate ioctl for device

..

> $ sudo /sbin/hdparm -c1 -d1 /dev/sda

>

> /dev/sda:

> setting 32-bit IO_support flag to 1

> HDIO_SET_32BIT failed: Invalid argument

>

> setting using_dma to 1 (on)

> HDIO_SET_DMA failed: Inappropriate ioctl

> for device

> IO_support = 0 (default)

> HDIO_GET_DMA failed: Inappropriate ioctl

> for device

..

libata does not have a way to control DMA or 32bit PIO settings. So the command will fail. Normal. Ignore it.

Libata will always use DMA if possible, so no need for either setting.

-ml

Rcomment-before 26 Dec 2008 02:23 Rcomment-trans shirishag75 Rcomment-after

Inappropriate ioctl for device
Hi all,

I get the above error.

This is on ubuntu 8.10 2.6.27-9-generic

$ uname -a

Linux shirish-desktop 2.6.27-9-generic #1 SMP Thu Nov 20 21:57:00 UTC 2008 i686 GNU/Linux

$ sudo /sbin/hdparm -c1 -d1 /dev/sda

/dev/sda:

setting 32-bit IO_support flag to 1

HDIO_SET_32BIT failed: Invalid argument

setting using_dma to 1 (on)

HDIO_SET_DMA failed: Inappropriate ioctl for device

IO_support = 0 (default)

HDIO_GET_DMA failed: Inappropriate ioctl for device

The disk in question is an IDE drive in emulated SCSI mode due to ubuntu moving to the new 'libata' library.

$ sudo hdparm -I /dev/sda

[sudo] password for shirish:

/dev/sda:

ATA device, with non-removable media

Model Number: ST3160021A

Serial Number: 4JS26D4P

Firmware Revision: 8.01

Standards:

Used: ATA/ATAPI-6 T13 1410D revision 2

Supported: 6 5 4

Configuration:

Logical max current

cylinders 16383 4047

heads 16 16

sectors/track 63 255

--

CHS current addressable sectors: 16511760

LBA user addressable sectors: 268435455

LBA48 user addressable sectors: 312581808

device size with M = 1024*1024: 152627 MBytes

device size with M = 1000*1000: 160041 MBytes (160 GB)

Capabilities:

LBA, IORDY(can be disabled)

Standby timer values: spec'd by Standard, no device specific minimum

R/W multiple sector transfer: Max = 16 Current = 16

Recommended acoustic management value: 128, current value: 0

DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5

Cycle time: min=120ns recommended=120ns

PIO: pio0 pio1 pio2 pio3 pio4

Cycle time: no flow control=240ns IORDY flow control=120ns

Commands/features:

Enabled Supported:

* SMART feature set

Security Mode feature set

* Power Management feature set

* Write cache

* Look-ahead

* Host Protected Area feature set

* WRITE_BUFFER command

* READ_BUFFER command

* DOWNLOAD_MICROCODE

SET_MAX security extension

* 48-bit Address feature set

* Device Configuration Overlay feature set

* Mandatory FLUSH_CACHE

* FLUSH_CACHE_EXT

* SMART error logging

* SMART self-test

* General Purpose Logging feature set

Time Limited Commands (TLC) feature set

Command Completion Time Limit (CCTL)

Security:

Master password revision code = 65534

supported

not enabled

not locked

not frozen

not expired: security count

not supported: enhanced erase

HW reset results:

CBLID- above Vih

Device num = 1 determined by the jumper

Checksum: correct

Please lemme know if there is anyway to set the same.

Rcomment-before 28 Jul 2008 20:46 Rcomment-trans ideguy Rcomment-after

Re: How to erase the whole disk ?
I believe you are doing the right sequence of steps, so the problem is likely a broken kernel call in the old IDE drivers.

I do know that there are bugs in the kernel ioctls() HDIO_DRIVE_TASK and HDIO_DRIVE_TASKFILE have bugs in some scenarios, with the old IDE drivers. So that is what is probably causing it not to work for you.

If you need this kind of functionality, your best bet is to switch over to the modern libata kernel drivers, which are replacing the old IDE ones. The libata kernel drivers fully support hdparm and the SECURITY_ERASE functionality.

Cheers

Rcomment-before 16 Jul 2008 10:55 Rcomment-trans Lotje Rcomment-after

How to erase the whole disk ?
Hi all,

Since quite a while I want to erase my harddisk on the secure erase method. hdparm supports

this, but I always get the same error 5.

I use version 6.9

root@Knoppix:/media/hda1# hdparm -V

hdparm v6.9

The first thing I do is ask some info about the disk:

root@Knoppix:/media/hda1# hdparm -I /dev/hda

/dev/hda:

ATA device, with non-removable media

Model Number: SAMSUNG SP0411N

Serial Number: S01JJ50X351236

Firmware Revision: TW100-11

Standards:

Used: ATA/ATAPI-7 T13 1532D revision 0

Supported: 7 6 5 4

Configuration:

Logical max current

cylinders 16383 16383

heads 16 16

sectors/track 63 63

--

CHS current addressable sectors: 16514064

LBA user addressable sectors: 78165360

device size with M = 1024*1024: 38166 MBytes

device size with M = 1000*1000: 40020 MBytes (40 GB)

Capabilities:

LBA, IORDY(can be disabled)

Standby timer values: spec'd by Standard, no device specific minimum

R/W multiple sector transfer: Max = 16 Current = 16

DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5

Cycle time: min=120ns recommended=120ns

PIO: pio0 pio1 pio2 pio3 pio4

Cycle time: no flow control=120ns IORDY flow control=120ns

Commands/features:

Enabled Supported:

* SMART feature set

* Power Management feature set

* Write cache

* Look-ahead

* WRITE_BUFFER command

* READ_BUFFER command

* DOWNLOAD_MICROCODE

* Device Configuration Overlay feature set

* Mandatory FLUSH_CACHE

* SMART error logging

* SMART self-test

Security:

Master password revision code = 65534

16min for SECURITY ERASE UNIT. 16min for ENHANCED SECURITY ERASE UNIT.

HW reset results:

CBLID- above Vih

Device num = 0 determined by CSEL

Checksum: correct

It looks that my disk supports enhanced security erase. Now I set the password, but

this already fail:

root@Knoppix:/media/hda1# hdparm --security-set-pass test /dev/hda

/dev/hda:

Issuing SECURITY_SET_PASS command, password="test", user=master, mode=high

Problem issuing security command: Input/output error

Error: 5

Then I tried to unlock, but because the password setting failed, this doesn't work either.

root@Knoppix:/media/hda1# hdparm --security-unlock test /dev/hda

/dev/hda:

Issuing SECURITY_UNLOCK command, password="test", user=master

Problem issuing security command: Input/output error

Error: 5

And the erase also give an error:

root@Knoppix:/media/hda1# hdparm --security-erase test /dev/hda

/dev/hda:

Issuing SECURITY_ERASE command, password="test", user=master

HDIO_DRIVE_CMD(erase prepare) failed: Input/output error

Can somebody help me to work this out ?

Thanks a lot,

Lotje

No-screenshot

Project Spotlight

WebDraw

A demonstration of server-side mouse tracking using AJAX over HTTP.

93989cd8616dd616a503acb16e8e92b3_thumb

Project Spotlight

Fire.fm

A Firefox extension to access Last.fm.