日期 | 修改内容 | 修改人 | 备注 |
---|---|---|---|
2021年10月27日 | 创建 | 荣涛 | |
2021年10月28日 | 添加可能的问题 | 荣涛 |
$ wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.6.9.tar.xz $ unxz -v linux-5.6.9.tar.xz # 或者 $ xz -d -v linux-5.6.9.tar.xz $ wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.6.9.tar.sign $ gpg --verify linux-5.6.9.tar.sign # 上面命令可能的输出为: # gpg: assuming signed data in 'linux-5.6.9.tar' # gpg: Signature made Sun 12 Aug 2018 04:00:28 PM CDT # gpg: using RSA key 79BE3E4300411886 # gpg: Can't check signature: No public key $ gpg --recv-keys 79BE3E4300411886 # 上面命令可能的输出为: # gpg: key 79BE3E4300411886: 7 duplicate signatures removed # gpg: key 79BE3E4300411886: 172 signatures not checked due to missing keys # gpg: /home/vivek/.gnupg/trustdb.gpg: trustdb created # gpg: key 79BE3E4300411886: public key "Linus Torvalds <torvalds@kernel.org>" imported # gpg: no ultimately trusted keys found # gpg: Total number processed: 1 # gpg: imported: 1 $ gpg --verify linux-5.6.9.tar.sign # 上面命令可能的输出为: # gpg: assuming signed data in 'linux-5.6.9.tar' # gpg: Signature made Sun 12 Aug 2018 04:00:28 PM CDT # gpg: using RSA key 79BE3E4300411886 # gpg: Good signature from "Linus Torvalds <torvalds@kernel.org>" [unknown] # gpg: aka "Linus Torvalds <torvalds@linux-foundation.org>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: ABAF 11C6 5A29 70B1 30AB E3C4 79BE 3E43 0041 1886 $ tar xvf linux-5.6.9.tar $ cd linux-5.6.9 $ cp -v /boot/config-$(uname -r) .config # 上步可能的输出 # '/boot/config-4.15.0-30-generic' -> '.config'
$ sudo apt-get install build-essential libncurses-dev bison flex libssl-dev libelf-dev
$ sudo yum group install "Development Tools" # or $ sudo yum groupinstall "Development Tools" $ sudo yum install ncurses-devel bison flex elfutils-libelf-devel openssl-devel
$ sudo dnf group install "Development Tools" $ sudo dnf install ncurses-devel bison flex elfutils-libelf-devel openssl-devel
几个选项:
$ make menuconfig
$ make xconfig
$ make gconfig
$ make menuconfig
## use 4 core/thread ## $ make -j 4 ## get thread or cpu core count using nproc command ## $ make -j $(nproc)
# Install the Linux kernel modules $ sudo make modules_install # Install the Linux kernel $ sudo make install # It will install three files into /boot directory as well # as modification to your kernel grub configuration file: # initramfs-5.6.9.img # System.map-5.6.9 # vmlinuz-5.6.9
$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg $ sudo grubby --set-default /boot/vmlinuz-5.6.9 # You can confirm the details with the following commands: $ sudo grubby --info=ALL | more $ sudo grubby --default-index $ sudo grubby --default-kernel
$ sudo update-initramfs -c -k 5.6.9 $ sudo update-grub
$ sudo reboot # 这里将进行系统重启 $ uname -mrs # 可能的输出 # Linux 5.6.9 x86_64
我的环境缺少了依赖:
$ sudo yum install slang-devel $ sudo yum install binutils-devel zlib-static $ sudo yum install libbabeltrace-devel $ sudo yum install java-1.8.0-openjdk-devel # 下面的 platform-python-devel 安装后并不起作用 $ sudo yum install platform-python-devel
编译perf:
$ make
安装perf:
# 注意,这里需要指定目标目录,否则可能被安装到 /root/bin/perf $ sudo make install DESTDIR=/usr
直接安装即可。
直接安装即可。
在编译内核过程中,可能出现问题现象:
BTF: .tmp_vmlinux.btf: pahole (pahole) is not available Failed to generate BTF for vmlinux Try to disable CONFIG_DEBUG_INFO_BTF make: *** [Makefile:1106: vmlinux] Error 1
参考链接:BTF: .tmp_vmlinux.btf: pahole (pahole) is not available
解决办法:
尝试安装(根据不同系统类型):
$ sudo apt install dwarves $ sudo dnf install dwarves $ sudo zypper in dwarves
如果搜不到,就代开powertools的yum源:
vim /etc/yum.repo.d/CentOS-Linux-PowerTools.repo enabled=1