# Sytem painfully slow (HDD dying?)

## Silenzium

Hey,

my laptop is painfully slow since my last kernel update, but I think it's not necessary the upgrade. My HDD started to make highfrequent noises and this is what smartctl says:

```
smartctl -a /dev/hda

smartctl version 5.38 [i686-pc-linux-gnu] Copyright (C) 2002-8 Bruce Allen

Home page is http://smartmontools.sourceforge.net/

=== START OF INFORMATION SECTION ===

Model Family:     Western Digital Scorpio family

Device Model:     WDC WD2500BEVE-00WZT0

Serial Number:    WD-WXE508E23015

Firmware Version: 01.01A01

User Capacity:    250,059,350,016 bytes

Device is:        In smartctl database [for details use: -P show]

ATA Version is:   8

ATA Standard is:  Exact ATA specification draft version not indicated

Local Time is:    Wed Aug  5 09:07:27 2009 CEST

SMART support is: Available - device has SMART capability.

SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===

SMART overall-health self-assessment test result: PASSED

General SMART Values:

Offline data collection status:  (0x84)   Offline data collection activity

               was suspended by an interrupting command from host.

               Auto Offline Data Collection: Enabled.

Self-test execution status:      (   0)   The previous self-test routine completed

               without error or no self-test has ever 

               been run.

Total time to complete Offline 

data collection:        (9600) seconds.

Offline data collection

capabilities:           (0x7b) SMART execute Offline immediate.

               Auto Offline data collection on/off support.

               Suspend Offline collection upon new

               command.

               Offline surface scan supported.

               Self-test supported.

               Conveyance Self-test supported.

               Selective Self-test supported.

SMART capabilities:            (0x0003)   Saves SMART data before entering

               power-saving mode.

               Supports SMART auto save timer.

Error logging capability:        (0x01)   Error logging supported.

               General Purpose Logging supported.

Short self-test routine 

recommended polling time:     (   2) minutes.

Extended self-test routine

recommended polling time:     ( 115) minutes.

Conveyance self-test routine

recommended polling time:     (   5) minutes.

SCT capabilities:           (0x203f)   SCT Status supported.

               SCT Feature Control supported.

               SCT Data Table supported.

SMART Attributes Data Structure revision number: 16

Vendor Specific SMART Attributes with Thresholds:

ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE

  1 Raw_Read_Error_Rate     0x000f   200   200   051    Pre-fail  Always       -       0

  3 Spin_Up_Time            0x0003   184   183   021    Pre-fail  Always       -       1766

  4 Start_Stop_Count        0x0032   099   099   000    Old_age   Always       -       1301

  5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -       0

  7 Seek_Error_Rate         0x000f   200   200   051    Pre-fail  Always       -       0

  9 Power_On_Hours          0x0032   095   095   000    Old_age   Always       -       3762

 10 Spin_Retry_Count        0x0013   100   100   051    Pre-fail  Always       -       0

 11 Calibration_Retry_Count 0x0012   100   100   051    Old_age   Always       -       0

 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       655

184 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       0

192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       651

193 Load_Cycle_Count        0x0032   199   199   000    Old_age   Always       -       3416

194 Temperature_Celsius     0x0022   111   095   000    Old_age   Always       -       36

196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0

197 Current_Pending_Sector  0x0012   200   200   000    Old_age   Always       -       0

198 Offline_Uncorrectable   0x0010   100   253   000    Old_age   Offline      -       0

199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0

200 Multi_Zone_Error_Rate   0x0009   100   253   051    Pre-fail  Offline      -       0

SMART Error Log Version: 1

No Errors Logged

SMART Self-test log structure revision number 1

Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error

# 1  Short offline       Completed without error       00%        19         -

# 2  Extended offline    Aborted by host               90%        19         -

SMART Selective self-test log data structure revision number 1

 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS

    1        0        0  Not_testing

    2        0        0  Not_testing

    3        0        0  Not_testing

    4        0        0  Not_testing

    5        0        0  Not_testing

Selective self-test flags (0x0):

  After scanning selected spans, do NOT read-scan remainder of disk.

If Selective self-test is pending on power-up, resume after 0 minute delay.

```

