Q0:如何缩减编译的initrd.img 的size
A:make INSTALL_MOD_STRIP=1 modules_install && make install
How to reduce the size of the initrd when compiling your kernel? - Unix & Linux Stack Exchange
Q1: 内核编译方法
A:
# yum install -y ncurses-devel openssl-devel.x86_64 bison flex elfutils-libelf-devel python3
for BTF compile need dwarves, so should enable the PowerTools repo than
# yum install dwarves
# make -j16
# make modules_install
# make install
Q2: 通过红帽的src rpm包编译自己的rpm 包
A: 参照下面连接
rpmbuild -bb --target=x86_64 SPECS/kernel.spec --without kabichk 2> build-err.log | tee build-out.log
https://wiki.centos.org/HowTos/Custom_Kernel
Q3: cnetos rpmbuild在哪个文件定义小版本
A: Makefile.rhelver 这个无法修改rpm包的小版本, 通过spec文件中的 %define specrelease 305.30.1.jmnd1%{?dist}
Q4: warning failed to connect to lvmetad,falling back to device scanning.错误
A: 简单的方法是编辑/etc/lvm/lvm.conf这个文件,找到use_lvmetad = 1将1修改为0,保存,重新配置grub。
# vi /etc/lvm/lvm.conf
设置 use_lvmetad=0
sudo update-initramfs -k $(uname -r) -u; sync
然后重启系统
Q5: UEFI grub 配置
A: gpt2为root所在分区
# cat /boot/efi/EFI/ubuntu/grub.cfg
set root=(hd0,gpt2)
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg
Q6: grub配置错误时如何通过grub2命令进入操作系统(ubuntu18.04验证,红帽没有验证)
A: grub2命令行进入ubuntu
grub>set root=(hd0,gpt1)
grub>linux /boot/vmlinuz-xxx-xxx
grub>initrd /boot/initrd.img-xxx-xxx
grub>boot
Q7: 安装模块时提示找不到certs/signing_key.pem, 怎么解决
# make modules_install
INSTALL arch/x86/crypto/blowfish-x86_64.ko
cp: cannot stat 'arch/x86/crypto/blowfish-x86_64.ko': No such file or directory
At main.c:291:
- SSL error:02001002:system library:fopen:No such file or directory: crypto/bio/bss_file.c:69
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: crypto/bio/bss_file.c:76
A:
You are missing a signing key to sign the module: sign-file: certs/signing_key.pem: No such file or directory
Create the key like this:
cd /lib/modules/$(uname -r)/build/certs (cd到将要编译内核的代码树中的certs目录)
tee x509.genkey > /dev/null << 'EOF'
[ req ]
default_bits = 4096
distinguished_name = req_distinguished_name
prompt = no
string_mask = utf8only
x509_extensions = myexts
[ req_distinguished_name ]
CN = Modules
[ myexts ]
basicConstraints=critical,CA:FALSE
keyUsage=digitalSignature
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid
EOF
openssl req -new -nodes -utf8 -sha512 -days 36500 -batch -x509 -config x509.genkey -outform DER -out signing_key.x509 -keyout signing_key.pem
Q8: rpmbuid时ABI BREAKAGE WAS DETECTED
**** kABI checking is enabled in kernel SPEC file. ****
+ chmod 0755 /home/mock/rpmbuild/SOURCES/check-kabi
+ '[' -e /home/mock/rpmbuild/SOURCES/Module.kabi_x86_64 ']'
+ cp /home/mock/rpmbuild/SOURCES/Module.kabi_x86_64 /home/mock/rpmbuild/BUILDROOT/kernel-4.18.0-305.30.1.el8.x86_64/Module.kabi
+ /home/mock/rpmbuild/SOURCES/check-kabi -k /home/mock/rpmbuild/BUILDROOT/kernel-4.18.0-305.30.1.el8.x86_64/Module.kabi -s Module.symvers
*** ERROR - ABI BREAKAGE WAS DETECTED ***
The following symbols have been changed (this will cause an ABI breakage):
A:--without kabichk
rpmbuild -bb --target=x86_64 SPECS/kernel.spec --without kabichk 2> build-err.log | tee build-out.log
https://wiki.centos.org/HowTos/Custom_Kernel
--nocheck Do not execute %check build stage even if present in spec.
Q9: BTF: .tmp_vmlinux.btf: pahole (pahole) is not available
Failed to generate BTF for vmlinux
A: 开启powertools repo后, yum install dwarves -y