1,系统版本说明:ARM 鲲鹏920
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS"
2, 将source.list中的deb-src打开
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse
deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-proposed main restricted universe multiverse
# # deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-proposed main restricted universe multiverse
3, 安装编译所需文件和软件
sudo apt-get update
sudo apt install -y make dpkg dpkg-dev libncurses5-dev libssl-dev libpciaccess0 ncurses-dev flex bison libelf-dev libssl-dev dwarves zstd
sudo apt build-dep linux #需要第一步
4, 下载内核源码
//查看系统可获得的内核源码
apt search linux-source
//下载系统源码文件(下载内核版本为4.15.0)
apt install linux-source-4.15.0=4.15.0-88.88
//解压源码
cd /usr/src/linux-source-4.15.0
tar -xjvf linux-source-4.15.0
或者:
apt install linux-source
5, 编译内核源码
//解压源码
cd /usr/src/linux-source-4.15.0
tar -xjvf linux-source-4.15.0
拷贝/boot/config-xxx ,到当前内核源码中
make menuconfig //直接保存、退出,生成配置文件.config
make -j64 //编译
make modules //编译模块
make modules_install //安装模块
make install //安装内核
cd /boot/grub
sudo update-grub2 //更新启动项
reboot
6,编译出错问题
root@Fish:/usr/src/linux-hwe-5.4-headers-5.4.0-42# make
scripts/kconfig/conf --syncconfig Kconfig
HOSTCC scripts/selinux/genheaders/genheaders
scripts/selinux/genheaders/genheaders.c:18:10: fatal error: classmap.h: No such file or directory
18 | #include "classmap.h"
| ^~~~~~~~~~~~
compilation terminated.
make[3]: *** [scripts/Makefile.host:107: scripts/selinux/genheaders/genheaders] Error 1
make[2]: *** [scripts/Makefile.build:522: scripts/selinux/genheaders] Error 2
make[1]: *** [scripts/Makefile.build:522: scripts/selinux] Error 2
make: *** [Makefile:1131: scripts] Error 2
原因就是因为使用了header的源码,这个源码时不完整的
七:编译deb包的升级方法
apt install make dpkg dpkg-dev libncurses5-dev libssl-dev libpciaccess0
mkdir /usr/src/linux-source-4.15.0/
tar -xvf linux-source-4.15.0.tgz -C /usr/src/linux-source-4.15.0/
cd /usr/src/linux-source-4.15.0/linux-source-4.15.0/
make menuconfig //直接保存、退出,生成配置文件.config
make -j64 //编译
make modules //编译模块
sudo make-kpkg --initrd --append-to-version -20220228 --revision 001 kernel_image kernel_headers -j4
在当前目录的上一级目录会生成:
inux-headers-4.15.18-20220228_001_arm64.deb
linux-image-4.15.18-20220228_001_arm64.deb
//内核升级安装
sudo dpkg -i linux-headers-4.15.18-20220228_001_arm64.deb
sudo dpkg -i linux-image-4.15.18-20220228_001_arm64.deb
cd /boot/grub
sudo update-grub2 //更新启动项
//如果更新的内核比当前系统的内核版本高,直接重启后,自动会使用高版本的内核
sudo reboot //即可升级完毕
//如果更新的内核比当前系统的内核版本低,就需要修改/etc/default/grub
cat /boot/grub/grub.cfg | grep menuentry 找到新版本的内核编号: 结果如下:
menuentry 'Ubuntu, with Linux 4.15.18-20220228' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.18-20220228-advanced-74577947-f486-4351-a2d3-fa0340afcda8' {
menuentry 'Ubuntu, with Linux 4.15.18-20220228 (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.18-20220228-recovery-74577947-f486-4351-a2d3-fa0340afcda8' {
menuentry 'Ubuntu, with Linux 4.15.0-76-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-76-generic-advanced-74577947-f486-4351-a2d3-fa0340afcda8' {文章来源:https://www.toymoban.com/news/detail-530118.html
如需要的是:
Ubuntu, with Linux 4.15.18-20220228
文章来源地址https://www.toymoban.com/news/detail-530118.html
# sudo vim /etc/default/grub
GRUB_DEFAULT=0
修改成:
GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 4.15.18-20220228"
接着继续更新grub2:
cd /boot/grub
sudo update-grub2 //更新启动项
到了这里,关于ARM Ubuntu内核更新记录的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!