linux内核编译linux内核⑦(安装内核模块|安装内核|重启系统|查看当前内核版本)(代码片段)

韩曙亮 韩曙亮     2023-03-09     590

关键词:

文章目录





一、安装内核模块



确保 Linux 内核编译完成 , 没有任何报错之后 ; 参考 【Linux 内核】编译 Linux 内核 ⑥ ( 安装 OpenSSL | 安装其它依赖库 | 内核编译完成 ) 博客 ;


进入 Linux 内核源码的根目录 , 执行

sudo make modules_install

命令 , 安装编译好的内核模块 ;

安装成功后命令行最后一页内容 :

完整过程如下 :

root@ubuntu:~# cd kernel/
root@ubuntu:~/kernel# cd linux-5.6.14
root@ubuntu:~/kernel/linux-5.6.14# 
root@ubuntu:~/kernel/linux-5.6.14# 
root@ubuntu:~/kernel/linux-5.6.14# ls
arch   COPYING  Documentation  include  Kbuild   lib          Makefile         modules.builtin.modinfo  net      scripts   System.map  virt            vmlinux.o
block  CREDITS  drivers        init     Kconfig  LICENSES     mm               modules.order            README   security  tools       vmlinux
certs  crypto   fs             ipc      kernel   MAINTAINERS  modules.builtin  Module.symvers           samples  sound     usr         vmlinux-gdb.py
root@ubuntu:~/kernel/linux-5.6.14# 
root@ubuntu:~/kernel/linux-5.6.14# 
root@ubuntu:~/kernel/linux-5.6.14# sudo make modules_install
  INSTALL arch/x86/crypto/aesni-intel.ko
  INSTALL arch/x86/crypto/blowfish-x86_64.ko
  INSTALL arch/x86/crypto/camellia-aesni-avx-x86_64.ko
  INSTALL arch/x86/crypto/camellia-aesni-avx2.ko
  INSTALL arch/x86/crypto/camellia-x86_64.ko
  INSTALL arch/x86/crypto/cast5-avx-x86_64.ko
  INSTALL arch/x86/crypto/cast6-avx-x86_64.ko
  INSTALL arch/x86/crypto/chacha-x86_64.ko
  INSTALL arch/x86/crypto/crc32-pclmul.ko
  INSTALL arch/x86/crypto/crct10dif-pclmul.ko
  INSTALL arch/x86/crypto/des3_ede-x86_64.ko
  INSTALL arch/x86/crypto/ghash-clmulni-intel.ko
  INSTALL arch/x86/crypto/glue_helper.ko
  INSTALL arch/x86/crypto/poly1305-x86_64.ko
  INSTALL arch/x86/crypto/serpent-avx-x86_64.ko
  INSTALL arch/x86/crypto/serpent-avx2.ko
  INSTALL arch/x86/crypto/serpent-sse2-x86_64.ko
  INSTALL arch/x86/crypto/sha1-ssse3.ko
  INSTALL arch/x86/crypto/sha256-ssse3.ko
  INSTALL arch/x86/crypto/sha512-ssse3.ko
  INSTALL arch/x86/crypto/twofish-avx-x86_64.ko
  INSTALL arch/x86/crypto/twofish-x86_64-3way.ko
  INSTALL arch/x86/crypto/twofish-x86_64.ko
  INSTALL arch/x86/events/intel/intel-cstate.ko
  INSTALL arch/x86/events/intel/intel-rapl-perf.ko
  INSTALL arch/x86/kernel/cpu/mce/mce-inject.ko
  INSTALL arch/x86/kernel/cpuid.ko
  INSTALL arch/x86/kernel/msr.ko
  INSTALL arch/x86/kvm/kvm-amd.ko
  INSTALL arch/x86/kvm/kvm-intel.ko
  INSTALL arch/x86/kvm/kvm.ko
  INSTALL arch/x86/oprofile/oprofile.ko
  INSTALL arch/x86/platform/atom/punit_atom_debug.ko
  INSTALL block/bfq.ko
  INSTALL block/kyber-iosched.ko
  INSTALL crypto/842.ko
  INSTALL crypto/aes_ti.ko
  INSTALL crypto/af_alg.ko
  INSTALL crypto/algif_aead.ko
  INSTALL crypto/algif_hash.ko
  INSTALL crypto/algif_rng.ko
  INSTALL crypto/algif_skcipher.ko
  INSTALL crypto/ansi_cprng.ko
  INSTALL crypto/anubis.ko
  INSTALL crypto/arc4.ko
  INSTALL crypto/asymmetric_keys/pkcs7_test_key.ko
  INSTALL crypto/async_tx/async_memcpy.ko
  INSTALL crypto/async_tx/async_pq.ko
  INSTALL crypto/async_tx/async_raid6_recov.ko
  INSTALL crypto/async_tx/async_tx.ko
  INSTALL crypto/async_tx/async_xor.ko
  INSTALL crypto/authenc.ko
  INSTALL crypto/authencesn.ko
  INSTALL crypto/blake2b_generic.ko
  INSTALL crypto/blowfish_common.ko
  INSTALL crypto/blowfish_generic.ko
  INSTALL crypto/camellia_generic.ko
  INSTALL crypto/cast5_generic.ko
  INSTALL crypto/cast6_generic.ko
  INSTALL crypto/cast_common.ko
  INSTALL crypto/ccm.ko
  INSTALL crypto/chacha20poly1305.ko
  INSTALL crypto/chacha_generic.ko
  INSTALL crypto/cmac.ko
  INSTALL crypto/crc32_generic.ko
  INSTALL crypto/cryptd.ko
  INSTALL crypto/crypto_engine.ko
  INSTALL crypto/crypto_simd.ko
  INSTALL crypto/crypto_user.ko
  INSTALL crypto/des_generic.ko
  INSTALL crypto/ecc.ko
  INSTALL crypto/ecdh_generic.ko
  INSTALL crypto/echainiv.ko
  INSTALL crypto/essiv.ko
  INSTALL crypto/fcrypt.ko
  INSTALL crypto/keywrap.ko
  INSTALL crypto/khazad.ko
  INSTALL crypto/lrw.ko
  INSTALL crypto/lz4.ko
  INSTALL crypto/lz4hc.ko
  INSTALL crypto/md4.ko
  INSTALL crypto/michael_mic.ko
  INSTALL crypto/pcbc.ko
  INSTALL crypto/pcrypt.ko
  INSTALL crypto/poly1305_generic.ko
  INSTALL crypto/rmd128.ko
  INSTALL crypto/rmd160.ko
  INSTALL crypto/rmd256.ko
  INSTALL crypto/rmd320.ko
  INSTALL crypto/salsa20_generic.ko
  INSTALL crypto/seed.ko
  INSTALL crypto/serpent_generic.ko
  INSTALL crypto/sha3_generic.ko
  INSTALL crypto/tcrypt.ko
  INSTALL crypto/tea.ko
  INSTALL crypto/tgr192.ko
  INSTALL crypto/twofish_common.ko
  INSTALL crypto/twofish_generic.ko
  INSTALL crypto/vmac.ko
  INSTALL crypto/wp512.ko
  INSTALL crypto/xcbc.ko
  INSTALL crypto/xor.ko
  INSTALL crypto/xxhash_generic.ko
  INSTALL crypto/zstd.ko
  INSTALL drivers/acpi/acpi_configfs.ko
  INSTALL drivers/acpi/acpi_extlog.ko
  INSTALL drivers/acpi/acpi_ipmi.ko
  INSTALL drivers/acpi/acpi_pad.ko
  INSTALL drivers/acpi/apei/einj.ko
  INSTALL drivers/acpi/dptf/dptf_power.ko
  INSTALL drivers/acpi/ec_sys.ko
  INSTALL drivers/acpi/nfit/nfit.ko
  INSTALL drivers/acpi/sbs.ko
  INSTALL drivers/acpi/sbshc.ko
  INSTALL drivers/acpi/video.ko
  INSTALL drivers/ata/acard-ahci.ko
  INSTALL drivers/ata/ahci.ko
  # 省略5000 
  INSTALL sound/usb/line6/snd-usb-toneport.ko
  INSTALL sound/usb/line6/snd-usb-variax.ko
  INSTALL sound/usb/misc/snd-ua101.ko
  INSTALL sound/usb/snd-usb-audio.ko
  INSTALL sound/usb/snd-usbmidi-lib.ko
  INSTALL sound/usb/usx2y/snd-usb-us122l.ko
  INSTALL sound/usb/usx2y/snd-usb-usx2y.ko
  INSTALL sound/x86/snd-hdmi-lpe-audio.ko
  INSTALL virt/lib/irqbypass.ko
  DEPMOD  5.6.14
root@ubuntu:~/kernel/linux-5.6.14# 
root@ubuntu:~/kernel/linux-5.6.14# 




二、安装内核



内核模块安装完成后 , 执行

sudo make install

命令 , 安装内核 ;

下面的内核安装过程会持续很长时间 ;

内核安装过程 :

root@ubuntu:~# cd kernel/linux-5.6.14
root@ubuntu:~/kernel/linux-5.6.14# 
root@ubuntu:~/kernel/linux-5.6.14# sudo make install
sh ./arch/x86/boot/install.sh 5.6.14 arch/x86/boot/bzImage \\
	System.map "/boot"
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 5.6.14 /boot/vmlinuz-5.6.14
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 5.6.14 /boot/vmlinuz-5.6.14
update-initramfs: Generating /boot/initrd.img-5.6.14
run-parts: executing /etc/kernel/postinst.d/pm-utils 5.6.14 /boot/vmlinuz-5.6.14
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 5.6.14 /boot/vmlinuz-5.6.14
run-parts: executing /etc/kernel/postinst.d/update-notifier 5.6.14 /boot/vmlinuz-5.6.14
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 5.6.14 /boot/vmlinuz-5.6.14
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-5.6.14
Found initrd image: /boot/initrd.img-5.6.14
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.13.0-36-generic
Found initrd image: /boot/initrd.img-4.13.0-36-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done
root@ubuntu:~/kernel/linux-5.6.14# 





三、重启系统



执行

reboot

命令 , 重启 Ubuntu 操作系统 ;





四、查看当前内核版本



重启之后 , 在命令行终端执行

uname -a

命令 , 查看当前的内核版本 , 发现当前内核版本已经

linux内核配置编译以及模块开发(代码片段)

文章目录Linux内核简介Linux体系结构Linux内核架构虚拟文件系统内核源码结构Linux内核配置与编译为什么要配置内核?内核配置方法编译内核过程Linux内核模块开发什么是内核模块内核模块设计安装与卸载模块可选信息模块申明... 查看详情

1-18编译安装内核支持ntfs文件系统

大纲:源码编译Linux内核使用Linux内核模块实战:编译一个NTFS内核模块,实现Linux挂载NTFS文件系统并实现读写功能===================================================================一、源码编译Linux内核通常我们想对内核进行升级时,可通过下... 查看详情

如何编译linux版本

参考技术A编译安装内核下载并解压内核解压内核:tarxflinux-2.6.XX.tar.xz定制内核:makemenuconfig参见makefilemenuconfig过程讲解编译内核和模块:make生成内核模块和vmlinuz,initrd.img,Symtem.map文件安装内核和模块:sudomakemodules_installinstall... 查看详情

linux内核编译

内核中的功能除了核心功能之外,在编译时,大多功能都有三种选择:1、不使用此功能;2、编译成内核模块;3、编译进内核;如何手动编译内核:makegconfig:Gnome桌面环境使用,需要安装图形开发库组:GNOMESoftwareDevelopmentmakekconfi... 查看详情

编写Linux内核模块是不是需要编译自己的内核?

】编写Linux内核模块是不是需要编译自己的内核?【英文标题】:DoesWritingLinuxKernelModuleRequireCompilingOwnKernel?编写Linux内核模块是否需要编译自己的内核?【发布时间】:2021-08-0309:23:45【问题描述】:我在Ubuntux86_64上有一个简单的he... 查看详情

Linux内核模块编译

】Linux内核模块编译【英文标题】:Linuxkernelmodulecompiling【发布时间】:2011-05-0302:15:31【问题描述】:我尝试编译简单的linux内核模块:#include<linux/module.h>#include<linux/kernel.h>intinit_module(void)printk("Helloworld1.\\n");return0;voidclean... 查看详情

如何为不同的 linux 内核编译一个 linux 内核模块

】如何为不同的linux内核编译一个linux内核模块【英文标题】:Howtocompilealinuxkernelmodulefordifferentlinuxkernel【发布时间】:2021-08-1622:25:24【问题描述】:我对内核编程有点陌生,但几天来我一直在为这个问题苦苦挣扎。我有一台带有... 查看详情

linux内核模块管理

模块的全称是动态可加载内核模块,它是具有独立功能的程序,可以被单独编译,但不能独立运行。模块是为内核或其他模块提供功能的代码集合。这些模块可以是Linux源码中自带的,也可以是由硬件厂商开发的&#... 查看详情

linux驱动模块编译进内核中

Linux驱动模块编译进内核中BQ27501驱动编译进内核一、       驱动程序编译进内核的步骤在linux内核中增加程序需要完成以下三项工作:1.将编写的源代码复制到Linux内核源代码的相应目录;2.在目录的Kconfig文件中增加新... 查看详情

编译安装内核(代码片段)

编译安装内核升级内核到linux-4.20.3.tar.xz查看当前内核版本:[[email protected]data]#uname-r3.10.0-862.el7.x86_64获取内核源代码包:www.kernel.orglinux-4.20.3.tar.xz==实施步骤1.安装编译所需的工具gccncurses-develmake(开发工具)2.下载内核源码a.w... 查看详情

已编译模块的数量是不是会影响 RAM 中 Linux 内核的大小?

】已编译模块的数量是不是会影响RAM中Linux内核的大小?【英文标题】:IsnumberofcompiledmodulesaffectingsizeoflinuxkernelinRAM?已编译模块的数量是否会影响RAM中Linux内核的大小?【发布时间】:2013-08-0215:23:23【问题描述】:当我编译Linux内... 查看详情

linux3.5内核模块开发编程(代码片段)

1.1Linux内核模块介绍1.1.1Linux内核模块概述嵌入式设备驱动开发中将驱动程序以模块的形式发布,更是极大地提高了设备使用的灵活性——用户只需要拿到相关驱动模块,再插入到用户的内核中,即可灵活地使用你的设... 查看详情

[第一节]wsl2内核编译/安装内核头文件/驱动调试(代码片段)

[第一节]WSL2内核编译/安装内核头文件/驱动调试WSL2下编写内核模块-简书(jianshu.com)1.查看当前系统的内核版本号lim@TIM:~$uname-r5.4.72-microsoft-standard-WSL22.下载内核源码去github下载对应的linux内核源码包wgethttps://github.com/microsoft/WSL2-Li... 查看详情

linux编译模块小技巧-内核配置文件快速查询模块

#Linux编译模块小技巧-内核配置文件快速查询模块#参考:https://www.linuxidc.com/Linux/2016-10/136157.htmFeb0900:49:17ArchLinuxmount[336]:modprobe:FATAL:Modulefusenotfoundindirectory/lib/modules/5.5.2Feb0900:49:17ArchLinuxmount[289]:fuse:devicenotfound,try‘modprobefuse‘firstmak... 查看详情

linux内核模块开发怎么进行单元测试

usb_register_notify,你当前的系统中运行的内核缺少这个函数定义,你这个因为你要安装的模块,并没有在这个你运行的这个系统中编译生成,而是拿别的机器,或者别人的模块安装在你当前的机器上,不提倡。有源码的话,在你... 查看详情

如何在linux上安装内核头文件

当你在编译一个设备驱动模块时,你需要在系统中安装内核头文件。内核头文件同样在你编译与内核直接链接的用户空间程序时需要。当你在这些情况下安装内核头文件时,你必须确保内核头文件精确地与你当前内核版本匹配(... 查看详情

linux内核开发_1_编译linux内核(代码片段)

目录1.准备工作1.1学习环境1.2下载Linux内核源码1.3解压Linux内核1.4目录结构介绍2.Linux内核配置2.1配置选项1.makeconfig2.makemenuconfig3. makegconfig3开始配置1.配置解释Generalsetup通用选项Enableloadablemodulesupport可加载模块Enabletheblocklayer块设备... 查看详情

linux内核开发_1_编译linux内核(代码片段)

目录1.准备工作1.1学习环境1.2下载Linux内核源码1.3解压Linux内核1.4目录结构介绍2.Linux内核配置2.1配置选项1.makeconfig2.makemenuconfig3. makegconfig3开始配置1.配置解释Generalsetup通用选项Enableloadablemodulesupport可加载模块Enabletheblocklayer块设备... 查看详情