Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

4/29/2020 Administration, Let it be anything on a Server

More Create Blog Sign In

Administration, Let it be anything on a Server


Have a go at it here

WEDNESDAY, MARCH 18, 2009

Flushing Linux Disk Cache in 2.6 Kernel.


Followers
Followers (0)
First of all, I would prefer informing you that you may
not be required to flush the Disk Cache used, as 2.6 kernel's
Follow
memory management is equipped well enough to handle the
memory request for new applications or existing applications by
Blog Archive
freeing up unused or least used Disk buffer cache.
▼ 2009 (1)
Still, you may be required to flush the cache periodically in a few ▼ March (1)
scenarios,
Flushing Linux Disk Cache in
2.6 Kernel.

Either your monitoring system is not well designed to


check the cached parameter of the free output from linux,
which inturn results in incident tickets being raised with
low on memory alerts when there would be sufficient
memory available for applications when they eventually
require memory

If there is more of a swapping activity taking place due to


the swappiness defined. (This is more unlikely to happen)

Before performing activites to flush the cache, you need to run a


'sync' to instruct the kernel to write all the finished modification
from the cache to the disk.

Modifying /proc/sys/vm/drop_caches file with specific values


would instruct the kernel to perform the corresponding
operations on the disk buffer cache.You can just echo the value
into the file to have the modifications intact till the next reboot.

as like, #echo 1>/proc/sys/vm/drop_caches

0=is the default value, with this value, the kernel doesn't
clear anything from cache unless memory deliberately
required by other applications.
1=Flush the pagecache alone from Disk Buffer Cache
2=Flush the dentries and inodes
3=Flush pagecache, dentries and inodes

https://os-db-admin.blogspot.com 1/3
4/29/2020 Administration, Let it be anything on a Server

Though these operation look threatening, they actually


donot harm the system by any means. The reason behind that
is, any change to the drop_caches file would make the kernel
drop only the clean caches, and not the dirty ones.

clean cache, is the information available in the cache which is in


sync with the disk or in other words which is already written to
the disk and is maintained in the cache to speed up future
reads.
where as dirty cache is all that you need to keep safe as those
information are not written to the disk yet.

Since, the changes made to drop_caches in turn result


in only flushing of clean caches, there is no real harm caused by
the flushing other than the loss of read performance of those
data when read for the first time after the flush (if you are
clearing pagecache).

If any change to the drop_caches file is required to be made


permenant, you can make it persistant among reboots by
making an entry in the /etc/sysctl.conf file.

"vm.drop_caches=which ever value as required"

If you have modified your drop_caches file and you donot have
an entry for vm.drop_caches in the sysctl.conf as well, and you
are unsure of what the system will boot up with, you can always
check for the value to which vm.drop_caches parameter is set
with by checking the sysctl -a output.

as like,
#sysctl -a grep vm.drop_caches
vm.drop_caches = 0
#

Hope, this would have left you with a good picture of how
to clear disk buffer cache and what it is about, though I donot
recommend you to flush the buffer unless you have performance
test run requirement or you have got caught in into the
monitoring tools which donot detect the caching properly.

That's it for today folks, will meet you soon with some other
interesting topic ...

***Raghav***
Posted by Raghav at 12:29 AM No comments:
Labels: #Drop_caches #MemoryTuning

Home

https://os-db-admin.blogspot.com 2/3

You might also like