无法在 Ubuntu 20.04 上安装 Linux 内核

Unable to install Linux kernel on Ubuntu 20.04

我是内核社区的新手,我正在学习如何编译和安装 Linux 内核,但我无法安装它。我正在 运行ning 6 核 Ryzen 5 和 Ubuntu 20.04 LTS,我的编译器使用 gcc。我当前的内核版本是 5.11.0-38-generic,我正在尝试编译和安装 5.14.14 版本。我使用 Greg Kroah Heartman 的 Linux 内核简而言之作为指南。首先,我从 kernel.org 下载最新的主线内核。然后,我 运行 make menuconfig 为我的系统生成一个 .config。接下来,我 运行 make -j12 编译内核, 运行 没问题 return 没有任何错误。我在安装它时遇到了 运行 麻烦。在 运行ning make install 之后,我得到以下错误输出:

arch/x86/Makefile:148: CONFIG_X86_X32 enabled but no binutils support
sh ./arch/x86/boot/install.sh \
    5.14.14 arch/x86/boot/bzImage \
    System.map "/boot"

 *** Missing file: arch/x86/boot/bzImage
 *** You need to run "make" before "make install".

make[1]: *** [arch/x86/boot/Makefile:161: install] Error 1
make: *** [arch/x86/Makefile:280: install] Error 2

install.sh 告诉我在我的 arch 目录中没有 bzImage 文件。我检查了一下,确实文件丢失了。我尝试查找“丢失的 bzImage 文件”,但找不到任何有用的信息。为什么不生成一个大的 zImage 文件?

我在上面的评论中尝试了 Justin Iurman 的建议,它适用于安装内核。我需要在 make 之前 运行 make bzImage。在 make bzImage 成功之前,我必须在配置文件中编辑一行。但是,sudo make install 给出了一些奇怪的输出:

arch/x86/Makefile:148: CONFIG_X86_X32 enabled but no binutils support
sh ./arch/x86/boot/install.sh \
    5.14.14 arch/x86/boot/bzImage \
    System.map "/boot"
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 5.14.14 /boot/vmlinuz-5.14.14
run-parts: executing /etc/kernel/postinst.d/dkms 5.14.14 /boot/vmlinuz-5.14.14
 * dkms: running auto installation service for kernel 5.14.14                                                                                                                                              Error! Your kernel headers for kernel 5.14.14 cannot be found.
Please install the linux-headers-5.14.14 package,
or use the --kernelsourcedir option to tell DKMS where it's located
Error! Your kernel headers for kernel 5.14.14 cannot be found.
Please install the linux-headers-5.14.14 package,
or use the --kernelsourcedir option to tell DKMS where it's located
                                                                                                                                                                                                    [ OK ]
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 5.14.14 /boot/vmlinuz-5.14.14
update-initramfs: Generating /boot/initrd.img-5.14.14
W: missing /lib/modules/5.14.14
W: Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/5.14.14: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
cat: /var/tmp/mkinitramfs_lEKSEC/lib/modules/5.14.14/modules.builtin: No such file or directory
depmod: WARNING: could not open modules.order at /var/tmp/mkinitramfs_lEKSEC/lib/modules/5.14.14: No such file or directory
depmod: WARNING: could not open modules.builtin at /var/tmp/mkinitramfs_lEKSEC/lib/modules/5.14.14: No such file or directory
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 5.14.14 /boot/vmlinuz-5.14.14
run-parts: executing /etc/kernel/postinst.d/update-notifier 5.14.14 /boot/vmlinuz-5.14.14
run-parts: executing /etc/kernel/postinst.d/xx-update-initrd-links 5.14.14 /boot/vmlinuz-5.14.14
I: /boot/initrd.img.old is now a symlink to initrd.img-5.11.0-38-generic
I: /boot/initrd.img is now a symlink to initrd.img-5.14.14
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 5.14.14 /boot/vmlinuz-5.14.14
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.14.14
Found initrd image: /boot/initrd.img-5.14.14
Found linux image: /boot/vmlinuz-5.11.0-38-generic
Found initrd image: /boot/initrd.img-5.11.0-38-generic
Found linux image: /boot/vmlinuz-5.11.0-37-generic
Found initrd image: /boot/initrd.img-5.11.0-37-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done

看来我虽然可以安装内核,但没有正常启动,但由于我的问题是安装内核,所以我将此问题标记为已关闭。