当前位置: 首页 > news >正文

ubuntu 22.04 编译安装新内核

1、普通用户登录系统

查看当前内核版本

$ uname -r
5.15.0-118-generic

2、下载内核源码

www.kernel.org

用户home目录新建子目录linux,下载并解压 linux-5.15.165.tar.xz

3、创建起始的配置文件.config

Configuration targets (见linux kernel in a nutshell)

configUpdates the current kernel configuration by using a line-oriented program.
menuconfigUpdates the current kernel configuration by using a text-based menu program.
xconfigUpdates the current kernel configuration by using a QT-based graphical program.
gconfigUpdates the current kernel configuration by using a GTK+-based graphical program.
oldconfigUpdates the current kernel configuration by using the current .config file and prompting for any new options that have been added to the kernel.
silentoldconfigJust like oldconfig, but prints nothing to the screen except when a question needs to be answered.
randconfigGenerates a new kernel configuration with random answers to all of the different options.
defconfigGenerates a new kernel configuration with the default answer being used for all options. The default values are taken from a file located in the arch/$ARCH/defconfig file, where $ARCH refers to the specific architecture for which the kernel is being built.
allmodconfigGenerates a new kernel configuration in which modules are enabled whenever possible.
allyesconfigGenerates a new kernel configuration with all options set to yes.
allnoconfigGenerates a new kernel configuration with all options set to no.
$ cd linux-5.15.165

三种方法创建.config文件

(1)使用源码自带的defconfig文件。适合嵌入式系统。

$ sudo make defconfig

(2)使用当前系统的config文件

$ cp /boot/config-$(uname -r) ./.config

一些新内核新增加的配置需要手工配置。

(3)使用localmodconfig 获取精简的编译配置(本文使用)

发布版的内核包含很多内核模块,但是对某个特定机器,实际用到的模块只是其中的极小一部分。
重新构建内核时,对不使用的模块进行编译就会浪费时间。
将localmodconfig作为make的目标,kbuild系统会获取一个当前在用的模块的列表,
生成仅以正在使用的内核模块为对象的.config文件,减少编译时间。

localmodconfig 也是使用 /boot/config-$(uname -r) 作为基准的。

$ lsmod > /tmp/mod
$ sudo make LSMOD=/tmp/mod localmodconfig

4、按需修改配置

$ sudo make menuconfig

按/输入配置项名称,可以省略CONFIG_前缀,回车搜索
按搜索结果旁的数字,可跳转至配置项,输入y、m、n更改配置
按Esc,直至返回到初始页
继续下一个配置项
选择Save,输入新文件名

5、构建内核

Build targets(见linux kernel in a nutshell)

allBuilds all of the different targets needed for this kernel to be able to be used. This includes both the modules and the static portion of the kernel.
vmlinuxBuilds just the static portion of the kernel, not any loadable modules.
modulesBuilds all of the loadable kernel modules for this configuration.
modules_installInstalls all of the modules into the specified location. If no location is specified with the INSTALL_MODULE_PATH environment variable, they are installed in the default root directory of the machine.
dir/Builds all of the files in the specified directory and in all subdirectories below it.
dir/file.[o|i|s]Builds only the specified file.
dir/file.koBuilds all of the needed files and links them together to form the specified module.
tagsBuilds all of the needed tags that most common text editors can use while editing the source code.
$ sudo make

问题:
scripts/extract-cert.c:21:10: fatal error: openssl/bio.h: No such file or directory
解决:
sudo apt install libssl-dev

问题:
<stdin>:1:10: fatal error: libelf.h: No such file or directory
解决:
sudo apt install libelf-dev

问题:
make[1]: *** No rule to make target 'debian/canonical-certs.pem', needed by 'certs/x509_certificate_list'.  Stop.
解决:
vi .config
CONFIG_SYSTEM_TRUSTED_KEYS="debian/canonical-certs.pem" 改为""
CONFIG_SYSTEM_REVOCATION_KEYS="debian/canonical-revoked-certs.pem" 改为""

问题:
net/core/rtnetlink.c:3528:1: warning: the frame size of 1112 bytes is larger than 1024 bytes [-Wframe-larger-than=]
解决:
vi .config
CONFIG_FRAME_WARN=1024 改为 4096

问题:
arch/x86/kernel/head_64.o: warning: objtool: .text+0x5: unreachable instruction
arch/x86/kernel/smp.o: warning: objtool: sysvec_reboot()+0x54: unreachable instruction
arch/x86/kernel/smp.o: warning: objtool: sysvec_reboot()+0x4c: unreachable instruction

解决:TODO

6、安装构建的所有模块

几乎所有发行版都附带一个名为 installkernel 的脚本(/usr/sbin/installkernel),内核构建系统可以使用该脚本自动将构建的内核安装到正确的位置并修改引导加载程序,开发人员无需执行任何额外操作。提供 installkernel 的发行版通常会将其放在名为 mkinitrd 的包中,因此如果在机器上找不到该脚本,请尝试安装该包。

$ sudo make modules_install INSTALL /lib/modules/5.15.165/kernel/drivers/net/dummy.koINSTALL /lib/modules/5.15.165/kernel/drivers/net/vxlan/vxlan.koINSTALL /lib/modules/5.15.165/kernel/drivers/thermal/intel/x86_pkg_temp_thermal.koINSTALL /lib/modules/5.15.165/kernel/fs/efivarfs/efivarfs.koINSTALL /lib/modules/5.15.165/kernel/net/ipv4/netfilter/iptable_nat.koINSTALL /lib/modules/5.15.165/kernel/net/ipv4/udp_tunnel.koINSTALL /lib/modules/5.15.165/kernel/net/ipv6/ip6_udp_tunnel.koINSTALL /lib/modules/5.15.165/kernel/net/netfilter/nf_log_syslog.koINSTALL /lib/modules/5.15.165/kernel/net/netfilter/xt_LOG.koINSTALL /lib/modules/5.15.165/kernel/net/netfilter/xt_MASQUERADE.koINSTALL /lib/modules/5.15.165/kernel/net/netfilter/xt_addrtype.koINSTALL /lib/modules/5.15.165/kernel/net/netfilter/xt_mark.koINSTALL /lib/modules/5.15.165/kernel/net/netfilter/xt_nat.koINSTALL /lib/modules/5.15.165/kernel/net/sched/act_bpf.koINSTALL /lib/modules/5.15.165/kernel/net/sched/act_gact.koINSTALL /lib/modules/5.15.165/kernel/net/sched/act_police.koINSTALL /lib/modules/5.15.165/kernel/net/sched/cls_bpf.koINSTALL /lib/modules/5.15.165/kernel/net/sched/sch_sfq.koDEPMOD  /lib/modules/5.15.165

将模块放在文件系统中的适当位置,以便新内核正确找到。
模块位于 /lib/modules/kernel_version 目录中,其中 kernel_version 是刚构建的新内核的版本。

7、安装主内核镜像

将启动以下过程: 
(1)内核构建系统将验证内核是否构建成功。
(2)构建系统会将 static kernel 部分安装到 /boot 目录下,并根据构建内核的内核版本命名这个可执行文件。
(3)将使用刚刚在 modules_install 阶段安装的模块自动创建任何所需的初始 ramdisk 映像。
(4)bootloader程序将被正确通知存在新内核,并将其添加到相应的菜单中,以便用户可以在下次引导机器时选择它。
(5)完成此操作后,内核安装成功,您可以安全地重新启动并试用新的内核映像。
请注意,此安装不会覆盖任何较旧的内核映像,因此,如果新内核映像出现问题,可以在引导时选择旧内核。

$ sudo make install
arch/x86/Makefile:142: CONFIG_X86_X32 enabled but no binutils support
sh ./arch/x86/boot/install.sh 5.15.165 \arch/x86/boot/bzImage System.map "/boot"
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 5.15.165 /boot/vmlinuz-5.15.165
update-initramfs: Generating /boot/initrd.img-5.15.165
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 5.15.165 /boot/vmlinuz-5.15.165
run-parts: executing /etc/kernel/postinst.d/update-notifier 5.15.165 /boot/vmlinuz-5.15.165
run-parts: executing /etc/kernel/postinst.d/xx-update-initrd-links 5.15.165 /boot/vmlinuz-5.15.165
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 5.15.165 /boot/vmlinuz-5.15.165
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.165
Found initrd image: /boot/initrd.img-5.15.165
Found linux image: /boot/vmlinuz-5.15.165.old
Found initrd image: /boot/initrd.img-5.15.165
Found linux image: /boot/vmlinuz-5.15.0-118-generic
Found initrd image: /boot/initrd.img-5.15.0-118-generic
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
done

问题:
arch/x86/Makefile:142: CONFIG_X86_X32 enabled but no binutils support
解决:
安装binutils 或者 找到arch/x86/Makefile的142行,注释掉CONFIG_X86_X32相关配置。

问题:
Warning: os-prober will not be executed to detect other bootable partitions.
解决:
vi /etc/default/grub
添加 GRUB_DISABLE_OS_PROBER=false
sudo update-grub

$ sudo make install
sh ./arch/x86/boot/install.sh 5.15.165 \arch/x86/boot/bzImage System.map "/boot"
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 5.15.165 /boot/vmlinuz-5.15.165
update-initramfs: Generating /boot/initrd.img-5.15.165
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 5.15.165 /boot/vmlinuz-5.15.165
run-parts: executing /etc/kernel/postinst.d/update-notifier 5.15.165 /boot/vmlinuz-5.15.165
run-parts: executing /etc/kernel/postinst.d/xx-update-initrd-links 5.15.165 /boot/vmlinuz-5.15.165
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 5.15.165 /boot/vmlinuz-5.15.165
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.165
Found initrd image: /boot/initrd.img-5.15.165
Found linux image: /boot/vmlinuz-5.15.165.old
Found initrd image: /boot/initrd.img-5.15.165
Found linux image: /boot/vmlinuz-5.15.0-118-generic
Found initrd image: /boot/initrd.img-5.15.0-118-generic
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
done

8、重启系统

# reboot

查看当前内核版本

# uname -r
5.15.165

9、实现开机进入grub引导菜单,选择可用内核启动

# vi /etc/default/grub
注释 GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT 改为 30
GRUB_CMDLINE_LINUX_DEFAULT 改为 text

# 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-5.15.165
Found initrd image: /boot/initrd.img-5.15.165
Found linux image: /boot/vmlinuz-5.15.165.old
Found initrd image: /boot/initrd.img-5.15.165
Found linux image: /boot/vmlinuz-5.15.0-118-generic
Found initrd image: /boot/initrd.img-5.15.0-118-generic
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
done

# reboot

选择第二项,显示可选的启动内核项

相关文章:

ubuntu 22.04 编译安装新内核

1、普通用户登录系统 查看当前内核版本 $ uname -r 5.15.0-118-generic 2、下载内核源码 www.kernel.org 用户home目录新建子目录linux&#xff0c;下载并解压 linux-5.15.165.tar.xz 3、创建起始的配置文件.config Configuration targets &#xff08;见linux kernel i…...

Linux 文件权限与属性管理

概述 Linux 系统是一种典型的多用户系统&#xff0c;不同的用户处于不同的地位&#xff0c;拥有不同的权限。为了保护系统的安全性&#xff0c;Linux 对不同用户访问同一文件&#xff08;包括目录文件&#xff09;的权限做了详细的规定。 文件属性查看 在 Linux 中&#xff0…...

Django学习实战篇三(适合略有基础的新手小白学习)(从0开发项目)

前言&#xff1a; 在上一章中&#xff0c;我们对Django的Model层有了比较全面的认识&#xff0c;本章就来配置Django自带的admin。这里需要认识到&#xff0c;Django的Model层是很重要的一环&#xff0c;无论是对于框架本身还是对于基于Django框架开发的大多数系统而言。因为一…...

【SPIE独立出版,连续2届稳定EI检索!】2024年第三届信息学,网络与计算技术国际学术会议(ICINC2024,10月25-27)

2024年第三届信息学&#xff0c;网络与计算技术国际学术会议(ICINC2024)将于2024年10月25-27日于中国郑州召开。 会议将围绕信息技术与通信&#xff0c;网络与计算技术等在相关领域中的最新研究成果&#xff0c;为来自国内外高等院校、科学研究所、企事业单位的专家、教授、学者…...

.NET/C#⾯试题汇总系列:基础语法

1. 字符串中string strnull和string str""和string strstring.Empty的区别&#xff1f; string str null;&#xff1a;这种方式声明了一个字符串变量str&#xff0c;并将其初始化为null。这意味着str不指向任何实际的字符串对象。如果你试图访问str的属性或方法&…...

【论文阅读】SwiftTheft: A Time-Efficient Model Extraction Attack Framework(2024)

完整标题 SwiftTheft: A Time-Efficient Model Extraction Attack Framework Against Cloud-Based Deep Neural Networks 摘要 With the rise of artificial intelligence(人工智能) and cloud computing(云计算), machine-learning-as-a-service platforms(机器学习即…...

springcloud间通信的方式

在 Spring Cloud 中&#xff0c;主要有以下几种通信方式&#xff1a; 一、基于 HTTP 的 RESTful API 工作原理&#xff1a; 这是一种常见的通信方式&#xff0c;各个微服务通过发送 HTTP 请求来相互调用。服务提供者暴露 RESTful API 接口&#xff0c;服务消费者通过 HTTP 客户…...

【C++ Qt day9】

2、将day1做的登录界面升级优化【资源文件的添加】 3、 使用手动连接&#xff0c;将登录框中的取消按钮使用第2种方式的连接到自定义的槽函数中&#xff0c;在自定义的槽函数中调用关闭函数 将登录按钮使用qt4版本的连接到自定义的槽函数中&#xff0c;在槽函数中判断ui界面上…...

中国传媒业人工智能应用发展图谱2024

易观分析&#xff1a;传媒产业是指以传播各类信息、知识为核心&#xff0c;通过多种媒介形式进行内容生产、发布和分发的综合性产业。技术的进步和应用对于传媒产业发展变革起到了核心驱动力的作用&#xff0c;2022年生成式AI进入应用爆发期&#xff0c;不仅带动了人工智能产业…...

RTX3060 FP64测试与猜想

RTX3060 FP64测试与猜想 一.小结二.查看FP64的峰值性能三.打满FP64、FP32的利用率,对比差异四.进一步证明pipe_fp64_cycles_active并不是2个fp64 core的metrics RTX3060 FP64测试与猜想 一.小结 RTX3060 compute capability为8.6,每个SM有2个FP64 core。每个cycle可输出2个fp…...

uniapp写移动端常见问题汇总

1. 手机顶部状态栏遮挡 写在需要的地方 <view class"status_bar" style"height: var(--status-bar-height); width: 100%;">2. 手机顶部状态栏字体颜色 // pages.json "statusBarStyle": "light",3. 背景覆盖全屏 page{widt…...

Linux运维排查常见故障_在tmp目录下有大量包含picture_ 的临时文件,每天晚上2 30需要对一天前的文件进行

echo“”>>/etc/security/limits.conf echo“*softnproc65535″>>/etc/security/limits.conf echo“*hardnproc65535″>>/etc/security/limits.conf echo“*softnofile65535″>>/etc/security/limits.conf echo“*hardnofile65535″>>/etc/secur…...

基于SpringBoot的智能制造云平台系统的设计与实现计算机毕设

一、选题背景与意义&#xff08;300字左右&#xff09; 根据工业4.0智能制造生态链中云工厂在实际生产当中的工作流程进行充分调研和整理出来的&#xff0c;描述最终用户在本系统中对于生产订单的处理、排产、以及生产的完整在线处理流程和业务需求的文档。 针对制造业而言&a…...

论文翻译:arxiv-2024 Benchmarking Benchmark Leakage in Large Language Models

Benchmarking Benchmark Leakage in Large Language Models https://arxiv.org/abs/2404.18824 在大型语言模型中基准测试泄露的基准测试 文章目录 在大型语言模型中基准测试泄露的基准测试摘要1 引言 图1&#xff1a;不同模型在基准测试的训练集上进行逐字训练相对于测试集以…...

十二、新版UI

一、UI Toolkit 这个组件是新版的UI系统 创建了一个新的UIBuild&#xff0c;在单独的场景中打开 未来Unity会以这个为基准。 缺点&#xff1a;目前没有Animator&#xff0c;做不了动画&#xff1b;没法加shader...

Path系统环境变量和CLASSPATH环境变量

Path系统环境变量 概述&#xff1a;Path环境变量不是java的&#xff0c;它隶属于windows操作系统 作用&#xff1a; PATH环境变量实际上就是给windows操作系统指路的。 在Path环境变量中有很多路径&#xff0c;路径和路径之间采用 分号(;) 隔开在DOS命令窗口中输入一条DOS命…...

自然语言处理系列六十六》对话机器人项目实战》对话机器人原理与介绍

注&#xff1a;此文章内容均节选自充电了么创始人&#xff0c;CEO兼CTO陈敬雷老师的新书《自然语言处理原理与实战》&#xff08;人工智能科学与技术丛书&#xff09;【陈敬雷编著】【清华大学出版社】 文章目录 自然语言处理系列六十六对话机器人项目实战》对话机器人原理与介…...

解码数字化转型顶层规划(附236页PPT:xx企业数字化转型项目顶层规划方案)

写在前面&#xff1a;PPT分享见后文~ 企业数字化转型顶层规划的制定是一个系统性的过程&#xff0c;需要综合考虑多个方面。以下是制定企业数字化转型顶层规划的一些关键步骤和要点&#xff0c;以供参考&#xff1a; 1、明确数字化转型战略定位&#xff1a; 将数字化转型作为…...

无需温度修正,测值准确可靠 GEO ACxxxx型振弦式锚索测力计

无需温度修正&#xff0c;测值准确可靠 GEO ACxxxx型振弦式锚索测力计 精准稳定的振弦式传感器&#xff0c;ACxxxx型振弦式锚索测力计&#xff0c;是长期监测预应力锚索压力的不二选择。采用特制应变计作为传感部件&#xff0c;无需温度修正&#xff0c;测值准确可靠。该传感器…...

shell脚本【一、 特殊变量/子串/特殊扩展变量/父子shell/内置命令、外置命令】

特殊变量 位置参数的获取 $0 获取shell脚本文件名&#xff0c;以及脚本路径&#xff1b;$n 获取shell脚本的第n个参数&#xff0c;n在1&#xff5e;9之间&#xff0c;如$1$2$9,大于9则需要写 ${10}&#xff1b;$# 获取执行的shell脚本后面的参数总个数&#xff1b;$* 获取she…...

多模态2025:技术路线“神仙打架”,视频生成冲上云霄

文&#xff5c;魏琳华 编&#xff5c;王一粟 一场大会&#xff0c;聚集了中国多模态大模型的“半壁江山”。 智源大会2025为期两天的论坛中&#xff0c;汇集了学界、创业公司和大厂等三方的热门选手&#xff0c;关于多模态的集中讨论达到了前所未有的热度。其中&#xff0c;…...

基于大模型的 UI 自动化系统

基于大模型的 UI 自动化系统 下面是一个完整的 Python 系统,利用大模型实现智能 UI 自动化,结合计算机视觉和自然语言处理技术,实现"看屏操作"的能力。 系统架构设计 #mermaid-svg-2gn2GRvh5WCP2ktF {font-family:"trebuchet ms",verdana,arial,sans-…...

linux之kylin系统nginx的安装

一、nginx的作用 1.可做高性能的web服务器 直接处理静态资源&#xff08;HTML/CSS/图片等&#xff09;&#xff0c;响应速度远超传统服务器类似apache支持高并发连接 2.反向代理服务器 隐藏后端服务器IP地址&#xff0c;提高安全性 3.负载均衡服务器 支持多种策略分发流量…...

基于ASP.NET+ SQL Server实现(Web)医院信息管理系统

医院信息管理系统 1. 课程设计内容 在 visual studio 2017 平台上&#xff0c;开发一个“医院信息管理系统”Web 程序。 2. 课程设计目的 综合运用 c#.net 知识&#xff0c;在 vs 2017 平台上&#xff0c;进行 ASP.NET 应用程序和简易网站的开发&#xff1b;初步熟悉开发一…...

基于Uniapp开发HarmonyOS 5.0旅游应用技术实践

一、技术选型背景 1.跨平台优势 Uniapp采用Vue.js框架&#xff0c;支持"一次开发&#xff0c;多端部署"&#xff0c;可同步生成HarmonyOS、iOS、Android等多平台应用。 2.鸿蒙特性融合 HarmonyOS 5.0的分布式能力与原子化服务&#xff0c;为旅游应用带来&#xf…...

MMaDA: Multimodal Large Diffusion Language Models

CODE &#xff1a; https://github.com/Gen-Verse/MMaDA Abstract 我们介绍了一种新型的多模态扩散基础模型MMaDA&#xff0c;它被设计用于在文本推理、多模态理解和文本到图像生成等不同领域实现卓越的性能。该方法的特点是三个关键创新:(i) MMaDA采用统一的扩散架构&#xf…...

工业自动化时代的精准装配革新:迁移科技3D视觉系统如何重塑机器人定位装配

AI3D视觉的工业赋能者 迁移科技成立于2017年&#xff0c;作为行业领先的3D工业相机及视觉系统供应商&#xff0c;累计完成数亿元融资。其核心技术覆盖硬件设计、算法优化及软件集成&#xff0c;通过稳定、易用、高回报的AI3D视觉系统&#xff0c;为汽车、新能源、金属制造等行…...

技术栈RabbitMq的介绍和使用

目录 1. 什么是消息队列&#xff1f;2. 消息队列的优点3. RabbitMQ 消息队列概述4. RabbitMQ 安装5. Exchange 四种类型5.1 direct 精准匹配5.2 fanout 广播5.3 topic 正则匹配 6. RabbitMQ 队列模式6.1 简单队列模式6.2 工作队列模式6.3 发布/订阅模式6.4 路由模式6.5 主题模式…...

虚拟电厂发展三大趋势:市场化、技术主导、车网互联

市场化&#xff1a;从政策驱动到多元盈利 政策全面赋能 2025年4月&#xff0c;国家发改委、能源局发布《关于加快推进虚拟电厂发展的指导意见》&#xff0c;首次明确虚拟电厂为“独立市场主体”&#xff0c;提出硬性目标&#xff1a;2027年全国调节能力≥2000万千瓦&#xff0…...

CRMEB 中 PHP 短信扩展开发:涵盖一号通、阿里云、腾讯云、创蓝

目前已有一号通短信、阿里云短信、腾讯云短信扩展 扩展入口文件 文件目录 crmeb\services\sms\Sms.php 默认驱动类型为&#xff1a;一号通 namespace crmeb\services\sms;use crmeb\basic\BaseManager; use crmeb\services\AccessTokenServeService; use crmeb\services\sms\…...