CentOS7下使用BCache+SSD固态硬盘对HDD硬盘进行缓存提速

文章目录[隐藏]

前言

如题,HDD的4K读取性能堪忧,但是便宜+大容量。在部分应用中,只需要4k读取速度高就行了,因此使用SSD做只读缓存是个不错的选择。

编译安装BCache

CentOS7内核并没有自带BCache,因此需要自己编译安装:



sudo yum install git libuuid libuuid-devel

git clone http://evilpiepirate.org/git/bcache-tools.git

cd bcache-tools

make

sudo make install

配置缓存

首先要开启BCache的模块:



modprobe bcache

make-bcache -B /dev/mapper/fedora_virthost-home 

make-bcache -C /dev/sda1

modprobe bcache

然后配置缓存



echo /dev/mapper/fedora_virthost-home > /sys/fs/bcache/register

echo /dev/sda1 > /sys/fs/bcache/register

mkfs.ext4 /dev/bcache0

mount /dev/bcache0 /home   #挂载在任意位置都行

ls /sys/fs/bcache/  #查看uuid

echo 766e3ca5-f2db-44c9-97cc-13a97b32d348 > /sys/block/bcache0/bcache/attach #这里是自己磁盘的uuid

BCache使用文档

官方文档,什么教程都不一定靠谱,尽量看官方的吧:


This article is under CC BY-NC-SA 4.0 license.
Please quote the original link:https://www.liujason.com/article/678.html
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy