How to release the Linux disk cache

0

For whatever reason you may need to free the disk cache at some point. Since Linux 2.6.16 the interface /proc/sys/vm/drop_caches has been available to simplify this process.

First we run the sync command before dropping the cache. Doing this will ensure that all memory in the cache is updated and all dirty pages are synchronized before dropping the cache. You can safely skip this step but if you have any dirty pages in your disk cache the system will refuse to release them.
# sync

The next step is echoing “3” to the /proc/sys/vm/drop_caches file which will signal the OS to release the pagecache, dentries and inodes.
# echo 3 > /proc/sys/vm/drop_caches

Share.