Compiling and Installing the Bcache
CentOS 7.6
- Obtain the bcache source code and save it to /home.
- Decompress the source package.
1 2
cd /home unzip bcache-swc-v0.2.0.zip - Compile and obtain the bcache driver module.
1 2
cd /home/bcache-swc-v0.2.0/drivers/md/bcache make -C /lib/modules/$(uname -r)/build M=$(pwd)
When running the make command, select the build directory of the kernel where bcache.ko needs to be run for compilation based on the site environment.
- View the reference count of the bcache module.
lsmod | grep -w bcache
Check that the reference count is 0.
bcache 458752 0
- Check that bcache.ko is not loaded in the current environment.
modprobe -r bcache
- (Optional) Delete the installation directory.
rm -rf /lib/modules/$(uname -r)/kernel/drivers/md/bcache
If the bcache is not installed, skip this step.
- Create an installation directory.
mkdir -p /lib/modules/$(uname -r)/kernel/drivers/md/bcache
- Copy bcache.ko to the installation directory.
cp bcache.ko /lib/modules/$(uname -r)/kernel/drivers/md/bcache
- Compress bcache.ko.
xz -z /lib/modules/$(uname -r)/kernel/drivers/md/bcache/bcache.ko
- Update the dependency of bcache.ko.
depmod -a
- Update initramfs.
dracut --add-drivers bcache -f /boot/initramfs-$(uname -r).img
- Check whether bcache.ko is successfully installed.
lsinitrd /boot/initramfs-$(uname -r).img | grep bcache.ko.xz -rw-r--r-- 1 root root 997136 Nov 30 11:45usr/lib/modules/4.14.0-115.el7a.0.1.aarch64/kernel/drivers/md/bcache/bcache.ko.xz ls -l /lib/modules/$(uname -r)/kernel/drivers/md/bcache/bcache.ko.xz -rw-r--r-- 1 root root 997136 Nov 30 11:45/lib/modules/4.14.0-115.el7a.0.1.aarch64/kernel/drivers/md/bcache/bcache.ko.xz
- Load bcache.ko.
modprobe bcache
openEuler 20.03
- Download the bcache source code and to /home.
- Decompress the source package.
unzip openeuler-kernel-openEuler-1.0-LTS.zip
- Replace the system header file temporarily.
mv /usr/src/kernels/$(uname -r)/include/trace/events/bcache.h /usr/src/kernels/$(uname -r)/include/trace/events/bcache.h.bak cp /home/kernel/include/trace/events/bcache.h /usr/src/kernels/$(uname -r)/include/trace/events/bcache.h
- Compile and obtain the bcache driver module.
1 2
cd /home/kernel/drivers/md/bcache make -C /lib/modules/$(uname -r)/build M=$(pwd)
When running the make command, select the build directory of the kernel where bcache.ko needs to be run for compilation based on the site environment.
- Replace it with the original file.
mv /usr/src/kernels/$(uname -r)/include/trace/events/bcache.h.bak /usr/src/kernels/$(uname -r)/include/trace/events/bcache.h
- View the reference count of the bcache module.
lsmod | grep -w bcache
Check that the reference count is 0.
bcache 458752 0
- Check that bcache.ko is not loaded in the current environment.
modprobe -r bcache
- Delete the installation directory.
rm -rf /lib/modules/$(uname -r)/kernel/drivers/md/bcache
- Create an installation directory.
mkdir -p /lib/modules/$(uname -r)/kernel/drivers/md/bcache
- Copy bcache.ko to the installation directory.
cp bcache.ko /lib/modules/$(uname -r)/kernel/drivers/md/bcache
- Compress bcache.ko.
xz -z /lib/modules/$(uname -r)/kernel/drivers/md/bcache/bcache.ko
- Update the dependency of bcache.ko.
depmod -a
- Update initramfs.
dracut --add-drivers bcache -f /boot/initramfs-$(uname -r).img
- Check whether bcache.ko is successfully installed.
lsinitrd /boot/initramfs-$(uname -r).img | grep bcache.ko.xz -rw-r--r-- 1 root root 997136 Nov 30 11:45usr/lib/modules/4.19.90-2012.4.0.0053.oe1.aarch64/kernel/drivers/md/bcache/bcache.ko.xz ls -l /lib/modules/$(uname -r)/kernel/drivers/md/bcache/bcache.ko.xz -rw-r--r-- 1 root root 997136 Nov 30 11:45/lib/modules/4.19.90-2012.4.0.0053.oe1.aarch64/kernel/drivers/md/bcache/bcache.ko.xz
- Load bcache.ko.
modprobe bcache
Parent topic: Installing the Bcache