You are not logged in.

#1 2012-04-13 17:23:39

Nanthiel
Member
From: Slovenia
Registered: 2009-09-20
Posts: 148

[Solved] Hard drive clicking (in Arch, but not Ubuntu)

Hey everyone,

I noticed that my hard drive makes clicking noises in Arch, but not in Ubuntu.

hdparm -B are always set to 254 in both systems. In Arch though, I get several clicks and smartctl -a (grepped Load_Cycle) increases with each one. It doesn't do this in Ubuntu.

hdparm -i and plain hdparm output are identical.

How may I go about troubleshooting this? Is it a kernel version thing?

Thanks, Nanthiel

P.S. Something else odd that I noticed. The read-ahead value is set to 3072 in Ubuntu upon removing the AC adapter. I can't set it to that manually, so what's going on? Trying that manually (-a option), I get "bad/missing filesystem-read-ahead value (0..2048)" in both systems.

Solution
See mac1202's answer about the idle3 timer.

Last edited by Nanthiel (2012-10-27 16:15:03)

Offline

#2 2012-04-13 17:38:05

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [Solved] Hard drive clicking (in Arch, but not Ubuntu)

Investigate what Ubuntu does, if you can. Try other values than 254.

I use:

    # Fix the ridiculous hard drive activity, for 8930g
    # https://bugs.launchpad.net/ubuntu/+bug/104535
    # smartctl -a /dev/sda | grep Load
    /sbin/hdparm -B 255 /dev/sda > /dev/null

And:

    # http://hep.kbfi.ee/index.php/IT/KernelTuning
    # Default is 256.
    blockdev --setra 4096 /dev/sda

And also, kinda related, for good measure:

    # https://bbs.archlinux.org/viewtopic.php?id=131703
    # https://bbs.archlinux.org/viewtopic.php … 4#p1002264
    # Default is 128. Optimizes a larger group of requests.
    echo 512 > /sys/block/sda/queue/nr_requests

Offline

#3 2012-04-13 19:58:13

Nanthiel
Member
From: Slovenia
Registered: 2009-09-20
Posts: 148

Re: [Solved] Hard drive clicking (in Arch, but not Ubuntu)

I have experimented with several hdparm -B values. Now, both Arch and Ubuntu are at 254 and only Arch clicks.

Thank you for the blockdev pointer, this was what I was looking for to set readahead with (seems hdparm -a is something else?).

I don't know where to investigate for the difference, what else could be important? Why does Arch park my disk heads and Ubuntu doesn't?

Is there some sort of dump I could do and diff the versions?

Offline

#4 2012-04-13 20:12:00

shulamy
Member
From: israel
Registered: 2010-09-11
Posts: 452

Re: [Solved] Hard drive clicking (in Arch, but not Ubuntu)

it can be just because  the systems are located on diferent parts of the disk,

and some sectors of arch are almost bad.

try a bad sector check and listen if there is noises at the arch part.

ezik

Offline

#5 2012-04-13 20:12:16

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [Solved] Hard drive clicking (in Arch, but not Ubuntu)

Nanthiel wrote:

I don't know where to investigate for the difference

Here's the source code.

Figure out which Ubuntu package runs hdparm, then look at the code.

Google for the model of your hard drive, plus "hdparm".

Edit: There's also this hdparm setting:
-M     Get/set Automatic Acoustic Management (AAM) setting.

Last edited by brebs (2012-04-13 20:30:42)

Offline

#6 2012-04-13 20:52:08

Nanthiel
Member
From: Slovenia
Registered: 2009-09-20
Posts: 148

Re: [Solved] Hard drive clicking (in Arch, but not Ubuntu)

I don't think there are bad sectors, the computer is only a month old.

I've checked the places in Ubuntu where hdparm gets run, and the options are equal to mine.

While messing with the settings I might've actually affected something, the heads haven't parked for an hour. hmm

I added "blockdev --setra 4096 /dev/sda" and copied over Ubuntu's vm.* kernel settings.

Maybe it will still park. But even if it doesn't, it held on for an hour, which is good enough!

brebs: my drive doesn't support acousting management, sadly.

I will report if it starts clicking again ... this is really odd.

(EDIT)

Yes it didn't stop clicking, but I've run Ubuntu for nearly 2 days just to check, and it starts clicking when I leave it alone (but oddly enough not during use). It seems the same for Arch now so I'll just tag this as [solved]. I am guessing that this is a hardware thing (Google says this is a common problem for WD hard drives that try to conserve power aggressively firmware-side).

I will copy my »power-saving« script here which goes into /etc/acpi just for good measure. Tips on further improving it are welcome.

#!/bin/sh

function common
{
  # Hard drive
  hdparm -B 254 -S 0 /dev/sda > /dev/null
  blockdev --setra 4096 /dev/sda

  # Bus power control
  for item in /sys/bus/*/devices/*/power/control; do
    echo -n auto > "$item"
  done
}

function battery
{
  # NMI watchdog
  sysctl -q kernel.nmi_watchdog=0

  # ASPM
  echo -n powersave > /sys/module/pcie_aspm/parameters/policy

  # Kernel write mode
  sysctl -q vm.laptop_mode=5 \
            vm.dirty_ratio=60 \
            vm.dirty_background_ratio=40 \
            vm.dirty_expire_centisecs=3000 \
            vm.dirty_writeback_centisecs=60000

  # Multi-core scheduler power saving
  echo -n 1 > /sys/devices/system/cpu/sched_mc_power_savings
  echo -n 1 > /sys/devices/system/cpu/sched_smt_power_savings

  # Sound card
  echo -n 1 > /sys/module/snd_hda_intel/parameters/power_save
  echo -n Y > /sys/module/snd_hda_intel/parameters/power_save_controller

  # Wireless
  iwconfig wlan0 power on

  # Screen
  echo -n 1 > /sys/module/i915/parameters/i915_enable_rc6
  echo -n 1 > /sys/module/i915/parameters/i915_enable_fbc
  echo -n 0 > /sys/class/backlight/acpi_video1/brightness
  xset dpms 60 75 300 2> /dev/null
}

function ac_adapter
{
  # NMI watchdog
  sysctl -q kernel.nmi_watchdog=1

  # ASPM
  echo -n default > /sys/module/pcie_aspm/parameters/policy

  # Kernel write mode
  sysctl -q vm.laptop_mode=0 \
            vm.dirty_ratio=10 \
            vm.dirty_background_ratio=5 \
            vm.dirty_expire_centisecs=3000 \
            vm.dirty_writeback_centisecs=500

  # Multi-core scheduler power saving
  echo -n 0 > /sys/devices/system/cpu/sched_mc_power_savings
  echo -n 0 > /sys/devices/system/cpu/sched_smt_power_savings

  # Sound card
  echo -n 0 > /sys/module/snd_hda_intel/parameters/power_save
  echo -n N > /sys/module/snd_hda_intel/parameters/power_save_controller

  # Wireless
  iwconfig wlan0 power off

  # Screen
  echo -n 0 > /sys/module/i915/parameters/i915_enable_rc6
  echo -n -1 > /sys/module/i915/parameters/i915_enable_fbc
  echo -n 3 > /sys/class/backlight/acpi_video1/brightness
  xset dpms 300 360 700 2> /dev/null
}

# ??? No idea why this is needed.
set $*

if [ "$1" == "common" ]; then
  common
elif [ "$1" == "ac_adapter" ]; then
  case "$4" in
    00000000)
      # On battery
      logger "[acpi] On battery"
      battery
      ;;
    00000001)
      # On AC
      logger "[acpi] On AC power"
      ac_adapter
      ;;
  esac
elif [ "$1" == "button/lid" ]; then
  case "$3" in
    open)
      # Restore brightness
      logger "[acpi] Restoring brightness"
      sleep 1 # Delay for the screen to turn on
      if [ "$(cat /sys/class/power_supply/AC0/online)" -gt 0 ]; then
        echo -n 3 > /sys/class/backlight/acpi_video1/brightness
      else
        echo -n 0 > /sys/class/backlight/acpi_video1/brightness
      fi
      ;;
    close)
      xset dpms force off 2> /dev/null
      ;;
  esac
fi

Last edited by Nanthiel (2012-04-15 16:06:02)

Offline

#7 2012-10-17 16:18:02

altercation
Member
From: Seattle
Registered: 2011-05-15
Posts: 136
Website

Re: [Solved] Hard drive clicking (in Arch, but not Ubuntu)

Nanthiel wrote:
# ??? No idea why this is needed.
set $*

I liked your powersaving script. This is tangential but since the set $* code confused me when I first came across it, and I saw your note in the script regarding it, I thought I'd note here why it is used.

In the case of, say, an acpi handler.sh script, the arguments to the script are getting passed as a single value. So, for example, the handler.sh script would be called with the equivalent of:

/etc/acpi/handler.sh "button/prog1 PROG1 00000080 00000000 K"

But this means that in the handler.sh script $1 == button/prog1 PROG1 00000080 00000000 K, whereas you really want to break that up and parse it bit by bit. using set $* passes each space delimited element of all the arguments passed to handler.sh as it's own argument, so $1 becomes "button/prog" in my example here. Note that this is why we can't use set "$*" (quoted) since that would pass everything as a unified argument again.


Ethan Schoonover
Precision Colors - http://ethanschoonover.com/solarized

Offline

#8 2012-10-21 09:42:45

mac1202
Member
Registered: 2011-05-24
Posts: 33

Re: [Solved] Hard drive clicking (in Arch, but not Ubuntu)

Maybe you can try this software available in AUR http://idle3-tools.sourceforge.net/

The idle3 timer seems to be a power on only setting. That means that the drive needs to be powered OFF and then ON to use the new setting.

Last edited by mac1202 (2012-10-21 09:46:58)

Offline

#9 2012-10-27 16:14:31

Nanthiel
Member
From: Slovenia
Registered: 2009-09-20
Posts: 148

Re: [Solved] Hard drive clicking (in Arch, but not Ubuntu)

Oh wow, I haven't heard a click since disabling the idle3 timer. Thanks!
(I just hope I have tested for long enough — a couple of days.)

Offline

Board footer

Powered by FluxBB