Rate This Document
Findability
Accuracy
Completeness
Readability

Compiling and Installing the Kernel

Obtaining the Kernel Source Code

  1. Create a directory and go to the directory.
    1
    2
    mkdir -p /home/kernel-bcache
    cd /home/kernel-bcache
    
  2. Download the kernel source package to the /home/kernel-bcache directory.

    Download address: https://repo.openeuler.org/openEuler-20.03-LTS-SP1/source/Packages/

  3. Decompress the source package.
    1
    2
    rpm2cpio kernel-4.19.90-2012.4.0.0053.oe1.src.rpm | cpio -divm
    tar -zxvf kernel.tar.gz
    
  4. Configure the image source.
    1. Use the SFTP tool to upload openEuler-***-everything-aarch64-dvd.iso to the /root directory on the server.
    2. Create a local folder to mount the 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.
      1
      vi /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
      
  5. Install the dependency.
    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 mkeuleros createrepo genisoimage
    

Replacing the Bcache Module

  1. Obtain the bcache source code and save it to /home.

    Download address: https://gitee.com/openeuler/kernel/tree/openEuler-1.0-LTS/kernel

  2. Decompress the source code.
    unzip openeuler-kernel-openEuler-1.0-LTS.zip
  3. Replace the bcache.
    1
    cp -rf /home/kernel/drivers/md/bcache /home/kernel-bcache/kernel/drivers/md/
    

Modifying the Kernel Configuration

  1. Obtain the kernel configuration file.
    1
    2
    cd /home/kernel-bcache/kernel
    cp arch/arm64/configs/openeuler_defconfig .config
    
  2. 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.

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

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

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

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

  4. Verify the configuration file.
    1. Ensure that the bcache module is enabled.

    2. Ensure that the value of page size is 4 KB.

  5. Overwrite the default configuration file.
    1
    cp .config arch/arm64/configs/openeuler_defconfig
    

    Type Y.

Creating a Kernel RPM Package

  1. Repack the kernel source code.
    1
    2
    cd /home/kernel-bcache
    tar -zcvf kernel.tar.gz kernel
    
  2. Create an rpmbuild directory.
    1
    2
    3
    mkdir -p /home/rpmbuild
    cd /home/rpmbuild
    mkdir -p BUILD  RPMS  SOURCES  SPECS  SRPMS
    
  3. Change the default rpmbuild path.
    1
    vi /root/.rpmmacros
    

    Add the following information:

    1
    %_topdir /home/rpmbuild
    
  4. Copy the files to the rpmbuild directory.
    1
    2
    3
    cp -r /home/kernel-bcache/* SOURCES/
    cp /home/kernel-bcache/kernel.spec SPECS/
    rm -rf SOURCES/kernel
    
  5. Compile and create a kernel RPM package.
    1
    vi /usr/lib/rpm/macros
    

    Change %_unpackaged_files_terminate_build 1 to %_unpackaged_files_terminate_build 0.

    1
    rpmbuild -bb /home/rpmbuild/SPECS/kernel.spec --with baseonly --without debug --without debuginfo
    
  6. View the generated kernel RPM package.
    ls /home/rpmbuild/RPMS/aarch64/

Installing the Kernel

  1. Upload the kernel RPM package generated in Creating a Kernel RPM Package to the /home/kernel-rpm directory.
    1
    mkdir -p /home/kernel-rpm
    
  2. Install the kernel RPM package.
    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
    
  3. Check the default kernel startup items.
    1
    grub2-editenv list
    

    Check the default kernel version number.

    • If the default version is the newly installed kernel version, skip step 4.
    • Otherwise, go to step 4.
  4. Modify the default kernel startup items.
    1
    cat /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)"
  5. Restart the system.
    1
    reboot