BuildKernelImage

Create a docker instance:

sudo docker run -it rockylinux:9 bash

In docker, run:

sed -e 's|^mirrorlist=|#mirrorlist=|g'     -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.ustc.edu.cn/rocky|g'     -i.bak     /etc/yum.repos.d/rocky-extras.repo     /etc/yum.repos.d/rocky.repo
yum makecache
dnf install -y 'dnf-command(config-manager)'
dnf config-manager --set-enabled crb
yum install -y vim rpm-build python3-devel elfutils-devel  openssl-devel perl-generators pesign yum-utils bc bison bpftool dwarves flex gcc gcc-c++ git-core hmaccalc kmod m4 make net-tools perl-devel gcc-plugin-devel  rpm-build rpmdevtools  dnf-plugins-core ncurses-devel make gcc bc bison flex elfutils-libelf-devel openssl-devel grub2 rpm-build rsync gcc vim yum-utils perl systemd-udev  asciidoc audit-libs-devel binutils-devel clang dwarves fuse-devel gcc-c++ gcc-plugin-devel git-core glibc-static java-devel kabi-dw kernel-rpm-macros libbabeltrace-devel libbpf-devel libcap-devel libcap-ng-devel libmnl-devel libnl3-devel libtraceevent-devel libtracefs-devel lld llvm lvm2 net-tools newt-devel numactl-devel pciutils-devel perl-devel python3-docutils system-sb-certs tpm2-tools xmlto elfutils-devel nss-tools perl-generators pesign python3-devel xz-devel
# download the following packages offlinely 
yum install -y WALinuxAgent-cvm-2.7.0.6-9.el9_2.1.rocky.0.noarch.rpm systemd-boot-unsigned-252-14.el9_2.1.x86_64.rpm
useradd -m mock

Then in host machine, do :

[root@dellnew ~]# docker ps 
CONTAINER ID   IMAGE          COMMAND   CREATED         STATUS         PORTS     NAMES
f7eb549f3d44   rockylinux:9   "bash"    7 minutes ago   Up 7 minutes             wonderful_sinoussi
[root@dellnew ~]# docker commit wonderful_sinoussi buidrockykernel:latest
[root@dellnew ~]# docker images
REPOSITORY        TAG       IMAGE ID       CREATED         SIZE
buidrockykernel   latest    207a4b57059e   5 seconds ago   1.94GB

Next time using this latest commited kernel you could directly build kernel src.

test images

Build via following command:

[root@text ~]# docker run --name=testrocky -v /root/buildout:/buildout -it buidrockykernel:latest /bin/bash
[root@fa4d8f532c21 /]# cp /buildout/kernel-5.15.113-200.el9.src.rpm /home/mock/
[root@fa4d8f532c21 /]# su - mock
[mock@fa4d8f532c21 ~]$ rpm -Uvh kernel-5.15.113-200.el9.src.rpm 
[mock@fa4d8f532c21 ~]$ cd rpmbuild/SPECS/
[mock@fa4d8f532c21 SPECS]$ time rpmbuild -ba kernel.spec 2>&1 | tee build.log

Build515KernelRPM

Using a docker instance:

$ dnf config-manager --set-enabled crb
$ yum install -y vim rpm-build python3-devel elfutils-devel  openssl-devel perl-generators pesign yum-utils bc bison bpftool dwarves flex gcc gcc-c++ git-core hmaccalc kmod m4 make net-tools perl-devel gcc-plugin-devel
$ vim /etc/yum.repos.d/kernellongterm.repo
[copr:copr.fedorainfracloud.org:kwizart:kernel-longterm-5.15]
name=Copr repo for kernel-longterm-5.15 owned by kwizart
baseurl=https://download.copr.fedorainfracloud.org/results/kwizart/kernel-longterm-5.15/epel-9-$basearch/
type=rpm-md
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://download.copr.fedorainfracloud.org/results/kwizart/kernel-longterm-5.15/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_metadata=1
$ yum makecache

As mock, do following:

$ yumdownloader --source kernel-longterm
$ ls
kernel-longterm-5.15.124-200.el9.src.rpm
$ rpm -Uvh kernel-longterm-5.15.124-200.el9.src.rpm
$ ls
kernel-longterm-5.15.124-200.el9.src.rpm  rpmbuild

