Creating a Bcache Device
Bcache drives are classified into data drives and cache drives. Generally, HDDs are used as data drives, and SSDs are used as cache drives. Perform the following operations on the three Ceph nodes. In the script, the 12 hard drives in /dev/sda-/dev/sdl are data drives of the bcache device, and the 400 GB partition in the NVMe drive is used as the cache drive. This document uses /dev/nvme0n1p$n as an example. The value of n ranges from 13 to 18, which corresponds to the partition value.
In actual situations, the OS drive may be located in an HDD. For example, if the system drive is installed in /dev/sda, the following script cannot be executed directly. Otherwise, an error is reported when the installation progress reaches make-bcache --wipe-bcache -B /dev/sda. Instead, you need to modify the script to ensure that only data drives are operated and other drives such as the OS drive and SSD drive for DB and WAL partitions are not operated.
Therefore, you need to check the dive partitions before creating a bcache device.
1 | lsblk |
As shown in Figure 1, the sda drive is the system drive.
- Create a create_bcache.sh script.
vi create_bcache.sh
Add the following content to the file:#!/bin/bash n=13 for disk in {a..f} do make-bcache -B /dev/sd${disk} -C /dev/nvme0n1p${n} ((n = $(( $n + 1 )))) done n=13 for disk in {g..l} do make-bcache -B /dev/sd${disk} -C /dev/nvme1n1p$n ((n = $(($n + 1)))) done
The parameters in make-bcache -B /dev/sd${disk} -C /dev/nvme0n1p${n} are defined as follows:
- -B: specifies a backend drive (data drive).
- -C: specifies a cache device (for accelerating the data drive).
For example, the backend drive is sdb and the cache device is nvme0n1p13.
make-bcache -B /dev/sdb -C /dev/nvme0n1p13
- Run the script.
1bash create_bcache.sh - Check whether the bcache device is successfully created.
lsblk

If the bcache device can be found under the corresponding data drive and cache drive, the creation is successful.
