Linux, 工作, 生活, 家人

Linux

Build Linux kernel 5.x on CentOS 7

This article’s procedure was tested in Ampere Altra CPU platform, but suppose that x86 system also can use this procedure.

CentOS 7’s gcc is too old to compile Linux kernel 5.x, and it can use another package named “software collections(SCL)” to install newer gcc to build Linux kernel.

Install CentOS 7 on Ampere Altra CPU

Earlier CentOS 7 default OS is too old to support ARM64 CPU and SSIF driver,
if you have problem to install on Ampre Altra CPU, it needs to block SSIF and change PCI parameter during booting. Add parameters below on Linux kernel booting parameter when install CentOS7.

modprobe.blacklist=ipmi_si pci=nomsi

Prepare Build Environment

Before download and build Linux kernel 5.x, it needs to run those command to prepare build environment

yum install -y centos-release-scl-rh
yum install -y devtoolset-9*
yum groupinstall -y "Development Tools"
yum install -y ncurses-devel
yum install -y hmaccalc zlib-devel binutils-devel elfutils-libelf-devel
yum install -y python3

Download Linux kernel

Ampere LTS kernel can be download from github, here is the command to checkout Ampere LTS kernel and switch version to 5.10

cd /root
git clone https://github.com/AmpereComputing/ampere-lts-kernel.git
cd /ampere-lte-kernel
git checkout -b origin/linux-5.10.y 5.10.y

On later Linux kernel, it needs to use git switch to switch to 5.10.y

git switch 5.10.y

Build Linux kernel

It’s simple to build Linux kernel

scl enable devtoolset-9 bash
cd /root/ampere-lte-kernel
cp arch/arm64/configs/altra_5.10_defconfig .config
make olddefconfig
make -j `nproc` && make -j `nproc` modules  && make modules_install && make install

GRUB Setting

Suggest to change default GRUB timeout to choice right kernel to boot.

sed -i 's/GRUB_TIMEOUT=5/GRUB_TIMEOUT=30/g' /etc/default/grub
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg

OK, right now it can reboot your system to have try.

Ref:
Good mirror site for CentOS7 package.
https://mirrors.bfsu.edu.cn/centos-altarch/7.9.2009/os/aarch64/

發佈留言