Replace to 5.15.113-1, then modify as following:

$ cp linux-5.15.tar.xz ./rpmbuild/SOURCES/linux-5.15.tar.xz
$ vim rpmbuild/SPECS/kernel.spec
Line 135? 
# Do we have a -stable update to apply?
#%define stable_update 124
%define stable_update 113

%define rpmversion %{kversion}.%{stable_update}
%define patchversion 5.15
#%define pkgrelease 200
%define pkgrelease 1
1400 # released_kernel with possible stable updates
1401 # This is special because the kernel spec is hell and nothing is consistent
1402 #xzcat %{SOURCE5000} | patch -p1 -F1 -s
1403 #xzcat %{SOURCE5000} | patch -p1 -F1 -s
1404 git commit -a -m "Stable update"
1405 
1406 # Note: Even in the "nopatches" path some patches (build tweaks and compile
1407 # fixes) will always get applied; see patch defition above for details
1408 
1409 #git am %{patches}                                                                                                                                                                                                                                      
1410 #git am %{patches}

BuildKernelOnRockyLinux92

Try Steps

Replace the repository for speedup:

sed -e 's|^mirrorlist=|#mirrorlist=|g'     -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.ustc.edu.cn/rocky|g'     -i.bak     /etc/yum.repos.d/rocky-extras.repo     /etc/yum.repos.d/rocky.repo
yum makecache

Install docker:

dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
# replace all of the `download.docker.com` into `https://mirrors.ustc.edu.cn/docker-ce`
yum makecache
yum install -y docker-ce
systemctl enable docker
systemctl start docker

Pull rockylinux9 and prepare building environment via:

docker pull rockylinux:9
docker run -it -v /root/source:/source rockylinux:9 /bin/bash
sed -e 's|^mirrorlist=|#mirrorlist=|g'     -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.ustc.edu.cn/rocky|g'     -i.bak     /etc/yum.repos.d/rocky-extras.repo     /etc/yum.repos.d/rocky.repo
yum makecache
yum install -y rpm-build rpmdevtools  dnf-plugins-core ncurses-devel make gcc bc bison flex elfutils-libelf-devel openssl-devel grub2 rpm-build rsync gcc vim yum-utils
rpm -ivh kernel-5.15.113_lts2021_iotg-1.src.rpm
useradd -m dash
su dash
$ cd 
$ rpmdev-setuptree
$ ls ~
rpmbuild

RockyLinux Way

Create docker instance:

docker run -it -v /root/source:/source rockylinux:9 /bin/bash

In docker, prepare for building kernel:

sed -e 's|^mirrorlist=|#mirrorlist=|g'     -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.ustc.edu.cn/rocky|g'     -i.bak     /etc/yum.repos.d/rocky-extras.repo     /etc/yum.repos.d/rocky.repo
yum makecache
yum install -y rpm-build rpmdevtools  dnf-plugins-core ncurses-devel make gcc bc bison flex elfutils-libelf-devel openssl-devel grub2 rpm-build rsync gcc vim yum-utils perl
yum --enablerepo=crb install -y systemd-udev  asciidoc audit-libs-devel binutils-devel clang dwarves fuse-devel gcc-c++ gcc-plugin-devel git-core glibc-static java-devel kabi-dw kernel-rpm-macros libbabeltrace-devel libbpf-devel libcap-devel libcap-ng-devel libmnl-devel libnl3-devel libtraceevent-devel libtracefs-devel lld llvm lvm2 net-tools newt-devel numactl-devel pciutils-devel perl-devel python3-docutils system-sb-certs tpm2-tools xmlto elfutils-devel nss-tools perl-generators pesign python3-devel xz-devel
# yum --enablerepo=crb install -y  kmod  patch  bash    tar  git-core  which bzip2  xz  findutils  gzip  m4  perl-interpreter  perl-Carp  perl-devel  perl-generators  make  diffutils  gawk gcc  binutils  redhat-rpm-config  hmaccalc  bison  flex  gcc-c++ net-tools  hostname  bc  elfutils-devel dwarves python3-devel gcc-plugin-devel bpftool rsync xmlto  asciidoc  python3-sphinx  python3-sphinx_rtd_theme  zlib-devel binutils-devel newt-devel  bison flex xz-devel audit-libs-devel java-devel libbabeltrace-devel libtraceevent-devel numactl-devel   gettext ncurses-devel libcap-devel libcap-ng-devel pciutils-devel python3-docutils zlib-devel binutils-devel clang llvm numactl-devel libcap-devel libcap-ng-devel rsync libmnl-devel rpm-build  elfutils kabi-dw openssl openssl-devel nss-tools pesign    xmlto asciidoc clang llvm lld


