Compiling and Installing the Kernel
The operations vary according to the OS. Unless otherwise specified, the operations are the same in the two OSs.
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.
- Decompress the source package.
- CentOS 7.6
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 - openEuler 20.03
1 2
rpm2cpio kernel-4.19.90-2012.4.0.0053.oe1.src.rpm | cpio -divm tar -zxvf kernel.tar.gz
- CentOS 7.6
- Configure the image source. (Perform this step only for openEuler 20.03. Skip this step for CentOS 7.6.)
- Use an SFTP tool to upload the openEuler-***-everything-aarch64-dvd.iso package to the /root directory on the server.
- Create a local directory to mount the image.
1mkdir -p /iso
- Mount the ISO file to the local directory.
1mount /root/openEuler-***-everything-aarch64-dvd.iso /iso
- Create a Yum source for the image.
1vi /etc/yum.repos.d/openEuler.repo
Add the following information to the file:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
[Base] name=Base baseurl=file:///iso enabled=1 gpgcheck=0 priority=1 [openEuler-source] name=openEuler-source baseurl=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/source/ enabled=1 gpgcheck=1 gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/source/RPM-GPG-KEY-openEuler [openEuler-os] name=openEuler-os baseurl=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/OS/aarch64/ enabled=0 gpgcheck=1 gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/OS/aarch64/RPM-GPG-KEY-openEuler [openEuler-everything] name=openEuler-everything baseurl=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/everything/aarch64/ enabled=0 gpgcheck=1 gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/everything/aarch64/RPM-GPG-KEY-openEuler [openEuler-EPOL] name=openEuler-epol baseurl=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/EPOL/aarch64/ enabled=1 gpgcheck=0 [openEuler-update] name=openEuler-update baseurl=http://repo.openeuler.org/openEuler-20.03-LTS-SP1/update/aarch64/ enabled=1 gpgcheck=0
- Install the dependencies.
- CentOS 7.6
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
- openEuler 20.03
1dnf -y install ncurses-devel bison m4 flex rpm-build rpmdevtools asciidoc audit-libs-devel binutils-devel elfutils-devel elfutils-libelf-devel gtk2-devel java-1.8.0-openjdk-devel xz-devel libbabeltrace-devel libunwind-devel newt-devel numactl-devel openssl-devel pciutils-devel perl-generators python3-devel python3-docutils xmlto zlib-devel createrepo genisoimage
- CentOS 7.6
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.
- CentOS 7.6
1 2
cd /home unzip bcache-swc-v0.2.0.zip - openEuler 20.03
unzip openeuler-kernel-openEuler-1.0-LTS.zip
- CentOS 7.6
- Replace the bcache.
- CentOS 7.6
1cp -rf /home/bcache-swc-v0.2.0/drivers/md/bcache /home/kernel-bcache/linux-4.14.0-115.10.1.el7a/drivers/md/
- openEuler 20.03
1cp -rf /home/kernel/drivers/md/bcache /home/kernel-bcache/kernel/drivers/md/
- CentOS 7.6
Modifying the Kernel Configuration
- Obtain the kernel configuration file.
- CentOS 7.6
1 2
cd /home/kernel-bcache/linux-4.14.0-115.10.1.el7a cp ../kernel-alt-4.14.0-aarch64.config .config - openEuler 20.03
1 2
cd /home/kernel-bcache/kernel cp arch/arm64/configs/openeuler_defconfig .config
- CentOS 7.6
- 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. (Perform this step only for CentOS 7.6. Skip this step for openEuler 20.03.)
1vi .config
Add #aarm64 to the first line.

- Verify the configuration file.
- Overwrite the default configuration file.
- CentOS 7.6
1cp .config ../kernel-alt-4.14.0-aarch64.config
Type Y.
- openEuler 20.03
1cp .config arch/arm64/configs/openeuler_defconfig
Type Y.
- CentOS 7.6
Creating a Kernel RPM Package
- Repack the kernel source code.
- CentOS 7.6
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 - openEuler 20.03
1 2
cd /home/kernel-bcache tar -zcvf kernel.tar.gz kernel
- CentOS 7.6
- 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.
- CentOS 7.6
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
- openEuler 20.03
1 2 3
cp -r /home/kernel-bcache/* SOURCES/ cp /home/kernel-bcache/kernel.spec SPECS/ rm -rf SOURCES/kernel
- CentOS 7.6
- Update the kernel patch. (Perform this step only for CentOS 7.6. Skip this step for openEuler 20.03.)
1rpmbuild -bp /home/rpmbuild/SPECS/kernel-alt.spec
- Compile and create a kernel RPM package.
- CentOS 7.6
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
- openEuler 20.03
1vi /usr/lib/rpm/macros
Change %_unpackaged_files_terminate_build 1 to %_unpackaged_files_terminate_build 0.

1rpmbuild -bb /home/rpmbuild/SPECS/kernel.spec --with baseonly --without debug --without debuginfo
- CentOS 7.6
- 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.
- CentOS 7.6
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 - openEuler 20.03
1 2
cd /home/kernel-rpm dnf -y install kernel-4.19.90-2012.4.0.0053.aarch64.rpm kernel-devel-4.19.90-2012.4.0.0053.aarch64.rpm
- CentOS 7.6
- Check the default kernel startup items.
1grub2-editenv list
Check the default kernel version number.
- Modify the default kernel startup items.
- CentOS 7.6
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)"
- openEuler 20.03
1cat /etc/grub2-efi.cfg | grep openEuler
In the preceding information, openEuler (4.19.90-2012.4.0.0053.aarch64) 20.03 (LTS-SP1) indicates the newly installed kernel.
grub2-set-default "openEuler (4.19.90-2012.4.0.0053.aarch64) 20.03 (LTS-SP1)"
- CentOS 7.6
- Restart the system.
1reboot
Parent topic: Installing the Bcache



