


Example tutorial for configuring the bcache module
1. Prerequisite: The bcache module needs to be configured in the kernel
##1.1 Check
-Whether it exists in the kernel: check whether the /sys/fs/bcache directory exists, it does not mean that there is no bcache in the kernel -Whether it exists as a kernel module: check /lib/modules/<$version> Does the /kernel/drivers/md/bcache directory exist? If it does not exist, it means that there is no bcache kernel module - If there is no bcache after checking the above two steps, it means that the kernel is not configured to compile bcache, and you need to configure and compile a new one yourself. Kernel (you need to pay attention to the version when downloading the kernel, the bcache function is only available in 3.10 and above)1.2 Compile the new kernel
$ wget "" $ rpm2cpio ./kernel-3.10.0-514.el7.src.rpm | cpio -idmv //提取rpm包内容,获取内核:linux-3.10.0-514.el7.tar.xz$ make menuconfig //内核配置 Device Drivers ->Multiple devices driver support (RAID and LVM) -><*> Block device as cache $ make bzImage (V=1) //编译内核$ make modules //编译内核模块$ make modules_install //拷贝内核模块的.ko文件到/lib/modules下$ make install //拷贝initrd和bzImage到boot目录下,并修改开机启动配置文件$ reboot //重启,根据菜单选择对应内核版本进入
2. Compile and install
//获取bcache-tools工具(以下两个网址任选其一)$ git clone http://evilpiepirate.org/git/bcache-tools.git$ git clone https://github.com/g2p/bcache-tools.git//安装前需要两个依赖包pkg-config和libblkid-dev$ yum -y install pkg-config libblkid-dev//编译安装bcache-tools$ make$ make install
3. Deployment method
3.1 Create bcache device
$ -bcache -C <cache-device> -B <backing device>--B -C - -b 结果:有几个backing device就会对应生成几个/dev/
<br>
example: the default block and bucket sizes of 512B and 128kB are used. The block size should match the backing devices sector size which will usually be either 512 or 4k . The bucket size should match the erase block size of the caching device with the intent of reducing write amplification. For example, using a HDD with 4k sectors and an SSD with an erase block size of 2MB this command would look like
# make-bcache --block 4k --bucket 2m -C /dev/sdy
##3.2 Add backing device - 1. Create a back-end device
$ make-bcache -B <backing-device> 结果:生成对应的设备/dev/bcache<n>
$ -la /sys/fs/bcache $ <CSET-UUID> > /sys/block/bcache<n>/bcache/
<br>
3.3 Delete the back-end device - 1 , detach and unbind the backing device
$ -la /sys/fs/bcache/ $ <CSET-UUID> > /sys/block/bcache<n>/bcache/
- 2. Delete the back-end device
$ > /sys/block/bcache<N>/bcache/
3.4 Add caching device
##-1. Create caching device $ make-bcache -C <cache device> 结果:在/sys/fs/bcache目录下生成对应的CACHE SET UUID
注意:有可能设备本身有残余数据,需要使用wipefs清理掉
$ wipefs -a /dev/sda


-2. Attach, associated with bcache device
$ echo <CSET-UUID> > /sys/block/bcache<n>/bcache/attach 解释:通过后端设备attach缓存设备,cache device才能开始缓存,backing device才能被缓存
Prerequisite: Make sure that no backing device is using it (can be viewed through lsblk)Explanation: - The existence of the cache device can be verified through / Understand the cache set uuid corresponding to the sys/fs/bcache directory
- After unregistering the uuid, the cache device is considered deleted$ echo 1 > /sys/fs/bcache/<cache set uuid>/unregister 结果:再看/sys/fs/bcache目录下就没有这个cache设备的uuid了
3.6 Format bcache and mount it using
$ mkfs.xfs /dev/bcache<n> //格式化设备为xfs文件系统$ mount /dev/bcache<n> /mnt //挂载设备到/mnt目录进行访问
4. Operation
4.1 Check the running status
$ cat /sys/block/bcache<n>/bcache/state
- clean: everything is ok, the cache is clean.
- dirty: This means everything is set up fine and you have writeback enabled, the cache is dirty.
- inconsistent: You are encountering a problem because the background device is out of sync with the cache device.
$ cat /sys/block/bcache<n>/bcache/dirty_data
// 设置缓存模式(默认writethrough)$ echo <cache mode> > /sys/block/bcache<N>/bcache/cache_mode// 查看缓存模式$ cat /sys/block/bcache<N>/bcache/cache_mode
[writethrough] writeback writearound none
4.5 Configuration information backing device is in the /sys/block/bcache cache device is in the /sys/fs/bcache/ Changes to the configuration information in /sys are temporary Yes, restarting will invalidate it. If you want to set the current configuration at startup, you need to create a conf configuration file in /etc/tmpfile.d/, for example /etc/tmpfile.d/my-bcache.conf: w /sys/block/bcache0/bcache/sequential_cutoff - - - - 1 $ bcache-super-show /dev/sd<n>
w /sys/block/bcache0/bcache/cache_mode - - - - writeback
(To set, in a persistent fashion, the sequential cutoff for bcache0 to 1 MB and write back)
The above is the detailed content of Example tutorial for configuring the bcache module. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Magnet link is a link method for downloading resources, which is more convenient and efficient than traditional download methods. Magnet links allow you to download resources in a peer-to-peer manner without relying on an intermediary server. This article will introduce how to use magnet links and what to pay attention to. 1. What is a magnet link? A magnet link is a download method based on the P2P (Peer-to-Peer) protocol. Through magnet links, users can directly connect to the publisher of the resource to complete resource sharing and downloading. Compared with traditional downloading methods, magnetic