yum install /source/WALinuxAgent-cvm-2.7.0.6-9.el9_2.1.rocky.0.noarch.rpm /source/systemd-boot-unsigned-252-14.el9_2.1.x86_64.rpm
useradd -m mock
su - mock

Download the kernel src rpm:

$ yumdownloader --source kernel
$ ls -l -h
total 139M
-rw-r--r--. 1 mock mock 139M Aug 10 06:30 kernel-5.14.0-284.25.1.el9_2.src.rpm
$ rpm -Uvh kernel-5.14.0-284.25.1.el9_2.src.rpm 
[mock@c51507a516d4 ~]$ cd ./rpmbuild/SPECS/
[mock@c51507a516d4 SPECS]$ ls
kernel.spec
[mock@c51507a516d4 SPECS]$ time rpmbuild -ba kernel.spec 

intel way

using the kernel-5.15.113-1.src.rpm package we got following issue:

Processing files: kernel-headers-5.15.113-1.x86_64
Provides: kernel-headers = 5.15.113 kernel-headers = 5.15.113-1 kernel-headers(x86-64) = 5.15.113-1
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Obsoletes: kernel-headers
Processing files: kernel-devel-5.15.113-1.x86_64
warning: absolute symlink: /lib/modules/5.15.113/build -> /usr/src/kernels/5.15.113
warning: absolute symlink: /lib/modules/5.15.113/source -> /usr/src/kernels/5.15.113
Provides: kernel-devel = 5.15.113-1 kernel-devel(x86-64) = 5.15.113-1
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Processing files: kernel-debugsource-5.15.113-1.x86_64
error: Could not open %files file /home/mock/rpmbuild/BUILD/kernel-5.15.113/debugsourcefiles.list: No such file or directory


RPM build errors:
    line 20: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
    absolute symlink: /lib/modules/5.15.113/build -> /usr/src/kernels/5.15.113
    absolute symlink: /lib/modules/5.15.113/source -> /usr/src/kernels/5.15.113
    Could not open %files file /home/mock/rpmbuild/BUILD/kernel-5.15.113/debugsourcefiles.list: No such file or directory

fedora 5.15 lts

Refers to https://copr.fedorainfracloud.org/coprs/kwizart/kernel-longterm-5.15/.

yum install -y bpftool
dnf copr enable kwizart/kernel-longterm-5.15
yumdownloader --source kernel-longterm
su - mock
rpm -Uvh kernel-longterm-5.15.124-200.el9.src.rpm
cd /home/mock/rpmbuild
time rpmbuild -ba kernel.spec 

build result:

$ find . | grep rpm$
./RPMS/x86_64/kernel-longterm-modules-internal-5.15.124-200.el9.x86_64.rpm
./RPMS/x86_64/kernel-longterm-debug-devel-matched-5.15.124-200.el9.x86_64.rpm
./RPMS/x86_64/kernel-longterm-debug-5.15.124-200.el9.x86_64.rpm
./RPMS/x86_64/kernel-longterm-5.15.124-200.el9.x86_64.rpm
./RPMS/x86_64/kernel-longterm-devel-matched-5.15.124-200.el9.x86_64.rpm
./RPMS/x86_64/kernel-longterm-debug-modules-extra-5.15.124-200.el9.x86_64.rpm
./RPMS/x86_64/kernel-longterm-modules-extra-5.15.124-200.el9.x86_64.rpm
./RPMS/x86_64/kernel-longterm-debug-modules-internal-5.15.124-200.el9.x86_64.rpm
./RPMS/x86_64/kernel-longterm-debug-debuginfo-5.15.124-200.el9.x86_64.rpm
./RPMS/x86_64/kernel-longterm-debug-devel-5.15.124-200.el9.x86_64.rpm
./RPMS/x86_64/kernel-longterm-debuginfo-5.15.124-200.el9.x86_64.rpm
./RPMS/x86_64/kernel-longterm-devel-5.15.124-200.el9.x86_64.rpm
./RPMS/x86_64/kernel-longterm-debug-modules-5.15.124-200.el9.x86_64.rpm
./RPMS/x86_64/kernel-longterm-debuginfo-common-x86_64-5.15.124-200.el9.x86_64.rpm
./RPMS/x86_64/kernel-longterm-modules-5.15.124-200.el9.x86_64.rpm
./RPMS/x86_64/kernel-longterm-debug-core-5.15.124-200.el9.x86_64.rpm
./RPMS/x86_64/kernel-longterm-core-5.15.124-200.el9.x86_64.rpm
./SRPMS/kernel-longterm-5.15.124-200.el9.src.rpm

