CentOS7上安装部署bcache模块

本文详细介绍如何在CentOS 7环境下安装bcache模块,并提供内核编译、模块加载及用户态程序bcache-tools的编译过程。此外,还介绍了如何确保bcache模块开机自动加载。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

bcache模块官方文档:
https://www.kernel.org/doc/Documentation/bcache.txt


一、 默认3.10内核不包含bcache模块,需要手动编译ko文件。


1. 首先确认内核版本 uname -r


2. 安装编译内核的必要工具
yum groupinstall "Development Tools" -y
yum install kernel-headers -y


3. 下载内核源码包并解包,以3.10.0-693内核版本为例
mkdir kernel
cd kernel
wget http://vault.centos.org/7.4.1708/os/Source/SPackages/kernel-3.10.0-693.el7.src.rpm
rpm2cpio ./kernel-3.10.0-693.el7.src.rpm | cpio -idmv


4. 修改bcache编译选项后编译内核
sudo sh -c 'yes "" | make oldconfig'
vi .config修改下面一行

CONFIG_BCACHE=m


make


5. 启用bcache模块
cd drivers/md/bcache/
xz -z bcache.ko
cp bcache.ko.xz /usr/lib/modules/3.10.0-693.el7.x86_64/kernel/drivers/md/
depmod -A
modinfo bcache
modprobe -f bcache


6. 使bcache模块开机加载
#cd /etc/sysconfig/modules/
#vim bcache.modules
在文件中添加如下内容 
#!/bin/sh 
/sbin/modprobe -f bcache 


#chmod 755 bcache.modules   //这一步至关重要
#reboot


二、 bcache的管理依赖用户态程序bcache-tools,需要先编译打rpm包


1.获取源码:
git clone https://github.com/g2p/bcache-tools.git


2.打包
yum install uuid-devel openssl libblkid-devel udev
根据Makefile自己写一个bcache-tools.spec
rpmbuild -ba bcache-tools.spec




三、 ###############  在CentOS7上进行安装 ##################


1.在CentOS7.3及以下版本,先升级内核版本到3.10.0-693,CentOS7.4无需升级
rpm -Uvh kernel*


2.安装bcache内核模块并启动加载
cp bcache.ko.xz /usr/lib/modules/3.10.0-693.el7.x86_64/kernel/drivers/md/

echo "#!/bin/sh" > /etc/sysconfig/modules/bcache.modules
echo "/sbin/depmod -A" >> /etc/sysconfig/modules/bcache.modules
echo "/sbin/modprobe -f bcache" >> /etc/sysconfig/modules/bcache.modules
chmod 755 /etc/sysconfig/modules/bcache.modules


3.安装bcache-tools,rpm由上面的步骤打包产生
rpm -ivh bcache-tools-1.0.8-1.el7.x86_64.rpm


4. reboot
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值