# slow harddrive access

## Bung

Hi, thanks for looking,

I recently did a fresh install and am having some issues with my harddrive access. Whenever my computer is writing to the harddrive (like unpacking files in portage or downloading a large file) my computer will get slow/buggy . My music will skip, and windows and video will move slow. Someone in a chat said to make sure i had PREEMPT set in my kernel, so i have CONFIG_PREEMPT=y and CONFIG_PREEMPT_BKL=y, however im still getting the issue.

I have the basic partition scheme from the install docs, (boot) (swap) (root). Boot is ext2 and root is ReiserFS... here is some more info, hope it helps...

Thanks for any help!

emerge --info

```

Portage 2.1-r2 (default-linux/x86/2006.0, gcc-4.1.1, glibc-2.3.6-r4, 2.6.17-gentoo-r4 i686)

=================================================================

System uname: 2.6.17-gentoo-r4 i686 Intel(R) Pentium(R) M processor 1700MHz

Gentoo Base System version 1.6.15

app-admin/eselect-compiler: [Not Present]

dev-lang/python:     2.4.3-r1

dev-python/pycrypto: 2.0.1-r5

dev-util/ccache:     [Not Present]

dev-util/confcache:  [Not Present]

sys-apps/sandbox:    1.2.17

sys-devel/autoconf:  2.13, 2.59-r7

sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2

sys-devel/binutils:  2.16.1-r3

sys-devel/gcc-config: 1.3.13-r3

sys-devel/libtool:   1.5.22

virtual/os-headers:  2.6.11-r2

ACCEPT_KEYWORDS="x86"

AUTOCLEAN="yes"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-O2 -march=i686 -pipe"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config"

CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/java-config/vms/ /etc/revdep-rebuild /etc/terminfo"

CXXFLAGS="-O2 -march=i686 -pipe"

DISTDIR="/usr/portage/distfiles"

FEATURES="autoconfig distlocks metadata-transfer sandbox sfperms strict"

GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"

MAKEOPTS="-j2"

PKGDIR="/usr/portage/packages"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/portage/local/layman/portage-xgl"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="x86 X alsa apache2 apm arts avi berkdb bitmap-fonts cdr cli crypt cups dlloader dri dvd eds emboss encode esd foomaticdb fortran gdbm gif gnome gpm gstreamer gtk gtk2 imlib ipv6 isdnlog java jpeg kde libg++ libwww mad mikmod motif mp3 mpeg mysql ncurses nls nptl nsplugin ogg opengl oss pam pcre pdflib perl png pppd python qt3 qt4 quicktime readline reflection sdl session spell spl ssl symlink tcpd truetype truetype-fonts type1-fonts udev unicode vorbis xml xmms xorg xv zlib elibc_glibc input_devices_keyboard input_devices_mouse kernel_linux userland_GNU video_cards_fglrx video_cards_vesa"

Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, PORTAGE_RSYNC_EXTRA_OPTS

```

make.conf

```

CFLAGS="-O2 -march=i686 -pipe"

CHOST="i686-pc-linux-gnu"

CXXFLAGS="${CFLAGS}"

MAKEOPTS="-j2"

ACCEPT_KEYWORDS="x86"

VIDEO_CARDS="fglrx vesa"

INPUT_DEVICES="keyboard mouse"

USE="X dri apache2 mysql pcre session unicode -doc symlink cdr dvd java nsplugin"

#SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage"

#GENTOO_MIRRORS="http://distfiles.gentoo.org http://www.ibiblio.org/pub/Linux/distributions/gentoo"

#PORTAGE_BINHOST="https://e.ututo.org.ar/i686"

#PKGDIR="/home/bung/binhost/"

PORTDIR_OVERLAY="/usr/portage/local/layman/portage-xgl"

PORTAGE_NICENESS="10"

```

P.S. I had to set that portage niceness because of this problem, it helped a bit, but not fully. Again its not just portage, its whenever Im writing/extracting files, things get slow.

P.P.S. If you notice anything else in my config thats iffy, let me know, im noob!

----------

## Gentree

hdparm -tT /dev/hda will give you some info of drive speed . also check dmesg and /var/log files for any errors relating to drive errors

tail -f /var/log/messages

 :Cool: 

----------

## Bung

Hi, thanks for the tips.

I dont see any error messages in dmesg (or when the comp is loading up) apart from fsck.ReiserFS not found.

This is a fresh install, however I had gentoo on here before, and it worked fine. 

Ok with "hdparm -tT /dev/hda" I get the following;

/dev/hda:

 Timing cached reads:   1808 MB in  2.00 seconds = 902.89 MB/sec

 Timing buffered disk reads:   10 MB in  3.54 seconds =   2.83 MB/sec

However, when I have music playing, this command does NOT make it stutter or make my computer slow down at all. So I dont think this is a valid test.

I added a little CPU/Mem monitor just to see if maybe it was my ram or something, and tried downloading a file. While downloading the file, every 5 seconds my music will skip, and my cpu monitor (not to mention my little blue cpu light) flashes. While unpacking the file, my CPU monitor goes to full and my system becomes nearly inoperable. I really think I got something setup wrong. Please, any help would really be appreciated, I dont want to spend another 3 days doing the fresh install all over.

Here is a little info about the harddrive stuff in dmesg, however Im thinking this really must be some kernel option Ive missed, or some incompatibility between important system utilities .. 

```

# less dmesg | grep ide

BIOS-provided physical RAM map:

CPU: After generic identify, caps: a7e9fbbf 00000000 00000000 00000000 00000180 00000000 00000000

CPU: After vendor identify, caps: a7e9fbbf 00000000 00000000 00000000 00000180 00000000 00000000

Boot video device is 0000:01:00.0

Linux video capture interface: v1.00

ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx

Probing IDE interface ide0...

Probing IDE interface ide1...

ide0 at 0x1f0-0x1f7,0x3f6 on irq 14

ide1 at 0x170-0x177,0x376 on irq 15

# less dmesg | grep hda

Kernel command line: root=/dev/hda3

hda: FUJITSU MHT2080AH, ATA DISK drive

hda: max request size: 128KiB

hda: 156301488 sectors (80026 MB) w/8192KiB Cache, CHS=65535/16/63

hda: cache flushes supported

 hda: hda1 hda2 hda3

ReiserFS: hda3: found reiserfs format "3.6" with standard journal

ReiserFS: hda3: using ordered data mode

ReiserFS: hda3: journal params: device hda3, size 8192, journal first block 18, max trans len 1024, max batch 900, max commit age 30, max trans age 30

ReiserFS: hda3: checking transaction log (hda3)

ReiserFS: hda3: replayed 5 transactions in 0 seconds

ReiserFS: hda3: Using r5 hash to sort names

Adding 506036k swap on /dev/hda2.  Priority:-1 extents:1 across:506036k

```

Thanks again for any help!

----------

## Bung

I was also suggested in #gentoo to set the following in my kernel:

go to processor type and features and set the timer frequency to 1000

preemption model is low latency desktop (this was already set)

in block layer that you choose deadline for your io scheduler

Unfortunately after booting to this kernel I tried installing acroread which downloads and unpacks a large file, and I still have the same problem. My system will laagggg.

----------

## razze

Hello!

Make sure you have DMA enabled for the drive. Can you please post the output of #hdparm -Ii /dev/hda as the buffered disk reads are waaaaay to low for a properly configured system (I believe it should be something around 20 MB/s for an ide HD)

----------

## Gentree

```
bash-3.1#hdparm -tT /dev/hda

/dev/hda:

 Timing cached reads:   1332 MB in  2.01 seconds = 664.31 MB/sec

 Timing buffered disk reads:  158 MB in  3.00 seconds =  52.64 MB/sec

bash-3.1#

```

your disk may be older than mine but you are v slow there.

I have had stuttery kernels before . You could try mm-sources in ~x86 or some of the patch sets in unsupported like no-sources I use. Very responcive.

as suggested above check your DMA settings poss due to duff or unsuitable IDE cable.

Fix you disk speed first then look at mm or other kernel if not happy.

 :Cool: 

----------

## Bung

Thanks for responding guys,

In the Device Drivers -> ATA/ATAPI/MFM/RLL section I already have, Is that ok:

[*]       Generic PCI bus-master DMA support      

[ ]         Force enable legacy 2.0.X HOSTS to use DMA   

[*]         Use PCI DMA by default when available   

# hdparm -Ii /dev/hda

```

/dev/hda:

 Model=FUJITSU MHT2080AH, FwRev=006C, SerialNo=NP00T4825K6E

 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs }

 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4

 BuffType=DualPortCache, BuffSize=8192kB, MaxMultSect=16, MultSect=off

 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=156301488

 IORDY=yes, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}

 PIO modes:  pio0 pio1 pio2 pio3 pio4

 DMA modes:  mdma0 mdma1 mdma2

 UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5

 AdvancedPM=yes: mode=0x80 (128) WriteCache=enabled

 Drive conforms to: ATA/ATAPI-6 T13 1410D revision 3a:  ATA/ATAPI-2 ATA/ATAPI-3 ATA/ATAPI-4 ATA/ATAPI-5 ATA/ATAPI-6

 * signifies the current active mode

ATA device, with non-removable media

        Model Number:       FUJITSU MHT2080AH

        Serial Number:      NP00T4825K6E

        Firmware Revision:  006C

Standards:

        Used: ATA/ATAPI-6 T13 1410D revision 3a

        Supported: 6 5 4 3

Configuration:

        Logical         max     current

        cylinders       16383   16383

        heads           16      16

        sectors/track   63      63

        --

        CHS current addressable sectors:   16514064

        LBA    user addressable sectors:  156301488

        device size with M = 1024*1024:       76319 MBytes

        device size with M = 1000*1000:       80026 MBytes (80 GB)

Capabilities:

        LBA, IORDY(cannot be disabled)

        bytes avail on r/w long: 4      Queue depth: 1

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

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

        Advanced power management level: 128 (0x80)

        Recommended acoustic management value: 254, current value: 254

        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:

           *    READ BUFFER cmd

           *    WRITE BUFFER cmd

           *    Host Protected Area feature set

           *    Look-ahead

           *    Write cache

           *    Power Management feature set

                Security Mode feature set

           *    SMART feature set

           *    Mandatory FLUSH CACHE command

           *    Device Configuration Overlay feature set

           *    Automatic Acoustic Management feature set

                SET MAX security extension

                Power-Up In Standby feature set

           *    Advanced Power Management feature set

           *    DOWNLOAD MICROCODE cmd

           *    SMART self-test

           *    SMART error logging

Security:

        Master password revision code = 65534

                supported

        not     enabled

        not     locked

                frozen

        not     expired: security count

        not     supported: enhanced erase

        80min for SECURITY ERASE UNIT.

HW reset results:

        CBLID- above Vih

        Device num = 0 determined by the jumper

Checksum: correct

```

----------

## Gentree

that's fine.

just looking at your dmesg, try grep -i  or grep for IDE.

I think you will find a msg about the slow down if it's cable related.

 :Cool: 

----------

## razze

can you try 

```
# hdparm -d /dev/hda
```

 to verify that DMA is really enabled. My example:

```
#hdparm -d /dev/hdc

/dev/hdc:

 using_dma    =  1 (on)
```

If it shows DMA off then run 

```
#hdparm -d 1 /dev/hda
```

to enable DMA.

----------

## Gentree

look all suboptions under  PCI IDE chipset support in ATA/IDE section . make sure you have your mobo chipset support selected.

read the help on those items if you're not clear. 

That should be a nice fast disk giving respectable timings simlar to mine.

 :Cool: 

----------

## Bung

thanks again for the help thus far fellas

Ok at first it looks like my dma was off:

```

# hdparm -d /dev/hda

/dev/hda:

 using_dma    =  0 (off)

# hdparm -d 1 /dev/hda

/dev/hda:

 setting using_dma to 1 (on)

 HDIO_SET_DMA failed: Operation not permitted

 using_dma    =  0 (off)

```

So I tried two things at once. I selected the only INTEL IDE chipset support suboption, recompiled my kernel and rebooted.

Once I rebooted to my new kernel, I ran # hdparm -d 1 /dev/hda .. and dma is/was ON! Yay!

Ive just tried downloading/compile some stuff, and my computer isnt laggy anymore!!! 

Thanks guys!!!

----------

## .:chrome:.

 *Bung wrote:*   

> go to processor type and features and set the timer frequency to 1000
> 
> preemption model is low latency desktop (this was already set)
> 
> in block layer that you choose deadline for your io scheduler

 

these settings doesn't improve hard disk performance and they can slow down some systems!

kernel isn't a toy!

----------

## Gentree

Glad we got you going, Bung. 

 *Quote:*   

> kernel isn't a toy!

 

yes it is!  It's like coloured plastic bricks, just a bit more complicated.

Once you get past the stage of banging them together you start to find out how to make a wall.   :Very Happy: 

----------

## Gentree

just looked back over your posts.

if the message was fsck.reiserfs not found (pay attention to detail when posting) you need reiserfsprogs.

emerge -p world will probably show this as [N] , new.

personally I suggest you forget reiserfs, its rather slow for most things (see namesys' own data) and gets slower fairly quickly due to fragmentation.

Unless you feel ready for a non-std kernel and reiser4 (the above indicates you could hold off a bit on that one) I suggest you user ext3 for root partition.

out of interest how about posting you timings now.

 :Cool: 

----------

## Bung

hey man, thanks again

i am installing reiserfsprogs now, cheers...

here are my timings:

# hdparm -tT /dev/hda

/dev/hda:

 Timing cached reads:   1552 MB in  2.00 seconds = 775.44 MB/sec

 Timing buffered disk reads:   56 MB in  3.27 seconds =  17.12 MB/sec

thanks for the tip about ext3, if its possible to change my drive format without reinstalling (ill google that) then I will switch over.

----------

## Gentree

read up on  hdparm , that still seems a bit sluggish, you may be able to tweek it up.

 *Quote:*   

> thanks for the tip about ext3, if its possible to change my drive format without reinstalling (ill google that) then I will switch over.

 

well you sure dont need to reinstall gentoo. If you have the space just make a new partition as ext3 and find yourself a live CD (conrad is good but almost any distro liveCD will do.) boot to the CD , mount you old and new paritions and copy across. You must not copy a running root partition so dont be tempted to try !!

```
cd /mnt/srcdir

cp -ax /mnt/destdir/* .

```

 you'll need to mkdir the two dirs , call 'em what you want.

then edit grub . duplicate the entry you currently have so it is still available if needed . Then just change one line in the copy to point to the new partition instead of the old.

Final change , mount the new partition at a temp locatation /tmp/newdir then edit etc/fstab to indicate the correct mount device for root partition. ie same change you made for grub.

You have just leart how to do a clone backup of your system. You can boot to either at this stage from grub.

Have fun (and pay attention to detail !)

 :Cool: 

----------

## Gentree

PS if you have assigned all free space to root partition you may like to look at the gparted liveCD . It's a great tool for resizing and the liveCD will let you do the formatting and the above copying as well.

 :Cool: 

----------

## srwalter

Another thing that can cause this stuttering, particularly as regards music playback, is a poor choice for the block scheduler.  I'm not sure if it is any longer the case, but it used to be that the default setting could cause some applications (i.e., music players) to be starved when a big read/write transaction was going on.  I've found that the "cfq" scheduler works well.  

"cat /sys/block/hda/queue/scheduler" will show you what choices you have and which one you're currently using (assuming you have plain IDE, sda if you're using SATA)

"echo cfg > /sys/block/hda/queue/scheduler" would set your scheduler to cfq.  This would need to be done after every boot, so it could be put in /etc/conf.d/local.start

----------

## Gentree

 *me wrote:*   

> read up on hdparm , that still seems a bit sluggish, you may be able to tweek it up.

   I just googled your drive model and realised its a 5400rpm . That may be all you get.

You could still try the other hdparm options like readahead tho' , wont do any harm and you may boost it a bit.

you're obviously pretty happy with 17.12 compared to what it was.

 :Cool: 

----------