Aug17

Enable perftools building, I think it failed because of the libebpf is too new comparing to 5.15.113 kernel. so changes to kerner’s tools/lib/bpf version’s libebpf-devel package for building.

WorkingTipsOniventoy

Create the server:

cd Downloads
mkdir iventory
cd iventory
tar xzvf ../iventoy-1.0.17-linux-free.tar.gz
cd iventoy-1.0.17
sudo ./iventoy.sh start

Select the DHCP server mode for external:

/images/2023_08_09_09_42_48_888x625.jpg

Create the linked iso:

➜  ~ ls /home/dash/Downloads/iventory/iventoy-1.0.17/iso 
➜  ~ ln -s /media/121/iso/Rocky-9.2-x86_64-dvd.iso /home/dash/Downloads/iventory/iventoy-1.0.17/iso/Rocky-9.2-x86_64-dvd.iso
➜  ~ ln -s /media/121/iso/ubuntu-22.04.2-desktop-amd64.iso /home/dash/Downloads/iventory/iventoy-1.0.17/iso/ubuntu-22.04.2-desktop-amd64.iso
➜  ~ ls -l -h /home/dash/Downloads/iventory/iventoy-1.0.17/iso 
total 0
lrwxrwxrwx 1 dash root 39 Aug  9 09:40 Rocky-9.2-x86_64-dvd.iso -> /media/121/iso/Rocky-9.2-x86_64-dvd.iso
lrwxrwxrwx 1 dash root 47 Aug  9 09:40 ubuntu-22.04.2-desktop-amd64.iso -> /media/121/iso/ubuntu-22.04.2-desktop-amd64.iso

Start the server:

/images/2023_08_09_09_43_26_1079x379.jpg

Using external dhcp server may need other configuration.

# vim /etc/dhcpd.conf
......
 subnet 192.168.1.0	netmask 255.255.255.0 {
    range 192.168.1.160 192.168.1.199;
    option routers 192.168.1.33;
    option subnet-mask 255.255.255.0;
       filename "iventoy_loader_16000";
       next-server 192.168.1.12;
    option broadcast-address 192.168.1.255;
    option domain-name-servers 223.5.5.5;
    option time-offset 0;
    default-lease-time	1209600;
    max-lease-time 1814400;
    }
......

OnMeshCommander

Steps:

# docker run -it ubuntu:latest /bin/bash
In docker instance:    
# cd /root
# mkdir meshcommander
# cd meshcommander
# npm install meshcommander 

Then commit this docker instance to docker image:

# docker commit awgowugowugouawo meshcommander:mine

Start the instance:

docker run -it -p 4080:3000 meshcommander:ctyun /bin/bash

Edit the node modules:

root@938cedc55cde:~/meshcommander# vim node_modules/meshcommander/webserver.js 
156         obj.app.listen(port, '0.0.0.0', function () { console.log("MeshCommander running on http://127.0.0.1:" + port + '.'); });
node node_modules/meshcommander/

Visit the https://ip:4080 you could reache the meshcommander webpage.

/images/2023_08_04_09_31_09_640x215.jpg

Configuration:

/images/2023_08_04_09_31_33_433x288.jpg

System Status:

./images/2023_08_04_09_32_08_363x424.jpg

Attach an iso for Linux installation:

meshcommander is too old. switch to