Looks pretty ok, doesn't it? But where does the sound come from?

----------

## NeddySeagoon

Silenzium,

You may be about to experience a spin motor bearing failure. Back up the drive if you still can.

As its /dev/hda, what does 

```
hdparm  /dev/hda 
```

show?

----------

## Silenzium

NeddySeagoon,

thanks for your help. Here's the output:

```
# hdparm /dev/hda

/dev/hda:

 multcount     = 16 (on)

 IO_support    =  0 (default) 

 unmaskirq     =  0 (off)

 using_dma     =  1 (on)

 keepsettings  =  0 (off)

 readonly      =  0 (off)

 readahead     = 256 (on)

 geometry      = 30401/255/63, sectors = 488397168, start = 0

```

Here's some more:

```
hdparm -tT /dev/hda 

/dev/hda:

 Timing cached reads:   1698 MB in  2.00 seconds = 849.44 MB/sec

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

Relevant parts of /etc/conf.d/hdparm:

```
hda_args="-B255"

# or you can set options for all PATA drives

pata_all_args="-d1"

# or, you can set hdparm options for all drives

all_args="-d1"

disc0_args="-a256A1c1m16u1"

cdrom0_args="-c1u1"

```

```
# emerge --info

Portage 2.1.6.13 (default/linux/x86/2008.0/desktop, gcc-4.3.2, glibc-2.9_p20081201-r2, 2.6.28-gentoo-r5 i686)

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

System uname: Linux-2.6.28-gentoo-r5-i686-Intel-R-_Pentium-R-_M_processor_1.73GHz-with-gentoo-2.0.1

Timestamp of tree: Thu, 06 Aug 2009 06:15:01 +0000

ccache version 2.4 [enabled]

app-shells/bash:     4.0_p28

dev-java/java-config: 2.1.8-r1

dev-lang/python:     2.4.4-r15, 2.6.2-r1, 3.1

dev-python/pycrypto: 2.0.1-r8

dev-util/ccache:     2.4-r8

dev-util/cmake:      2.6.4-r2

sys-apps/baselayout: 2.0.1

sys-apps/openrc:     0.3.0-r1

sys-apps/sandbox:    2.0

sys-devel/autoconf:  2.13, 2.63-r1

sys-devel/automake:  1.5, 1.7.9-r1, 1.9.6-r2, 1.10.2, 1.11

sys-devel/binutils:  2.19.1-r1

sys-devel/gcc-config: 1.4.1

sys-devel/libtool:   2.2.6a

virtual/os-headers:  2.6.30-r1

ACCEPT_KEYWORDS="x86 ~x86"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-O2 -march=pentium-m -pipe -fomit-frame-pointer"

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/config"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/splash /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c /etc/udev/rules.d"

CXXFLAGS="-O2 -march=pentium-m -pipe -fomit-frame-pointer"

DISTDIR="/usr/portage/distfiles"

FEATURES="ccache distlocks fixpackages parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS="ftp://ftp.wh2.tu-dresden.de/pub/mirrors/gentoo ftp://sunsite.informatik.rwth-aachen.de/pub/Linux/gentoo http://mirror.gentoo.no"

LANG="de_DE@euro"

LC_ALL="de_DE.UTF-8"

LDFLAGS="-Wl,-O1"

LINGUAS="de en en_GB en_US fr nb nb_NO"

MAKEOPTS="-j2"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

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

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/local/portage/layman/xwing /usr/local/portage/layman/sunrise /usr/local/portage"

SYNC="rsync://ftp.wh2.tu-dresden.de/gentoo-portage"

USE="X a52 aac ace acl acpi alsa amr asf audiofile bash-completion berkdb bluetooth branding bzip2 cairo cdda cddb cdparanoia cdr cli cracklib crypt cups dbus directfb dri dts dvd dvdr dvdread dvi emboss encode esd evo exif fam fbcon fbcondecor ffmpeg firefox flac fortran freetype garmin gdbm gif gnuplot gnutls gphoto2 gpm gps gstreamer gtk hal iconv iptc ipv6 isdnlog jabber java jpeg latex ldap libnotify lirc lm_sensors mad matroska mikmod mmx mp3 mpeg mudflap musicbrainz ncurses nls nptl nptlonly nsplugin ogg opengl openmp pam pcre pdf perl pmu png postscript ppds pppd python qt3support qt4 quicktime rar raw readline realmedia reflection samba sdl session spell spl sse sse2 ssl startup-notification svg svga sysfs tcpd theora tiff truetype unicode usb v4l v4l2 vcd vorbis wifi win32codecs x264 x86 xfce xine xinerama xml xorg xscreensaver xulrunner xv xvid zip zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse synaptics evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="de en en_GB en_US fr nb nb_NO" USERLAND="GNU" VIDEO_CARDS="radeon vesa fbdev"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

```

btw: Where do all the ALSA_CARDS come from? I didn't activate them.

Just in case it is a kernel problem (maybe I mixed sth up with the ATA options), here's my kernel config.

btw: I recently switched from fglrx to radeon, I hope that has nothing to do with my slow system.

----------

## NeddySeagoon

Silenzium,

Your hdparm /dev/hda output is OK. you have DMA on, 16 sectors per IRQ set and read ahead turned right up.

Your 50+Mb/sec sequential disk read speed at the outside of the platter is ok too.

If you don't set ALSA_CARDS= in make.conf, you get the full list. Its used by alsa-drivers to know what kernel modules to install.

Most people use kernel provided alsa, so ALSA_CARDS= is not used.

Looking at your kernel,

CONFIG_PREEMPT_VOLUNTARY=y is not the best choice for responsiveness.

Lowe Latency Desktop is better.

CONFIG_HIGHMEM4G=y is only needed if you hae > 1G RAM

CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y is bad for battery life. It runs the CPU flat our all the time.

I use CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND even on my desktop.

You are using the old PATA kernel branch, which s ok and you have # CONFIG_ATA is not set, whis is good as it contains the new libata drivers for your hard drive chip set and you only want one driver loaded per device.

It appears you have a few debug options on. I've not checked them all. You should only enable debugging if you want to work on the kernel code. The effects of debug options varies, from spamming your logs, which slows down what you want to do, to nothing at all (other than kernel bloat) until the option s activated by writing something to /proc.

Go through make menuconfig and turn off all the debugging options.

----------

## Silenzium

NeddySeagoon,

thanks for looking through my kernel config.

 *NeddySeagoon wrote:*   

> Looking at your kernel,
> 
> CONFIG_PREEMPT_VOLUNTARY=y is not the best choice for responsiveness.
> 
> Lowe Latency Desktop is better.
> ...

 

Ok, I switched to low latency. Some months ago, I changed that because of other performance problems.

I do have more than 1 GB of RAM.

 *NeddySeagoon wrote:*   

> CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y is bad for battery life. It runs the CPU flat our all the time.
> 
> I use CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND even on my desktop.

 

I thought cpufreqd is taking care of this (I followed the Gentoo power management guide), but I changed it anyway.

 *NeddySeagoon wrote:*   

> It appears you have a few debug options on. I've not checked them all. You should only enable debugging if you want to work on the kernel code. The effects of debug options varies, from spamming your logs, which slows down what you want to do, to nothing at all (other than kernel bloat) until the option s activated by writing something to /proc.
> 
> Go through make menuconfig and turn off all the debugging options.

 

I deactivated CONFIG_PNP_DEBUG_MESSAGES, but I couldn't find CONFIG_X86_DEBUGCTLMSR, CONFIG_DEBUG_BUGVERBOSE and CONFIG_DEBUG_MEMORY_INIT in "make menuconfig" (I don't want to edit .config directly). The latter two are dependent on EMBEDDED and/or BUG, but both are not active.   :Question: 

I recompiled the kernel and it feels a lot faster (however not perfect - pretty slow while loading web pages and switching between windows for example*). During emerge, it's slow as always despite using PORTAGE_NICENESS=15.  I also got a warning during compilation:

```
[...]

  AR      lib/lib.a

  CC      arch/x86/lib/delay.o

  AS      arch/x86/lib/getuser.o

  CC      arch/x86/lib/memcpy_32.o

  AS      arch/x86/lib/putuser.o

  CC      arch/x86/lib/string_32.o

  CC      arch/x86/lib/strstr_32.o

  CC      arch/x86/lib/usercopy_32.o

  AR      arch/x86/lib/lib.a

  LD      vmlinux.o

  MODPOST vmlinux.o

