bcache使用

bcache使用


bcache简介

Bcache is a Linux kernel block layer cache. It allows one or more fast disk drives such as flash-based solid state drives (SSDs) to act as a cache for one or more slower hard disk drives.
Bcache目前已被集成到Linux 3.10内核中,但是centos7默认是不支持bcache模块的。所以需要重新编译内核。

下载内核代码

As an ordinary user, not root, create a build tree based on a ~/rpmbuild/ directory:

[user@host]$ mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
[user@host]$ echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros

安装源码包和工具

[root@host]# yum install rpm-build redhat-rpm-config asciidoc hmaccalc perlExtUtils-Embed pesign xmlto
[root@host]# yum install audit-libs-devel binutils-devel elfutils-devel elfutils-libelfdevel
[root@host]# yum install ncurses-devel newt-devel numactl-devel pciutils-devel python-devel zlib-devel
[root@host]# yum install gcc net-tools bc bison

安装内核代码

[user@host]$ rpm -i http://vault.centos.org/7.2.1511/updates/Source/SPackages/kernel-3.10.0-514.10.2.el7.src.rpm 2>&1 | grep -v exist

到目前为止,源码包与工具包已经安装完毕,开始解压和准备源文件

[user@host]$ cd ~/rpmbuild/SPECS
[user@host SPECS]$ rpmbuild -bp --target=$(uname -m) kernel.spec

编译内核

需要安装kernel-devel,这时/usr/src/kernels就会生成内核源码
yum install kernel-devel(注意是否与系统版本一致)

make oldconfig
make menuconfig
go to "device drivers" -> "Multiple devices driver support (RAID and LVM)" -> "Block device as cache" enable it!
save and exit
make prepare
make scripts
拷贝Module.symvers
cp /usr/src/kernels/3.10.0-514.10.2.el7.x86_64/Module.symvers ./
make M=drivers/md/bcache

把驱动文件拷贝到系统默认加载路径下

cp drivers/md/bcache/bcache.ko /lib/modules/3.10.0-693.21.1.el7.x86_64/kernel/drivers/md/
生成模块间的依赖关系 depmod -a
加载模块 modprobe bcache

配置系统系统自动加载bcache模块

vi /etc/sysconfig/modules/bcache.modules
添加modprobe bcache
chmod +x /etc/sysconfig/modules/bcache.modules

你可能感兴趣的:(存储)