Compiling and Installing the Kernel
Obtaining the Kernel Source Code
- Create a directory and go to the directory.
1 2
mkdir -p /home/kernel-bcache cd /home/kernel-bcache - Download the kernel source package to the /home/kernel-bcache directory.
Download address: http://vault.centos.org/7.6.1810/updates/Source/SPackages/

- Decompress the source package.
1 2
rpm2cpio kernel-alt-4.14.0-115.10.1.el7a.src.rpm | cpio -divm tar -xvf linux-4.14.0-115.10.1.el7a.tar.xz - Install the dependency.
1yum -y install rpm-build m4 gcc xmlto asciidoc openssl-devel hmaccalc python-devel newt-devel perl-ExtUtils-Embed elfutils-devel zlib-devel binutils-devel bison audit-libs-devel java-devel numactl-devel pciutils-devel ncurses-devel createrepo genisoimage net-tools git bc
Replacing the Bcache Module
- Obtain the bcache source code and save it to /home.
Download address: https://github.com/kunpengcompute/bcache/releases/tag/swc-v0.2.0
- Decompress the source package.
1 2
cd /home unzip bcache-swc-v0.2.0.zip - Replace the bcache.
1cp -rf /home/bcache-swc-v0.2.0/drivers/md/bcache /home/kernel-bcache/linux-4.14.0-115.10.1.el7a/drivers/md/
Modifying the Kernel Configuration
- Obtain the kernel configuration file.
1 2
cd /home/kernel-bcache/linux-4.14.0-115.10.1.el7a cp ../kernel-alt-4.14.0-aarch64.config .config - Configure the bcache module.
1make menuconfig
- Choose .

- Press Enter to access the next-level menu, and then choose .

- Press Enter to access the next-level menu, choose , and press M to select the configuration.

- Click Exit twice to return to the first-level menu.

- Choose .
- Change the kernel page size to 4 KB.
- Choose .

- Press Enter to access the next-level menu, and choose .

- Press Enter to access the next-level menu, and press Space to choose 4 KB.

- Click Exit twice to save the setting and exit.


- Choose .
- Modify the configuration file.
1vi .config
Add #aarm64 to the first line.

- Verify the configuration file.
- Overwrite the default configuration file.
1cp .config ../kernel-alt-4.14.0-aarch64.config
Type Y.
Creating a Kernel RPM Package
- Repack the kernel source code.
1 2 3 4
cd /home/kernel-bcache tar -cvf linux-4.14.0-115.10.1.el7a.tar linux-4.14.0-115.10.1.el7a rm -f linux-4.14.0-115.10.1.el7a.tar.xz xz -z linux-4.14.0-115.10.1.el7a.tar - Create an rpmbuild directory.
1 2 3
mkdir -p /home/rpmbuild cd /home/rpmbuild mkdir -p BUILD RPMS SOURCES SPECS SRPMS - Change the default rpmbuild path.
1vi /root/.rpmmacros
Add the following information:
1%_topdir /home/rpmbuild
- Copy the files to the rpmbuild directory.
1 2 3
cp -r /home/kernel-bcache/* SOURCES/ cp /home/kernel-bcache/kernel-alt.spec SPECS/ rm -rf SOURCES/linux-4.14.0-115.10.1.el7a
- Update the kernel patch.
1rpmbuild -bp /home/rpmbuild/SPECS/kernel-alt.spec
- Compile and create a kernel RPM package.
1rpmbuild -bb /home/rpmbuild/SPECS/kernel-alt.spec --with baseonly --without debug --without debuginfo
Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/rpmbuild/BUILDROOT/kernel-alt-4.14.0-115.10.1.el7a.aarch64 Wrote: /home/rpmbuild/RPMS/aarch64/kernel-4.14.0-115.10.1.el7a.aarch64.rpm Wrote: /home/rpmbuild/RPMS/aarch64/kernel-headers-4.14.0-115.10.1.el7a.aarch64.rpm Wrote: /home/rpmbuild/RPMS/aarch64/perf-4.14.0-115.10.1.el7a.aarch64.rpm Wrote: /home/rpmbuild/RPMS/aarch64/python-perf-4.14.0-115.10.1.el7a.aarch64.rpm Wrote: /home/rpmbuild/RPMS/aarch64/kernel-tools-4.14.0-115.10.1.el7a.aarch64.rpm Wrote: /home/rpmbuild/RPMS/aarch64/kernel-tools-libs-4.14.0-115.10.1.el7a.aarch64.rpm Wrote: /home/rpmbuild/RPMS/aarch64/kernel-tools-libs-devel-4.14.0-115.10.1.el7a.aarch64.rpm Wrote: /home/rpmbuild/RPMS/aarch64/kernel-devel-4.14.0-115.10.1.el7a.aarch64.rpm Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.4Lfz8M + umask 022 + cd /home/rpmbuild/BUILD + cd kernel-alt-4.14.0-115.10.1.el7a + rm -rf /home/rpmbuild/BUILDROOT/kernel-alt-4.14.0-115.10.1.el7a.aarch64 + exit 0
- View the generated kernel RPM package.
ls /home/rpmbuild/RPMS/aarch64/
Installing the Kernel
- Upload the kernel RPM package generated in Creating a Kernel RPM Package to the /home/kernel-rpm directory of each server that requires the smart write cache service.
1mkdir -p /home/kernel-rpm
- Install the kernel RPM package.
1 2
cd /home/kernel-rpm yum -y install kernel-4.14.0-115.10.1.el7a.aarch64.rpm kernel-devel-4.14.0-115.10.1.el7a.aarch64.rpm kernel-headers-4.14.0-115.10.1.el7a.aarch64.rpm - Check the default kernel startup items.
1grub2-editenv list

Check the default kernel version number.
- Modify the default kernel startup items.
1cat /etc/grub2-efi.cfg | grep CentOS
In the preceding information, CentOS Linux (4.14.0-115.10.1.el7a.aarch64) 7 (AltArch) indicates the newly installed kernel version.
grub2-set-default "CentOS Linux (4.14.0-115.10.1.el7a.aarch64) 7 (AltArch)"
- Restart the system.
1reboot
Parent topic: Installing the Bcache

