Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a Linux server that reads files from a network drive and processes them. In a common scenario, a user will log in and access the same files over and over again. The size of the files varies but the larger ones can be around 50+ Mb. The files seldom change.

I was wondering if it's somehow possible to transparently cache the files. I don't want (or can) change the program the reads the files, nor do I control the protocol by which the files are accessed. I just want something to detect that I access a certain path, copy the file locally (if needed) and then read the file from the local drive.

I've read about Bcache but can't figure out if it's what I need.

Do you have any suggestions?

Thanks, Vadim.

share|improve this question
up vote 4 down vote accepted

Look into cachefilesd. It works almost automatically. All you need to do is this:

  1. Create an ext3 filesystem on the client to house the cache. Put it on whatever local media you want (dedicated partition, LVM LV, etc...) and make it whatever size you want the cache to be.

  2. Mount this filesystem on /var/cache/fscache. Put it in /etc/fstab so it will always mount at boot time.

  3. Install cahefilesd (Debian package cachefilesd)

  4. I think this is the default already, but make sure dir is set to /var/cache/fscache in /etc/cachefilesd.conf.

  5. Add "fsc" to the mount options of the filesystems for which you want to enable the cache. For example: "rw,hard,fsc". Unmount and remount these filesystems.

share|improve this answer
Thanks. Is it also possible on Red Hat? – Vadim Jul 9 '12 at 14:44
Sure, I imagine it is perfectly possible on Red Hat! – Celada Jul 9 '12 at 17:29
It does not worki for sshfs filesystem: #sshfs -o context=system_u:system_r:cachefiles_kernel_t /mnt/ska7 fuse: unknown option `context=system_u:system_r:cachefiles_kernel_t' – Arie Skliarouk Jul 27 '15 at 3:26
rumor is it is fixed in libfuse 3.0: [] – Arie Skliarouk Jul 27 '15 at 3:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .