Fcache HOWTO
From openSUSE
This page talks about fcache 1.3 (0x03), the last version from Jens Axboe's git repo (but ported to the current Suse Kernel).
Jens Axboe writes in the the log for this patch: "fcache is a frontend cache for a file system that aims to reduce a dominantly repeatable seeky read workload to sequential access. It does this by first running the workload in a priming mode, logging the accesses to the file system on a cache device. Subsequent runs in non-priming mode then access the data sequentially from the frontend cache, instead of punting to the real device.
The primary intended application is to reduce boot time by attaching to the root file system."
More informations about fcache can be found in Jens Axboe's mail to lkm: http://lkml.org/lkml/2006/5/15/46
Fcache will only cache ext3 partitions, so if you use reiserfs for the partition you want to cache you're out of luck.
Contents |
Kernel
Get and install kernel rpms for 10.2 or Factory from the openSUSE build service http://software.opensuse.org/download/home:/frank_ruell/
The name of the kernel is consciously left as kernel-default, so one should be able to use existing kmps.
Init scripts
In /etc/init.d/boot.rootfsck comment the line where the comment says "remount in any case to apply additional options".
Like in the folowing patch:
--- boot.rootfsck 2007/05/24 11:20:06 1.1
+++ boot.rootfsck 2007/05/24 11:20:27
@@ -159,7 +159,7 @@
echo "root file system (/) is NOT being checked."
fi
# remount in any case to apply additional options like xattr
- mount -n -o remount,rw /
+ #mount -n -o remount,rw /
fi
# start with a clean mtab and enter root fs entry
rm -f /etc/mtab*
@@ -182,4 +182,3 @@
esac
rc_exit
If you don't do this, priming will be fired up twice, thus in effect only half of the boot process will be primed.
Boot parameter
Now add the boot parameter "ro" to the boot parameters for your fcache enabled kernel.
For grub this would mean on my system to change in /boot/grub/menu.lst
kernel /boot/vmlinuz-2.6.21-8-default root=/dev/disk/by-id/scsi-SATA_IC25N060ATMR04-_MRG31DKCGLP57K-part6 vga=0x342 resume=/dev/sda3 splash=silent showopts
to
kernel /boot/vmlinuz-2.6.21-8-default root=/dev/disk/by-id/scsi-SATA_IC25N060ATMR04-_MRG31DKCGLP57K-part6 vga=0x342 resume=/dev/sda3 splash=silent showopts ro
Else the partition fcache caches is mounted by initrd read/write without fcache being enabled, which will make fcache fail.
Fstab
You need a not otherwise used partition that fcache can use as cache. All data on this cache partition will be overwritten. (If you don't have a spare partition, you may use your swap partition to at least try out fcache.)
For example, I want to use /dev/sda5 as caching device for fcache. To find out its major and minor nummer I do
d192:~ # file /dev/sda5 /dev/sda5: block special (8/5)
Now specify this partition as cache for the rootfs, change the mount options for /etc/fstab
/dev/disk/by-id/scsi-SATA_IC25N060ATMR04-_MRG31DKCGLP57K-part6 / ext3 acl,user_xattr 1 1
to
/dev/disk/by-id/scsi-SATA_IC25N060ATMR04-_MRG31DKCGLP57K-part6 / ext3 acl,user_xattr,fdev=x/y,fprime 1 1
You get the values for fdev=x/y by running file(1) as shown above. Notice, we also added fprime as mount option.
Now you can shutdown your system, the next boot everything read from harddisc will be written linear to the cache device.
Boot, maybe login and fire up firefox or whatever you do after boot.
After that remove the fprime mount option from /etc/fstab and do a
mount -o remount /
Fcache is now set up. You should regognize that the very decrease of harddisk seeks while booting makes booting itself way faster.
If you do a system-update or somesuch you need to prime fcache again.
Don't forget to remove the fdev mount option, if you change the setup of your harddisks.

