Search:  
Gentoo Wiki

Fcache


This article is outdated. Please update this article with new information to match with the current portage tree and gentoo releases, and remove information about really old versions of software, then remove {{Update}} from this article's source.


Contents

Introduction

Fcache is a remapping cache that sits between the file system and block device. Its primary goal is to speed up boot-up time in linux. Read more from Linux Kernel Mailing List Archives.

Note: Your root partition must be ext3 for fcache to work at this time.
Note: Using Reiser4 with an fcache enabled kernel, data loss might occur: http://marc.theaimsgroup.com/?l=reiserfs&m=115892815019185&w=2

Kernel configuration

Fcache needs a patched kernel. If you use ck-sources, 2.6.17-ck1 already has it, so no additional patching is required.

If your kernel doesn't come patched, you will need to patch the kernel manually. NOTE: You need 2.6.17 series kernel for this patch.

Code: Patching the kernel
cd /usr/src/linux
wget http://www.kernel.org/pub/linux/kernel/people/ck/patches/2.6/2.6.17/2.6.17-ck1/patches/fs-fcache-v2.1.patch
patch -p1 < fs-fcache-v2.1.patch

Next we need to enable fcache in kernel's config.

Linux Kernel Configuration: Enabling fcache
 Device Drivers  --->
     Block devices  --->
         [*] Boot frontend cache driver

Now recompile and reboot into your new kernel.

Creating partition for fcache

Fcache needs partition in which it stores the cache data. The partition must be formated in ext3, but there should be support for other file systems in the future. I'm not sure how much disk space is actually needed, but I created 512M partition and it should be enough.

Read gentoo documentation on how to create and format a new partition if you don't know already.

Configuring boot-scripts and running fcache for the first time

Now we need to edit /etc/init.d/checkroot to start fcache on bootup. Find line that says:

File: File /etc/init.d/checkroot
mount -n -o remount,rw / &> /dev/null

And change it to:

File: File /etc/init.d/checkroot
 # This is the original
 #mount -n -o remount,rw / &> /dev/null
 # This is for first boot with fcache
 mount -n -o remount,rw,fcache_dev=#/#,fcache_prime=1 / &> /dev/null
 # This is for subsequent boots with fcache
 #mount -n -o remount,rw,fcache_dev=#/#,fcache_prime=0 / &> /dev/null

NOTE: You must change fcache_dev=#/# as appropriate for your fcache device in all of the examples. The fcache_dev takes a string describing the major and minor number of the cache device. For example if your fcache device is /dev/sda3, it would be fcache_dev=8/3.

Now reboot and let it do the caching (booting should be a little slower this time).

When you want to stop the caching (or priming), run:

Code: Stopping the priming
mount / -o remount,fcache_dev=#/#,fcache_prime=0

Next, change the lines we edited in /etc/init.d/checkroot to:

File: File /etc/init.d/checkroot
# This is the original
#mount -n -o remount,rw / &> /dev/null
# This is for first boot with fcache
#mount -n -o remount,rw,fcache_dev=#/#,fcache_prime=1 / &> /dev/null
# This is for subsequent boots with fcache
mount -n -o remount,rw,fcache_dev=#/#,fcache_prime=0 / &> /dev/null

Now reboot and enjoy faster bootup.

Retrieved from "http://www.gentoo-wiki.info/Fcache"

Last modified: Wed, 01 Oct 2008 08:30:00 +0000 Hits: 3,073