I use NFS to share media to computers around my house. Unfortunately one of the machines is on a slow wireless link, is there a way to cache network shares on the local disk for performance?
2 Answers
Stefan led me down the right track. This will work on any system 12.04 and newer.
Your filesystem will also need extended attribute support. If you're using EXT4 you're fine, if you're using EXT3 you'll need to ensure your filesystem is mounted with the user_xattr attribute.
Here's how I set it up on the client machine, you don't need to do anything on the server side.
First, install the user space daemon:
sudo apt-get install cachefilesdThen turn it on by editing
/etc/default/cachefilesdand changing the run line toRUN=yesEnsure your NFS mount in
/etc/fstabhas anfscoption. Don't forget to remount it after you've made the changes. Here's my excerpt (modify to your needs):192.168.1.115:/home/jorge /home/jorge/Backup nfs fscStart the service:
sudo /etc/init.d/cachefilesd start
Configuration of the cache is done in /etc/cachefilesd.conf, see the references for what the setting options are.
References:
- Linux Magazine
/usr/share/doc/cachefilesd/howto.txt.gz/usr/share/doc/cachefilesd/README.gz- How do I enable extended attributes on ext4?
- 70,934
- 124
- 466
- 653
-
Does it happen to know how to apply the same on `/etc/auto.master` ? – sorin Apr 03 '12 at 09:41
-
Be aware that there is a bug which can cause the `cachefilesd` daemon to run at 100% CPU: https://www.redhat.com/archives/linux-cachefs/2014-February/msg00001.html https://bugzilla.redhat.com/show_bug.cgi?id=485314 – akaihola Mar 18 '15 at 07:28
-
2At least as of Ubuntu 14.04, rw,hard are default, and intr is deprecated. So the only option you're using that has effect these days is fsc – Andrew Wagner Aug 28 '17 at 14:16
-
@AndrewWagner Please submit an edit to the article! – Jorge Castro Sep 02 '17 at 20:36
I'm not sure if there is any way to do this currently with Ubuntu 10.04 LTS.
However, the newer versions of the Linux kernel include a feature called FS-Cache & CacheFS, which sounds exactly like what you (and I) want.
Also see Local Caching For Network Filesystems.
- 4,120
- 6
- 30
- 34
-
Thanks, it's a great feature. Unluckily it lacks write support :(. – Javier Rivera Sep 22 '10 at 17:18