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

Compiling the Kernel

The operations vary according to the OS. Unless otherwise specified, the operations are the same in 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. Download the kernel source package to the /home/kernel-bcache directory.

      http://vault.centos.org/7.6.1810/updates/Source/SPackages/

    2. 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. 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
    
  5. 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.

  6. 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.

  7. Modify the configuration file.
    1. Open the file.
      1
      vim .config
      
    2. Press i to enter the insert mode and add #aarm64 to the first line.

    3. Press Esc to exit the insert mode.
    4. Ensure that the bcache module is enabled.

    5. Ensure that the page size is 4K.

    6. Type :wq! and press Enter to save and exit the file.
  8. Overwrite the default configuration file.
    1
    cp .config ../kernel-alt-4.14.0-aarch64.config
    

    Type y.

  9. Obtain the bcache patch and replace the source code.
    1. Download the patch package.

      https://mirrors.huaweicloud.com/kunpeng/archive/kunpeng_solution/storage/Patch/

    2. Copy the patch package to the /home directory and decompress it.
      1
      2
      3
      cd /home
      mkdir -p /home/bcache_patch
      tar -zxvf bcache_patch.tar.gz -C /home/bcache_patch
      
    3. Replace the bcache source code.
      1
      /bin/cp /home/bcache_patch/* /home/kernel-bcache/linux-4.14.0-115.10.1.el7a/drivers/md/bcache
      
  10. Run the following commands to generate an RPM package in /root/rpmbuild/RPMS/aarch64/:
    make binrpm-pkg -j48
    make rpm-pkg

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. Download the kernel source package to the /home/kernel-bcache directory.

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

    2. Decompress the source package.
      1
      2
      rpm2cpio kernel-4.19.90-2003.4.0.0036.oe1.src.rpm | cpio -divm
      tar -zxvf kernel.tar.gz
      
  3. Configure the image source.
    1. Upload the everything image file corresponding to the OS to the server.

      Use an SFTP tool to upload the openEuler-***-everything-aarch64-dvd.iso package to the /root directory on the server.

    2. Create a local directory to mount the image.
      1
      mkdir -p /iso
      

      This section uses the creation of the iso folder in the root directory as an example.

    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
        vim /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 mkeuleros createrepo genisoimage
    
  5. Obtain the kernel configuration file.
    1
    2
    cd /home/kernel-bcache/kernel
    cp arch/arm64/configs/openeuler_defconfig .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. Verify the configuration file.
    1. Open the file.
      1
      vim .config
      
    2. Ensure that the bcache module is enabled.

    3. Ensure that the page size is 4K.

    4. Type :q! and press Enter to exit the file.
  9. Overwrite the default configuration file.
    1
    cp .config arch/arm64/configs/openeuler_defconfig
    

    Type y.

  10. Run the following commands to generate an RPM package in /root/rpmbuild/RPMS/aarch64/:
    make binrpm-pkg -j48
    make rpm-pkg