Created
March 28, 2014 05:12
-
-
Save toc21c/9825834 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# cache construct variables | |
CACHE_DEV="/dev/sdb" | |
#SOURCE_DEV="/dev/sdd" | |
SOURCE_DEV="/dev/sdc" | |
CACHE_NAME="test-dmc" | |
# cache device whole size(byte) | |
CACHE_DEV_SZ=$(blockdev --getsize64 ${CACHE_DEV}) | |
SOURCE_DEV_SZ=$(blockdev --getsize64 ${SOURCE_DEV}) | |
# often 4K | |
BLK_SIZE=$(blockdev --getbsz ${CACHE_DEV}) | |
MNT_DEST="/vmImages_iscsi/stg/129.201.00" | |
if [ -z $1 ] ; | |
then | |
echo "usage $0 [ratio] [wb: -w]" | |
exit | |
fi | |
if [ -z $2 ] ; | |
then | |
echo "Write-through mode" | |
else | |
echo "Write-back mode" | |
fi | |
ratio=$1 | |
# capacity(blocks) | |
# ratio by source device | |
CACHE_CAP=$(echo "scale=0; (${SOURCE_DEV_SZ} * ${ratio}/100)/ ${BLK_SIZE}" | bc -l) | |
echo "Ratio : ${ratio}% : ${CACHE_CAP}/${CACHE_DEV_SZ}" | |
# dm-cache setup | |
# write-back | |
./dmc-setup.pl -o ${SOURCE_DEV} -c ${CACHE_DEV} -n ${CACHE_NAME} -s ${CACHE_CAP} $2 | |
#mount cache device | |
mount /dev/mapper/${CACHE_NAME} ${MNT_DEST} | |
sleep 1 | |
dmsetup table ${CACHE_NAME} | |
echo | |
dmsetup status ${CACHE_NAME} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment