Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

QuickStart Recipe for Ubuntu 11.10

msayapin edited this page Mar 13, 2012 · 5 revisions

This page describes setting up and removing Flashcache on Ubuntu 11.10 using an existing root partition. It looks like there is a bug in the github wiki parser that combines all the lines. Until they fix it, just view the source to use this document.

Table of Contents

Resources

Instructions

# Install pre-reqs
apt-get install git build-essential dkms linux-headers-`uname -r`

# Get flashcache source
git clone https://github.com/facebook/flashcache.git

# Add the "lazy" create option here:
wget https://github.com/guppy/flashcache/commit/1ea19b6fbf453e1e2955aef5488c708f5191ca68.patch
patch -p1 <1ea19b6fbf453e1e2955aef5488c708f5191ca68.patch

# Build and install the source (as root)
make -f Makefile.dkms

Setting up flashcache on a md device

# Install boot support
make -f Makefile.dkms boot_conf

# Find the UUID of the volume you want to cache:
ls -la /dev/disk/by-uuid/

# Create the flashcache device
# Assuming /dev/sdb is your flashcache SSD, replace with your actual device
flashcache_create -v -l -p back -b 4k fc-md /dev/sdb /dev/disk/by-uuid/(UUID_FOUND_ABOVE)

vi /etc/fstab
# Comment out the line with the device you want to cache
# Add a new line for the flashcache similar this:
/dev/mapper/fc-md / ext4 relatime,nobarrier 0 1

# Update the initial RAM disk to add the FC modules and helper apps
update-initramfs -k ALL -u

# Set some optional options
vi /etc/sysctl.conf

#####################
# flashcache settings
#####################

# disable writing dirty cache data at shutdown (do this only if you really trust FC)
dev.flashcache.fast_remove = 1

# change the reclaim policy to LRU from FIFO 
dev.flashcache.reclaim_policy = 1

# do not write "stale" data to disk until evicted due to lack of space
dev.flashcache.fallow_delay = 0

# reboot and enjoy the speed

# Test with 
ls -la /dev/mapper/
# To see which device is fc-md
# Then
iostat 
# To see that the fc-md device is seeing the same i/o as the underlying block device

Removing Flashcache from a Boot Volume

# First, ensure that dev.flashcache.fast_remove = 0 and reboot to minimize potential lost data
# Edit fstab
vi /etc/fstab
# Comment out the flashcache line and un-comment the original device line

# Reboot to recovery mode (hold left shift during boot)
# Mount / using the non-flashcache drive
mount -o relatime /dev/md0 /

# Remove the FC device mapper device
dmsetup remove fc-md

# Remove FC special SSD signature (change /dev/sdb with whatever your FC device is)
flashcache_destroy /dev/sdb

# Done, continue booting normally
exit