Drop Linux Disc Cache

On this page I found a handy tip to drop the disc cache that Linux keeps in the main memory. I use this to reduce the amount of information written to disc when hibernating using TuxOnIce.

Linux has the tendency to keep all kinds of information cached in the memory. This is very handy when opening programs, but it can be a nousence when you have 2GB memory. Most of the times the disc cache is as large are even twice as large as the actual data in the memory.

When hibernating this results in writing up to 2GB to disk and this can take a while. And TuxOnIce seems not completely stable and crashes during resuming when the disc image is somewhere over 1GB.

So if my memory is filled I run the following commands as root and then I hibernate.
sync; echo 3 > /proc/sys/vm/drop_caches.
The sync command is also very handy for detaching USB drives, because it flushes the caches.

Tags: , , , ,

Leave a Reply