Turn off Linux file cache

8

1

How do I turn off write cache in Linux? More specifically, SUSE 11?

My problem is that heavy I/O kills the system even if the generating process is a user priority class, and the starved processes are RR/RT class. So my high availability system breaks with lots of timeouts.

I have / mounted on a flash drive, and a few mount points looking into a RAID controller. For the RAID, I want to try to turn the cache off, since it has a cache inside. But if it needs to be system-wide, fine.

So far I used sync option to mount, but it's not quite like turning off the cache.

Any ideas?

n-alexander

Posted 2010-07-05T14:25:11.450

Reputation: 363

General rule to be real-time is not to mix the workloads, especially batch and interactive tasks. If you want a service to be real-time, then put it on a dedicated server. Otherwise, it would be interesting to hear if ionice suggested below would help alleviate the problem. – Dummy00001 – 2010-07-05T22:48:29.897

Answers

5

When mounting your hard drives use -o sync which will turn off write buffering for the drive.

You can also set it up in your fstab:

/dev/sda1    /    reiserfs        sync    0   0

amphetamachine

Posted 2010-07-05T14:25:11.450

Reputation: 1 443

2The OP says he already tried this. – Sjoerd – 2010-07-05T14:31:32.137

yes, that's actually how you turn off file write caching. When I was asking the question I didn't know enough to ask correctly. Thanks! – n-alexander – 2010-08-20T16:49:44.903

1

Maybe drop_caches can help you. It does not seem to disable the cache, merely clear it.

Sjoerd

Posted 2010-07-05T14:25:11.450

Reputation: 1 131

What's wrong with sync? – amphetamachine – 2010-07-05T14:32:52.367

0

For a plain hard disk it would normally be

hdparm -W 0 /dev/sdX

but RAID controllers typically don't pass that through.

You'll have to check the configuration interface of your RAID controller for any options. It might not be possible.

Peter Eisentraut

Posted 2010-07-05T14:25:11.450

Reputation: 6 330

hdparm affects the block device. Linux cache is much higher up – n-alexander – 2010-08-20T16:48:31.380

1I suppose it depends on which "write cache" he means. – Peter Eisentraut – 2010-09-04T11:14:15.563

0

please have a look here: https://superuser.com/a/464382/106740 With http://code.google.com/p/pagecache-mangagement/, you can disable file caches on a per-application level

Robert Metzger

Posted 2010-07-05T14:25:11.450

Reputation: 238