ubuntu 20.04 升级内核
系统信息
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal
$ uname -a
Linux kang-HP-ProBook-440-14-inch-G10-Notebook-PC 5.15.0-67-generic #74~20.04.1-Ubuntu SMP Wed Feb 22 14:52:34 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
安装依赖
sudo apt update && sudo apt upgrade
sudo apt install binutils build-essential gcc make perl net-tools libncurses-dev \
openssh-server git fakeroot libssl-dev bc flex libelf-dev bison \
dwarves zstd
Linux 源码下载
- 官网: https://www.kernel.org/pub/
- Git: https://git.kernel.org/
- ftp: http://ftp.sjtu.edu.cn/sites/ftp.kernel.org/pub/linux/kernel/
拷贝 .config 配置文件
解压源代码并进入源码根目录,然后执行
cp /boot/config-$(uname -r) .config
修改 .config 文件,左侧为修改后,解决编译报错问题
编译
make menuconfig # 弹出的不做任何修改,直接保存。
make -j16
sudo make modules_install
sudo make install
$ sudo make modules_install
SYMLINK /lib/modules/6.11.7/build
INSTALL /lib/modules/6.11.7/modules.order
INSTALL /lib/modules/6.11.7/modules.builtin
INSTALL /lib/modules/6.11.7/modules.builtin.modinfo
INSTALL /lib/modules/6.11.7/kernel/arch/x86/events/amd/amd-uncore.ko
SIGN /lib/modules/6.11.7/kernel/arch/x86/events/amd/amd-uncore.ko
INSTALL /lib/modules/6.11.7/kernel/arch/x86/events/intel/intel-cstate.ko
SIGN /lib/modules/6.11.7/kernel/arch/x86/events/intel/intel-cstate.ko
INSTALL /lib/modules/6.11.7/kernel/arch/x86/events/rapl.ko
SIGN /lib/modules/6.11.7/kernel/arch/x86/events/rapl.ko
INSTALL /lib/modules/6.11.7/kernel/arch/x86/kernel/cpu/mce/mce-inject.ko
SIGN /lib/modules/6.11.7/kernel/arch/x86/kernel/cpu/mce/mce-inject.ko
INSTALL /lib/modules/6.11.7/kernel/arch/x86/kernel/msr.ko
SIGN /lib/modules/6.11.7/kernel/arch/x86/kernel/msr.ko
INSTALL /lib/modules/6.11.7/kernel/arch/x86/kernel/cpuid.ko
SIGN /lib/modules/6.11.7/kernel/arch/x86/kernel/cpuid.ko
INSTALL /lib/modules/6.11.7/kernel/arch/x86/crypto/twofish-x86_64.ko
SIGN /lib/modules/6.11.7/kernel/arch/x86/crypto/twofish-x86_64.ko
INSTALL /lib/modules/6.11.7/kernel/arch/x86/crypto/twofish-x86_64-3way.ko
SIGN /lib/modules/6.11.7/kernel/arch/x86/crypto/twofish-x86_64-3way.ko
......
$ sudo make install
INSTALL /boot
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 6.11.7 /boot/vmlinuz-6.11.7
update-initramfs: Generating /boot/initrd.img-6.11.7
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8126a-2.fw for module r8169
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 6.11.7 /boot/vmlinuz-6.11.7
run-parts: executing /etc/kernel/postinst.d/update-notifier 6.11.7 /boot/vmlinuz-6.11.7
run-parts: executing /etc/kernel/postinst.d/xx-update-initrd-links 6.11.7 /boot/vmlinuz-6.11.7
I: /boot/initrd.img.old is now a symlink to initrd.img-5.15.0-126-generic
I: /boot/initrd.img is now a symlink to initrd.img-6.11.7
run-parts: executing /etc/kernel/postinst.d/zz-shim 6.11.7 /boot/vmlinuz-6.11.7
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 6.11.7 /boot/vmlinuz-6.11.7
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.11.7
Found initrd image: /boot/initrd.img-6.11.7
Found linux image: /boot/vmlinuz-5.15.0-126-generic
Found initrd image: /boot/initrd.img-5.15.0-126-generic
Found linux image: /boot/vmlinuz-5.15.0-67-generic
Found initrd image: /boot/initrd.img-5.15.0-67-generic
Adding boot menu entry for UEFI Firmware Settings
done
$ sudo update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.11.7
Found initrd image: /boot/initrd.img-6.11.7
Found linux image: /boot/vmlinuz-5.15.0-126-generic
Found initrd image: /boot/initrd.img-5.15.0-126-generic
Found linux image: /boot/vmlinuz-5.15.0-67-generic
Found initrd image: /boot/initrd.img-5.15.0-67-generic
Adding boot menu entry for UEFI Firmware Settings
done
解决 WIFI 不工作
git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
sudo cp iwlwifi-* /lib/firmware/`
sudo reboot