Build a home server - part 7
Configure Flashcache
Add
Enable Flashcache (please check Robert Vojcik's blogg)
Edit
Edit
Done!
Part 8 - Configure LVM for snapshots.
root@ohlala:~# cd /usr/src/
root@ohlala:/usr/src# git clone git://anonscm.debian.org/collab-maint/flashcache.git
Cloning into 'flashcache'...
root@ohlala:/usr/src# cd flashcache/
root@ohlala:/usr/src/flashcache# make
root@ohlala:/usr/src/flashcache# make clean
root@ohlala:/usr/src/flashcache# make install
root@ohlala:/usr/src/flashcache# make -f Makefile.dkms boot_conf
root@ohlala:/usr/src/flashcache# vi /etc/sysctl.conf
Add
#####################
# Flashcache settings
#####################
#
# Using Writethrough
#
# (All modes) Global caching mode to cache everything
dev.flashcache.md1+data-ftest.cache_all = 1
# (All modes) Change the reclaim policy to LRU from FIFO
dev.flashcache.md1+data-ftest.reclaim_policy = 1
Enable Flashcache (please check Robert Vojcik's blogg)
Edit /etc/default/flashcache
:#
# FlashCache Configuration#
# FlashCache configured ?
FLASH_CACHE_START=YES
# FlashCache binaries
FLASH_CACHE_BIN=/sbin
# New Flashcache device
FLASH_CACHE_DEV=fcache
# Original data device
DATA_DEV=/dev/mapper/data-ftest
# Cache device - Fast disk / SSD
CACHE_DEV=/dev/md1
# block size
BLOCK_SIZE=4k
# cache type (-p back|around|thru)
CACHE_TYPE=thru
Edit /etc/init/flashcache-init
. Do not forget to chmod a+x /etc/init.d/flashcache-init.
#!/bin/bash
### BEGIN INIT INFO
# Provides: flashcache-init
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Prepare flashcache device during boot time
# Description: Create flashcache device during boot
### END INIT INFO
# debian lenny
# update-rc.d flashcache-init start 27 S . stop 45 0 6 .
# Load Configuration
. /etc/default/flashcache
export PATH=$PATH:$FLASH_CACHE_BIN:/usr/bin:/usr/sbin/
function do_start {
if ! [[ "$FLASH_CACHE_START" = "YES" ]] ; then
echo " --- Flashcache not configured or turned off"
exit 0
fi
echo " --- Starting FlashCache"
echo -n " --- Loading kernel module..."
if modprobe flashcache ; then
echo "OK"
else
echo "FAILED"
exit 1
fi
if [[ "$CACHE_TYPE" == "back" ]] ; then
echo " --- Trying to load FlashCache - $CACHE_TYPE"
if flashcache_load $CACHE_DEV; then
echo " --- Loading FlashCache OK - $CACHE_TYPE"
else
echo " --- ERROR: Problem during FlashCache loading"
exit 1
fi
fi
if [[ "$CACHE_TYPE" == "thru" ]] ; then
echo " --- Trying to initialize FlashCache, type: $CACHE_TYPE"
if flashcache_create -v -p $CACHE_TYPE -b $BLOCK_SIZE $FLASH_CACHE_DEV $
CACHE_DEV $DATA_DEV; then
echo " --- Initializing FlashCache OK, type: $CACHE_TYPE"
else
echo " --- ERROR: Problem during FlashCache initialization - typ
e: $CACHE_TYPE"
exit 1
fi
fi
if [[ "$CACHE_TYPE" = "around" ]] ; then
echo " --- Trying to initialize FlashCache, type: $CACHE_TYPE"
if flashcache_create -v -p $CACHE_TYPE -b $BLOCK_SIZE $FLASH_CACHE_DEV $
CACHE_DEV $DATA_DEV; then
echo " --- Initializing FlashCache OK, type: $CACHE_TYPE"
else
echo " --- ERROR: Problem during FlashCache initialization, type
: $CACHE_TYPE"
exit 1
fi
fi
}
function do_stop {
echo " --- Stopping FlashCache."
if dmsetup remove $FLASH_CACHE_DEV ; then
echo " --- Successfully removed."
exit
else
echo " --- ERROR: Some problems during remove."
exit 1
fi
}
case "$1" in
"start")
do_start
;;
"stop")
do_stop
;;
*)
cat << EOF
Initialization script for FlashCache
Usage: $0 <start|stop>
EOF
exit 1
;;
esac
Edit
/etc/rc.local:
#
# mount the cached file system
#
echo "\n *** Mounting cached filesystem /ftest (/etc/rc.local) ***"
mount -v -t ext4 -O user_xattr,nobarriers /dev/mapper/fcache /ftest
Edit
/etc/fstab
to make a note about your cached file system/dev/mapper/fcache /ftest ext4 noauto,user_xattr,nobarrier 0 2
Done!
Part 8 - Configure LVM for snapshots.
Kommentarer
Trackback