# Kernel disables hd write cache (SAMSUNG HM641JI hdd)

## Martux

Hello!

I was investigating why my new Samsung R780 laptop with an Core I7 mobile is so slow.

On one point I checked hd-performance with hdaparm on the build in 640GB drive:

```

hdparm -t /dev/sda

/dev/sda:

 Timing buffered disk reads:  92 MB in  3.06 seconds =  30.07 MB/sec

```

That is without write cache. So I tried enabling it and get significant better results:

```

hdparm -t /dev/sda

/dev/sda:

 Timing buffered disk reads: 278 MB in  3.00 seconds =  92.57 MB/sec

```

I tried activating it through /etc/conf.d/hdparm, but the kernel disables it always...

```

Jan  9 21:08:18 aumakua kernel: [  651.325920] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA

Jan  9 21:08:41 aumakua kernel: [  674.493764] ata1: hard resetting link

```

What is going on here? How can this be managed?

EDIT: I forgot: Kernel is gentoo-sources-2.6.37

----------

## Martux

I figured this out:

If set through /etc/conf.d/hdparm, the -W1 option to enable write cache is disabled by the kernel again.

When I wait some minutes after startup and the enable it manually, it stays "on"...

Right now I am copying several hundreds GB to another HD and it is still kept "on".

Of course this affects performance massively, as it changes this i7 machine from laggy crap to a rather useful machine. So any help on how to fix this permanently is highly appreciated!

----------

## Martux

UPDATE: 

I found that when switching from my KDE desktop to the syslog via Ctrl&alt&F12, the write cache gets disabled for all SATA drives.

If put back on manually afterwards, it stays on... until I switch terminal again, and so on.

What is this all about?

----------

## pigeon768

Whenever the drive is reset, the options are reset to their default settings. This reset can happen whenever a drive wakes up from being spun down. I believe that whether the drive resets after being spun down and what the default settings are are drive specific, but it might have something to do with the disk controller. In either case, it is not the kernel driver that is disabling the write cache; the /var/log/messages line is an informational message relaying the results of a query of the state of the hard disk.

What is the output from 'hdparm -I /dev/sda' and 'dmesg'?

----------

## Martux

Thanks for the reply.

Unfortunately I will be stuck on windows until I have a bigger hd.

Strange: It seems not to occure while the drive is put to sleep because I was switching to TTY12 in the middle of a copy process.

When switching back it was resetted  :Sad: 

I also booted from a PCLinuxOS Live USB and there the problem doesn't occur at all. All write caches for all SATA devices are switched on and stay that way... Strange. Is there a kernel parameter which controls this?

Regards,

Marcus

----------

## Martux

I know now what is responsible for this:

Powerdevil...

As soon as the checkmark "energy saving functions of system enabled" is set, this will happen.

Arghhh.

----------

