I am running ubuntu 20.04 LTS (kernel 5.4.0-81-generic) from PXE and I wish to add a local cache. Because I don't want to have a partition on all my devices for caching, I wish to use a ramdisk for that purpose.
I have managed to enable the fsc option during boot with the help of this answer.
However when I run the cachefilesd service, it failes with -95: Operation not supported. This is probably because tmpfs doesn't support user_xattr, which is required.
I have read here that you can compile/patch the kernel to enable user_xattr, though this is a security risk. Besides being a maintenance nightmare, I do not wish to go that far and fiddle around with automating that with every kernel update.
I have read here (german) and this and it's response.
It indicates that you can make a tmpfs, then make a loopback device, format that to ext4 and then run your fs-cache on there.
However, since I'm using PXE and the NFS mount point is /, how do I do that during boot, preferably before cachedfilesd.service is started?
My bootloader (vesamenu.c32)
# [...]
label                   ubuntunfs
        menu label      ^Ubuntu NFS
        text help
Run ubuntu from Network File System.
        endtext
        kernel          ubuntu/boot/vmlinuz
        initrd          ubuntu/boot/initrd.img
        append          root=/dev/nfs nfsroot=192.168.1.5:/srv/tftp/ubuntu,rw,fsc,relatime ip=dhcp rw
# [...]
My fstab
/proc    /proc    proc    defaults   0 0
/sys     /sys     sysfs   defaults   0 0
/dev/nfs /        nfs     defaults,relatime,fsc   1 1
# ramdisk for fs-cache for nfs
tmpfs    /media/ramdisk    tmpfs    defaults,size=5%      0       0
none            /tmp            tmpfs   defaults        0       0
none            /var/run        tmpfs   defaults        0       0
none            /var/lock       tmpfs   defaults        0       0
none            /var/tmp        tmpfs   defaults        0       0
my /etc/cachefilesd.conf
dir /media/ramdisk
tag mycache
brun 90%
bcull 70%
bstop 30%
frun 90%
fcull 70%
fstop 30%
culltable 14