赞
踩
编译内核分三步
1)make
2)sudo make modules_install
3)sudo make install
如何需要配置内核,在make之前,执行make menuconfig配置内核。
升级之前注意保存快照。做好备份。
参考遇到的问题。本次只记录遇到的问题是如何解决的。具体如何编译,参考本系列前两篇文章。
make时的报错。
cc1: out of memory allocating 89674192 bytes after a total of 193392640 bytes
- virtual memory exhausted: 无法分配内存
- scripts/Makefile.build:303: recipe for target 'drivers/net/ethernet/mellanox/mlx5/core/en_rep.o' failed
- make[5]: *** [drivers/net/ethernet/mellanox/mlx5/core/en_rep.o] Error 1
- scripts/Makefile.build:544: recipe for target 'drivers/net/ethernet/mellanox/mlx5/core' failed
- make[4]: *** [drivers/net/ethernet/mellanox/mlx5/core] Error 2
解决办法1:
提示内存不足,不太可能啊,当前内存是4G,那就将内存提升到8G。
然后...然后就解决了。增加内存以后,其他问题也自动消失了。有点意外啊。
执行sudo make modules_install也很顺利
执行 sudo make install时报错了。
- lkmao@ubuntu:/big/linux-4.19.260/linux-4.19.260$ sudo make install
- sh ./arch/x86/boot/install.sh 4.19.260 arch/x86/boot/bzImage \
- System.map "/boot"
- run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.19.260 /boot/vmlinuz-4.19.260
- run-parts: executing /etc/kernel/postinst.d/dkms 4.19.260 /boot/vmlinuz-4.19.260
- * dkms: running auto installation service for kernel 4.19.260
- Kernel preparation unnecessary for this kernel. Skipping...
-
- Building module:
- cleaning build area....(bad exit status: 2)
- make KERNELRELEASE=4.19.260 VM_UNAME=4.19.260 MODULEBUILDDIR=/var/lib/dkms/open-vm-tools/10.0.7/build -C vmxnet....(bad exit status: 2)
- ERROR (dkms apport): kernel package linux-headers-4.19.260 is not supported
- Error! Bad return status for module build on kernel: 4.19.260 (x86_64)
- Consult /var/lib/dkms/open-vm-tools/10.0.7/build/make.log for more information.
- [ OK ]
- run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.19.260 /boot/vmlinuz-4.19.260
- update-initramfs: Generating /boot/initrd.img-4.19.260
- run-parts: executing /etc/kernel/postinst.d/pm-utils 4.19.260 /boot/vmlinuz-4.19.260
- run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.19.260 /boot/vmlinuz-4.19.260
- run-parts: executing /etc/kernel/postinst.d/update-notifier 4.19.260 /boot/vmlinuz-4.19.260
- run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.19.260 /boot/vmlinuz-4.19.260
- Generating grub configuration file ...
- Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
- Found linux image: /boot/vmlinuz-4.19.260
- Found initrd image: /boot/initrd.img-4.19.260
- Found linux image: /boot/vmlinuz-4.15.0-142-generic
- Found initrd image: /boot/initrd.img-4.15.0-142-generic
- Found linux image: /boot/vmlinuz-4.15.0-29-generic
- Found initrd image: /boot/initrd.img-4.15.0-29-generic
- Found memtest86+ image: /boot/memtest86+.elf
- Found memtest86+ image: /boot/memtest86+.bin
- done
- lkmao@ubuntu:/big/linux-4.19.260/linux-4.19.260$
解决问题:
没看出来什么情况,重启看看有没有升级成功。
查看版本号
cat /proc/version
Linux version 4.19.260 (lkmao@ubuntu) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12)) #1 SMP Thu Sep 29 14:19:07 CST 2022
竟然升级成功了。
执行perf命令时,报错如下所示:
- lkmao@ubuntu:/big/linux-4.19.260/linux-4.19.260$ perf
- WARNING: perf not found for kernel 4.19.260
-
- You may need to install the following packages for this specific kernel:
- linux-tools-4.19.260-4.19.260
- linux-cloud-tools-4.19.260-4.19.260
-
- You may also want to install one of the following packages to keep up to date:
- linux-tools-4.19.260
- linux-cloud-tools-4.19.260
- lkmao@ubuntu:/big/linux-4.19.260/linux-4.19.260$
事情解决的意外简单。
make oldconfigmake oldconfig与make config类似,但是它的作用是在现有内核设置文件基础上建立一个新的设置文件,只会向用户提问有关新内核特性的问题。在内核升级的过程中,make oldconfig非常有用。用户可以将现有内核的设置文件.config复制到新内核的源码目录中,执行make oldconfig,此时,用户只需要回答那些针对新增特性的问题。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。