我要评分
获取效率
正确性
完整性
易理解

Compiling and Installing the Kernel

The operations vary according to the OS. Unless otherwise specified, the operations are the same on the two OSs.

CentOS 7.6

  1. Create a directory and go to the directory.
    1
    2
    mkdir -p /home/kernel-bcache
    cd /home/kernel-bcache
    
  2. Obtain the kernel source code.
    1. Run the following command to check the kernel version:
      1
      uname -a
      

      The queried kernel version is as follows:

      Linux ceph3 4.14.0-115.el7a.0.1.aarch64 #1 SMP Sun Nov 25 20:54:21 UTC 2018 aarch64 aarch64 aarch64 GNU/Linux
    2. Download the kernel source package of the matching version to the /home/kernel-bcache directory.

      Package:

    3. 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
      
  3. Install the dependencies.
    1
    yum -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
    
  4. Replace the bcache module.
    1. Obtain the bcache source code and save it to /home.
    2. Decompress the source package.
      1
      2
      cd /home
      unzip bcache-smart-write-cache.zip
      
    3. Replace the bcache module.
      1
      cp -rf /home/bcache-smart-write-cache/drivers/md/bcache /home/kernel-bcache/linux-4.14.0-115.10.1.el7a/drivers/md/
      
  5. 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
    
  6. Configure the bcache module.
    1
    make menuconfig
    
    1. Choose Device Drivers.

    2. Press Enter to access the next-level menu, and then choose Multiple device driver support (RAID and LVM).

    3. Press Enter to access the next-level menu, choose Block device as cache, and press M to select the configuration.

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

  7. Change the kernel page size to 4KB.
    1. Choose Kernel Features.

    2. Press Enter to access the next-level menu, and choose Page size (64KB).

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

    4. Click Exit twice to save the setting and exit.

  8. Modify the configuration file.
    1. Open the following file:
      1
      vi .config
      
    2. Find the CONFIG_BCACHE field in the configuration file. If the value is CONFIG_BCACHE=m, the bcache module is enabled.

    3. Find the CONFIG_ARM64_4K_PAGES field in the configuration file. If the value is CONFIG_ARM64_4K_PAGES=y, the page size is 4 KB.

    4. Type :wq! and press Enter to save and exit the file.
  9. Overwrite the default configuration file with the configuration file modified in step 8.
    1
    cp .config ../kernel-alt-4.14.0-aarch64.config
    
  10. Type y.
  11. Run the following commands to generate an RPM package. After that, the RPM package is generated in /root/rpmbuild/RPMS/aarch64/.
    1
    2
    make binrpm-pkg -j48
    make rpm-pkg -j
    
  12. Upload the kernel RPM package generated in step 11 to the /home/kernel-rpm directory of each server that requires the smart write cache service.
    1
    2
    mkdir -p /home/kernel-rpm
    cp  /root/rpmbuild/RPMS/aarch64/* /home/kernel-rpm
    
  13. Install the kernel RPM package.
    1
    2
    cd /home/kernel-rpm
    yum -y install kernel-4.14.0-1.aarch64.rpm  kernel-devel-4.14.0-1.aarch64.rpm  kernel-headers-4.14.0-1.aarch64.rpm
    
  14. Check the versions of all kernels installed in the system.
    1
    cat /etc/grub2-efi.cfg  | grep CentOS
    

  15. Check the default kernel startup item.
    1
    grub2-editenv list
    
    • If the default version is the newly installed kernel version CentOS Linux (4.14.0-115.10.1.el7a.aarch64) 7 (AltArch), go to step 17.
    • Otherwise, go to step 16 and then step 17.
  16. Modify the default kernel startup item. In the command, CentOS Linux (4.14.0-115.10.1.el7a.aarch64) 7 (AltArch) indicates the version of the newly installed kernel.
    grub2-set-default "CentOS Linux (4.14.0-115.10.1.el7a.aarch64) 7 (AltArch)"
  17. Reboot the system.
    1
    reboot
    

openEuler 20.03

  1. Create a directory and go to the directory.
    1
    2
    mkdir -p /home/kernel-bcache
    cd /home/kernel-bcache
    
  2. Obtain the kernel source code.
    1. Check the system kernel version.
      1
      uname -a
      

      The queried kernel version is as follows:

      Linux localhost.localdomain 4.19.90-2109.1.0.0108.oe1.aarch64 #1 SMP Mon Sep 6 03:51:48 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux
    2. Download the kernel source package of the matching version to the /home/kernel-bcache directory.

    3. Decompress the source package.
      1
      2
      rpm2cpio kernel-4.19.90-2109.1.0.0108.oe1.src.rpm | cpio -divm
      tar -zxvf kernel.tar.gz
      
  3. Configure the image source.
    1. Use the SFTP tool to upload the openEuler-***-everything-aarch64-dvd.iso image source file of the corresponding OS to the /root directory on the server.
    2. Create a local directory to mount the image.

      In this example, an iso directory is created in the root directory for mounting the local image.

      1
      mkdir -p /iso
      
    3. Mount the ISO file to the local directory.
      1
      mount /root/openEuler-***-everything-aarch64-dvd.iso /iso
      
    4. Create a Yum source for the image and configure the source.
      1. Create a .repo file.
        1
        vi /etc/yum.repos.d/openEuler.repo
        
      2. Press i to enter the insert mode and add the following content to the file to mount the Yum source:
        1
        2
        3
        4
        5
        6
        [Base]
        name=Base
        baseurl=file:///iso
        enabled=1
        gpgcheck=0
        priority=1
        
      3. Add the following content to configure the openEuler network source:
         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
        [openEuler-source]
        name=openEuler-source
        baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/source/
        enabled=1
        gpgcheck=1
        gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/source/RPM-GPG-KEY-openEuler
        
        [openEuler-os]
        name=openEuler-os
        baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/
        enabled=0
        gpgcheck=1
        gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/RPM-GPG-KEY-openEuler
        
        [openEuler-everything]
        name=openEuler-everything
        baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/everything/aarch64/
        enabled=0
        gpgcheck=1
        gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/everything/aarch64/RPM-GPG-KEY-openEuler
        
        [openEuler-EPOL]
        name=openEuler-epol
        baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/EPOL/aarch64/
        enabled=1
        gpgcheck=0
        
        [openEuler-update]
        name=openEuler-update
        baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/update/aarch64/
        enabled=1
        gpgcheck=0
        
      4. Press Esc to exit the insert mode. Type :wq! and press Enter to save and exit the file.
  4. Install the dependencies.
    1
    dnf -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
    
  5. Replace the bcache module.
    1. Obtain the bcache source code and save it to /home.
    2. Decompress the source package.
      1
      2
      cd /home
      unzip kernel-openEuler-1.0-LTS.zip
      
    3. Replace the bcache module.
      1
      \cp -rf /home/kernel-openEuler-1.0-LTS/drivers/md/bcache /home/kernel-bcache/kernel/drivers/md/
      
  6. Obtain the kernel configuration file.
    1
    2
    cd /home/kernel-bcache/kernel
    cp arch/arm64/configs/openeuler_defconfig .config
    
  7. Configure the bcache module.
    1
    make menuconfig
    
    1. Choose Device Drivers.

    2. Press Enter to access the next-level menu, and then choose Multiple device driver support (RAID and LVM).

    3. Press Enter to access the next-level menu, choose Block device as cache, and press M to select the configuration.

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

  8. Change the kernel page size to 4KB.
    1. Choose Kernel Features.

    2. Press Enter to access the next-level menu, and choose Page size (64KB).

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

    4. Click Exit twice to save the setting and exit.

  9. Verify the configuration file.
    1. Open the following file:
      1
      vi .config
      
    2. Find the CONFIG_BCACHE field in the configuration file. If the value is CONFIG_BCACHE=m, the bcache module is enabled.

    3. Find the CONFIG_ARM64_4K_PAGES field in the configuration file. If the value is CONFIG_ARM64_4K_PAGES=y, the page size is 4 KB.

    4. Press Esc, type :wq!, and press Enter to exit the file.
  10. Overwrite the default configuration file.
    1
    cp .config arch/arm64/configs/openeuler_defconfig
    
  11. Type y.
  12. Run the following commands to generate an RPM package in the /root/rpmbuild/RPMS/aarch64/ directory:
    yum install bc -y
    make binrpm-pkg -j48
    make rpm-pkg -j48
  13. Upload the kernel RPM package generated in step 12 to the /home/kernel-rpm directory of each server that requires the smart write cache service.
    1
    2
    mkdir -p /home/kernel-rpm
    cp  /root/rpmbuild/RPMS/aarch64/* /home/kernel-rpm
    
  14. Install the kernel RPM package.
    1
    2
    cd /home/kernel-rpm
    dnf -y install kernel-*.rpm
    
  15. Check the default kernel startup item.
    1
    grub2-editenv list
    

    Check the default kernel version.

    • If the default version is the newly installed kernel version, skip step 16.
    • Otherwise, go to step 16.
  16. Modify the default kernel startup item.
    1
    cat /etc/grub2-efi.cfg  | grep openEuler
    

    In the preceding figure, openEuler (4.19.90-2109.1.0.0108.oe1.aarch64) 20.03 (LTS-SP1) indicates the newly installed kernel version.

    grub2-set-default "openEuler (4.19.90-2109.1.0.0108.oe1.aarch64) 20.03 (LTS-SP1)"
  17. Reboot the system.
    1
    reboot