LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-13-2015, 09:37 AM   #1
kktsuri
LQ Newbie
 
Registered: Jan 2014
Distribution: Mint
Posts: 22

Rep: Reputation: Disabled
Disabling read-cache buffering for a device


Hey all,

I'd like to disable the buffer/read cache when Linux reads from a file and stores it in temporary RAM, so if read again, it can be from RAM instead of disk. But I want to do it on just one storage device (say /dev/sdb).

I'm NOT looking to benchmark the specific storage device. What I'm looking for is to disable read buffering for it, because it is a SSD and I prefer my RAM to be used by cache from the slower hard disk instead of caching SSD.

Linux is not booted from the SSD anyway, since logging would kill it too fast for my use and I need all of its small space for the specialized applications I'm using (where I read from it 99% of the time and barely write).


Anyway my simple question is, can I tell linux to not cache the SSD, or at least prioritize one device for caching over another? If I run out of memory for caching, I'd like it to not discard my hard-disk's cached data, because re-reading data from SSD is much much faster than from HDD so I'd rather have it re-read from the SSD always.

i.e it could cache /dev/sdb but never replacing old cache from /dev/sda, since /dev/sda is priority etc.

Last edited by kktsuri; 05-13-2015 at 09:38 AM.
 
Old 05-13-2015, 10:00 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
You can mount the filesystem with the "sync" option. Note this from the mount man page:

Code:
 sync   All I/O to the filesystem should be done synchronously. In case of media with limited number of write cycles (e.g.  some  flash
        drives) "sync" may cause life-cycle shortening.
 
1 members found this post helpful.
Old 05-13-2015, 12:09 PM   #3
kktsuri
LQ Newbie
 
Registered: Jan 2014
Distribution: Mint
Posts: 22

Original Poster
Rep: Reputation: Disabled
Thanks! I googled and I only saw that sync removes write-caching, didn't know it also works for read-caching.

Though, I'd obviously prefer if it did not disable write-caching but only read-caching. I can workaround it of course, by just remounting it when writing to it (like I said it happens rarer), since write-caching is fine, then remount it back with sync and perhaps read-only so I know I won't mess up by accident.

 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling cache priyadarshan Linux - Newbie 1 02-14-2011 09:10 AM
Disabling Chrome's cache by linking it to /dev/null Changes Linux - Newbie 4 09-28-2010 07:47 AM
[sda] Write cache: enabled, read cache: enabled, doesn't support DPO seskissinger Linux - Software 3 05-16-2008 01:17 PM
Disabling D-cache in linux sekhar Linux - Software 0 06-04-2007 05:27 AM
Help Needed - Logging Users Out and Clearing cache or disabling back/forward buttons anthonysaulnier Programming 0 10-17-2005 11:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration