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

My problem is that heavy IO kills the system even if the generating process is 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?

Thanks, Alex

link|improve this question
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 Jul 5 '10 at 22:48
feedback

migrated from stackoverflow.com Jul 5 '10 at 14:38

This question came from our site for professional and enthusiast programmers.

4 Answers

up vote 1 down vote accepted

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
link|improve this answer
2  
The OP says he already tried this. – Sjoerd Jul 5 '10 at 14:31
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 Aug 20 '10 at 16:49
feedback

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

link|improve this answer
What's wrong with sync? – amphetamachine Jul 5 '10 at 14:32
feedback

Can you use ionice on the io-generating process?

link|improve this answer
ionice only works with direct IO. It can be sync or async, but it needs to be direct. Any data that go through cache loose their associated io priority and use the default. So as long as the big writers go through cache they can't be ioniced. – n-alexander Aug 20 '10 at 16:51
feedback

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.

link|improve this answer
hdparm affects the block device. Linux cache is much higher up – n-alexander Aug 20 '10 at 16:48
I suppose it depends on which "write cache" he means. – Peter Eisentraut Sep 4 '10 at 11:14
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.