Ubuntu – How to disable the prefetch cache

cache

I run a few Ubuntu servers that have a load of django sites running on them. The sites and the httpd start at boot and after that (apart from me SSHing in to update it or using bzr to update websites) nothing else gets run on it.

At the moment over half the ram is allocated as cache. This isn't a problem because cache usually makes space or a little bit of it slips into swap (again, this doesn't really bother me) but I don't see the need for it.

Is there a quick way to disable the cache? This is more of an experiment than anything else so it would be handy to know how to turn it back on again.

Best Answer

This blog post by Andrea Righi suggests that there isn't a config option in the kernel, but it also sketches out a little glibc wrapper library to just set the O_DIRECT flag on every call to open().

This should have the same effect as disabling the read-buffer completely.

Additionally, the OpenOffice wiki has a couple of methods to do cold-start testing. This isn't what you want, but I thought I include it anyway.