How to use mdf files and mds files With the continuous advancement of computer technology, we can store and share data in a variety of ways. In the field of digital media, we often encounter some special file formats. In this article, we will discuss a common file format - mdf and mds files, and introduce how to use them. First, we need to understand the meaning of mdf files and mds files. mdf is the extension of the CD/DVD image file, and the mds file is the metadata file of the mdf file.

CrystalDiskMark is a small HDD benchmark tool for hard drives that quickly measures sequential and random read/write speeds. Next, let the editor introduce CrystalDiskMark to you and how to use crystaldiskmark~ 1. Introduction to CrystalDiskMark CrystalDiskMark is a widely used disk performance testing tool used to evaluate the read and write speed and performance of mechanical hard drives and solid-state drives (SSD). Random I/O performance. It is a free Windows application and provides a user-friendly interface and various test modes to evaluate different aspects of hard drive performance and is widely used in hardware reviews

foobar2000 is a software that can listen to music resources at any time. It brings you all kinds of music with lossless sound quality. The enhanced version of the music player allows you to get a more comprehensive and comfortable music experience. Its design concept is to play the advanced audio on the computer The device is transplanted to mobile phones to provide a more convenient and efficient music playback experience. The interface design is simple, clear and easy to use. It adopts a minimalist design style without too many decorations and cumbersome operations to get started quickly. It also supports a variety of skins and Theme, personalize settings according to your own preferences, and create an exclusive music player that supports the playback of multiple audio formats. It also supports the audio gain function to adjust the volume according to your own hearing conditions to avoid hearing damage caused by excessive volume. Next, let me help you

Get started easily: How to use pip mirror source With the popularity of Python around the world, pip has become a standard tool for Python package management. However, a common problem that many developers face when using pip to install packages is slowness. This is because by default, pip downloads packages from Python official sources or other external sources, and these sources may be located on overseas servers, resulting in slow download speeds. In order to improve download speed, we can use pip mirror source. What is a pip mirror source? To put it simply, just

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension

NetEase Mailbox, as an email address widely used by Chinese netizens, has always won the trust of users with its stable and efficient services. NetEase Mailbox Master is an email software specially created for mobile phone users. It greatly simplifies the process of sending and receiving emails and makes our email processing more convenient. So how to use NetEase Mailbox Master, and what specific functions it has. Below, the editor of this site will give you a detailed introduction, hoping to help you! First, you can search and download the NetEase Mailbox Master app in the mobile app store. Search for "NetEase Mailbox Master" in App Store or Baidu Mobile Assistant, and then follow the prompts to install it. After the download and installation is completed, we open the NetEase email account and log in. The login interface is as shown below

Cloud storage has become an indispensable part of our daily life and work nowadays. As one of the leading cloud storage services in China, Baidu Netdisk has won the favor of a large number of users with its powerful storage functions, efficient transmission speed and convenient operation experience. And whether you want to back up important files, share information, watch videos online, or listen to music, Baidu Cloud Disk can meet your needs. However, many users may not understand the specific use method of Baidu Netdisk app, so this tutorial will introduce in detail how to use Baidu Netdisk app. Users who are still confused can follow this article to learn more. ! How to use Baidu Cloud Network Disk: 1. Installation First, when downloading and installing Baidu Cloud software, please select the custom installation option.