WARNING: modpost: Found 1 section mismatch(es).

To see full details build your kernel with:

'make CONFIG_DEBUG_SECTION_MISMATCH=y'

  GEN     .version

  CHK     include/linux/compile.h

  UPD     include/linux/compile.h

[...]

```

Following the instructions results in:

```
[...]

  AR      lib/lib.a

  CC      arch/x86/lib/delay.o

  AS      arch/x86/lib/getuser.o

  CC      arch/x86/lib/memcpy_32.o

  AS      arch/x86/lib/putuser.o

  CC      arch/x86/lib/string_32.o

  CC      arch/x86/lib/strstr_32.o

  CC      arch/x86/lib/usercopy_32.o

  AR      arch/x86/lib/lib.a

  LD      vmlinux.o

  MODPOST vmlinux.o

WARNING: vmlinux.o(.cpuinit.data+0x0): Section mismatch in reference from the variable initial_code to the function .init.text:i386_start_kernel()

The variable __cpuinitdata initial_code references

a function __init i386_start_kernel().

If i386_start_kernel is only used by initial_code then

annotate i386_start_kernel with a matching annotation.

  GEN     .version

  CHK     include/linux/compile.h

  UPD     include/linux/compile.h

[...]

```

* Might that be related to the new video driver (radeon)? X uses quite a lot of CPU (40% while switching windows) and I also have some small graphical glitches.

----------

## NeddySeagoon

Silenzium,

Those kernel build warnings are for maintainers.  Maybe the debug options you could not find need to be activated before they use much CPU time.

There are a few more things you can do.  

1. Run the long test provided by smartmontools

2. Get the vendors test software from the drive makers site. Be careful with this as some or all of the tests may be data destructive.

The vendors test software will  often phone home to check your warranty and offer to print you a returned material authorisation if your drive is failing and still under warranty

----------

## mikegpitt

@Neddy:  I don't want to hijack the thread, but you brought up something that I was curious about.  I've never had great battery life on my laptop... maybe 2 hours on the battery until I feel like I should plug it in.  I set my kernel to CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y, since I want things to be snappy, but I also use cpufreqd to change drop to the cpu frequency lower when I'm on battery.

Even though I'm using cpufreqd, would changing this kernel setting to "on demand" improve battery life?

----------

## NeddySeagoon

mikegpitt,

I missed the original poster mentioning cpufreqd. It may make no diference.

I use on demand and the gnome CPU frquency monitor. That gives me close to the advertised battery life on my Acer One.

----------

## energyman76b

performance means that the cpu is always stuck at highest speed.

I also use ondemand - and no cpufreqd - because it is not needed. When I play ut2004 or vegastrike, I set all cores to performance, and back to ondemand afterwards. The energy savings are very high.

About preemption - I have to disagree with Neddy here. In my experience, voluntary preemption gives the best overall results. Lowlatency/forced preemption can totally kill harddisk and cd/dvd disk drive performance while providing little benefits - in my case no benefits at all.

For the op: if a harddisk starts making high pitched noises it is usually the spindle going bad. It can die every moment. The most dangerous thing is to stop the harddisk and restart it, because it puts strain on the spindle's bearings. Also it might move a bit - and the heads won't find any data anymore. Backup everything ASAP and don't let the disk spin down until you did it.

----------

