Command of the week – hdparm

hdparm is a command line for linux where you can tune your settings for your hard drive.  For lots of good info, check out this page at the ubuntu forums:

http://ubuntuforums.org/showthread.php?t=16360

Also the following article from the year 2000:

http://www.linuxdevcenter.com/pub/a/linux/2000/06/29/hdparm.html

One of the main reasons why I bring this up is that I used it to solve some errors I was getting. Now on my current machine, I have a 10GB primary disk that I use to install the O/S I'm using on and a second slave disk that I use to store data.  I've noticed some lags in Hardy Heron when I'm just going around doing my bunsiness of multi-tasking and such and came across the following in my /var/log/messages:

Jun  6 22:41:29 serenity kernel: [  870.447029] hda: dma_intr: status=0x51 { DriveReady SeekComplete Error }

Jun  6 22:41:29 serenity kernel: [  870.447038] hda: dma_intr: error=0x84 { DriveStatusError BadCRC }

Jun  6 22:41:29 serenity kernel: [  870.447042] ide: failed opcode was: unknown

(Yes my machine is named after the ship in Firefly.)

So this is where hdparm came to my rescue. Here were the steps I did to stop getting the above errors:

$ sudo hdparm -i /dev/hda | grep DMA

IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}

DMA modes:  mdma0 mdma1 mdma2

UDMA modes: udma0 udma1 udma2 *udma3 udma4

This tells my that my current UDMA mode was set to udma3. I figured this was wrong since I was getting those errors in my logs, so I decided to try udma4. The way to set it is with using the -X flag on hdparm. To do UDMA, you take the number 64 and add the UDMA mode you want to it. So for udma4 it is 64 + 4 = 68. For DMA you would use 32 and add the MDMA mode to it. So here's me trying udma4:

$ sudo hdparm -X68 -d1 -u1 -m16 -c3 /dev/hda

/dev/hda:

 setting 32-bit IO_support flag to 3

 setting multcount to 16

 setting unmaskirq to 1 (on)

 setting using_dma to 1 (on)

 setting xfermode to 68 (UltraDMA mode4)

 multcount     = 16 (on)

 IO_support    =  3 (32-bit w/sync)

 unmaskirq     =  1 (on)

 using_dma     =  1 (on)

$ sudo hdparm -i /dev/hda | grep DMA

 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}

 DMA modes:  mdma0 mdma1 mdma2

 UDMA modes: udma0 udma1 udma2 udma3 *udma4

Then I ran a test with this setting:

sudo hdparm -Tt /dev/hda

Unfortunately, I was still getting the errors in the logs. Next, I tried the opposite and went to udma0:

$ sudo hdparm -X64 -d1 -u1 -m16 -c3 /dev/hda 

/dev/hda:

 setting 32-bit IO_support flag to 3

 setting multcount to 16

 setting unmaskirq to 1 (on)

 setting using_dma to 1 (on)

 setting xfermode to 64 (UltraDMA mode0)

 multcount     = 16 (on)

 IO_support    =  3 (32-bit w/sync)

 unmaskirq     =  1 (on)

 using_dma     =  1 (on)

Proceeded with a test:

 $ sudo hdparm -Tt /dev/hda

/dev/hda:

 Timing cached reads:   674 MB in  2.00 seconds = 336.31 MB/sec

 Timing buffered disk reads:   26 MB in  3.11 seconds =   8.37 MB/sec

I checked my logs and voila! No more errors.

This entry was posted in software and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *